From 673178616f721e46739d09e81846981788c5693d Mon Sep 17 00:00:00 2001 From: JappaWakka Date: Thu, 21 Oct 2021 20:44:38 +0200 Subject: [PATCH] =?UTF-8?q?Added=20Battle=20Animation=20type=20Background?= =?UTF-8?q?=20to=20temporarily=20draw=20a=20texture=20to=20the=20screen=20?= =?UTF-8?q?behind=20the=20Pok=C3=A9mon=20but=20in=20front=20of=20the=20wor?= =?UTF-8?q?ld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- P3D/Battle/BattleAnimations/BABackground.vb | 60 +++++++++++++++++ .../BattleAnimations/BattleAnimation3D.vb | 1 + P3D/Battle/BattleSystemV2/BattleScreen.vb | 65 ++++++++++++++++++- .../QueryObjects/AnimationQueryObject.vb | 19 +++++- P3D/P3D.vbproj | 1 + 5 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 P3D/Battle/BattleAnimations/BABackground.vb diff --git a/P3D/Battle/BattleAnimations/BABackground.vb b/P3D/Battle/BattleAnimations/BABackground.vb new file mode 100644 index 000000000..929acc114 --- /dev/null +++ b/P3D/Battle/BattleAnimations/BABackground.vb @@ -0,0 +1,60 @@ +Public Class BABackground + + Inherits BattleAnimation3D + + Public TransitionSpeed As Single = 0.01F + Public FadeIn As Boolean = False + Public FadeOut As Boolean = False + Public BackgroundOpacity As Single = 1.0F + Public EndState As Single = 0.0F + Public Texture As Texture2D + + Public Sub New(ByVal Texture As Texture2D, ByVal TransitionSpeed As Single, ByVal FadeIn As Boolean, FadeOut As Boolean, ByVal EndState As Single, ByVal startDelay As Single, ByVal endDelay As Single, Optional ByVal StartState As Single = 0.0F) + MyBase.New(New Vector3(0.0F), TextureManager.DefaultTexture, New Vector3(1.0F), startDelay, endDelay) + Me.Texture = Texture + Me.EndState = EndState + Me.FadeIn = FadeIn + Me.FadeOut = FadeOut + Me.TransitionSpeed = TransitionSpeed + + Me.BackgroundOpacity = StartState + Me.Visible = False + + Me.AnimationType = AnimationTypes.Background + End Sub + + Public Overrides Sub Render() + If startDelay = 0.0F AndAlso Me.BackgroundOpacity > 0.0F Then + Core.SpriteBatch.Draw(Me.Texture, New Rectangle(0, 0, windowSize.Width, windowSize.Height), New Color(255, 255, 255, CInt(255 * Me.BackgroundOpacity))) + End If + End Sub + + Public Overrides Sub DoActionActive() + If Me.FadeIn = True Then + If Me.EndState > Me.BackgroundOpacity Then + Me.BackgroundOpacity += Me.TransitionSpeed + If Me.BackgroundOpacity >= Me.EndState Then + Me.BackgroundOpacity = Me.EndState + Me.FadeIn = False + Me.EndState = 0 + End If + End If + Else + If Me.FadeOut = True Then + If Me.EndState < Me.BackgroundOpacity Then + Me.BackgroundOpacity -= Me.TransitionSpeed + If Me.BackgroundOpacity <= Me.EndState Then + Me.BackgroundOpacity = Me.EndState + End If + End If + If Me.BackgroundOpacity = Me.EndState Then + Me.Ready = True + End If + Else + Me.BackgroundOpacity = Me.EndState + Me.Ready = True + End If + End If + End Sub + +End Class \ No newline at end of file diff --git a/P3D/Battle/BattleAnimations/BattleAnimation3D.vb b/P3D/Battle/BattleAnimations/BattleAnimation3D.vb index 1aeb45e27..8011ce1d2 100644 --- a/P3D/Battle/BattleAnimations/BattleAnimation3D.vb +++ b/P3D/Battle/BattleAnimations/BattleAnimation3D.vb @@ -17,6 +17,7 @@ Wait ViewPokeBill Sound + Background End Enum Public AnimationType As AnimationTypes = AnimationTypes.Nothing diff --git a/P3D/Battle/BattleSystemV2/BattleScreen.vb b/P3D/Battle/BattleSystemV2/BattleScreen.vb index 4cc142822..a4dcf7821 100644 --- a/P3D/Battle/BattleSystemV2/BattleScreen.vb +++ b/P3D/Battle/BattleSystemV2/BattleScreen.vb @@ -768,7 +768,33 @@ Public Overrides Sub Draw() SkyDome.Draw(45.0F) + + Dim ForegroundEntities As New List(Of Entity) + For Each e As Entity In Level.Entities + If e Is OwnPokemonNPC Then + ForegroundEntities.Add(e) + End If + If e Is OppPokemonNPC Then + ForegroundEntities.Add(e) + End If + If e Is OwnTrainerNPC Then + ForegroundEntities.Add(e) + End If + If e Is OppTrainerNPC Then + ForegroundEntities.Add(e) + End If + If e Is OwnPokemonModel Then + ForegroundEntities.Add(e) + End If + If e Is OppPokemonModel Then + ForegroundEntities.Add(e) + End If + Next + If ForegroundEntities.Count > 0 Then + ForegroundEntities = (From f In ForegroundEntities Order By f.CameraDistance Descending).ToList() + End If Level.Draw() + World.DrawWeather(Screen.Level.World.CurrentMapWeather) If HasToWaitPVP() = True Then @@ -781,13 +807,25 @@ End If End If + Dim ForegroundAnimationList As New List(Of AnimationQueryObject) If BattleQuery.Count > 0 Then Dim cIndex As Integer = 0 Dim cQuery As New List(Of QueryObject) nextIndex: If BattleQuery.Count > cIndex Then Dim cQueryObject As QueryObject = BattleQuery(cIndex) - cQuery.Add(cQueryObject) + If cQueryObject.QueryType = QueryObject.QueryTypes.MoveAnimation Then + If CType(cQueryObject, AnimationQueryObject).DrawBeforeEntities = False Then + cQuery.Add(cQueryObject) + Else + ForegroundAnimationList.Add(CType(cQueryObject, AnimationQueryObject)) + cIndex += 1 + GoTo nextIndex + End If + Else + cQuery.Add(cQueryObject) + End If + If cQueryObject.PassThis = True Then cIndex += 1 @@ -802,6 +840,31 @@ nextIndex: Next End If + If ForegroundAnimationList.Count > 0 Then + For i = 0 To ForegroundEntities.Count - 1 + ForegroundEntities(i).Render() + DebugDisplay.MaxVertices += ForegroundEntities(i).VertexCount + Next + + Dim cIndex As Integer = 0 + Dim cQuery As New List(Of QueryObject) +nextIndexForeground: + If ForegroundAnimationList.Count > cIndex Then + Dim cQueryObject As QueryObject = ForegroundAnimationList(cIndex) + cQuery.Add(cQueryObject) + + If cQueryObject.PassThis = True Then + cIndex += 1 + GoTo nextIndexForeground + End If + End If + + cQuery.Reverse() + + For Each cQueryObject As QueryObject In cQuery + cQueryObject.Draw(Me) + Next + End If 'Core.SpriteBatch.DrawString(FontManager.MiniFont, "Battle system not final!", New Vector2(0, Core.windowSize.Height - 20), Color.White) TextBox.Draw() diff --git a/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb b/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb index ff0d88d2f..fba7a46b3 100644 --- a/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb +++ b/P3D/Battle/BattleSystemV2/QueryObjects/AnimationQueryObject.vb @@ -10,6 +10,7 @@ Public SpawnedEntities As List(Of Entity) Public CurrentEntity As Entity Public CurrentModel As ModelEntity + Public DrawBeforeEntities As Boolean Public Overrides ReadOnly Property IsReady As Boolean Get @@ -17,9 +18,10 @@ End Get End Property - Public Sub New(ByVal entity As Entity, ByVal BattleFlipped As Boolean, Optional ByVal model As ModelEntity = Nothing) + Public Sub New(ByVal entity As Entity, ByVal BattleFlipped As Boolean, Optional ByVal model As ModelEntity = Nothing, Optional DrawBeforeEntities As Boolean = False) MyBase.New(QueryTypes.MoveAnimation) Me.AnimationSequence = New List(Of BattleAnimation3D) + Me.DrawBeforeEntities = DrawBeforeEntities If BattleFlipped <> Nothing Then Me.BattleFlipped = BattleFlipped End If @@ -28,14 +30,22 @@ AnimationSequenceBegin() End Sub Public Overrides Sub Draw(ByVal BV2Screen As BattleScreen) + Dim Backgrounds As New List(Of Entity) + Dim RenderObjects As New List(Of Entity) For Each a As BattleAnimation3D In Me.AnimationSequence - RenderObjects.Add(a) + If a.AnimationType = BattleAnimation3D.AnimationTypes.Background Then + Backgrounds.Add(a) + Else + RenderObjects.Add(a) + End If Next If RenderObjects.Count > 0 Then RenderObjects = (From r In RenderObjects Order By r.CameraDistance Descending).ToList() End If - + For Each [Object] As Entity In Backgrounds + [Object].Render() + Next For Each [Object] As Entity In RenderObjects [Object].Render() Next @@ -218,6 +228,9 @@ AnimationSequence.Add(baSound) End Sub + Public Sub AnimationBackground(Texture As Texture2D, ByVal RemoveEntityAfter As Boolean, ByVal TransitionSpeed As Single, ByVal FadeIn As Boolean, ByVal FadeOut As Boolean, ByVal EndState As Single, ByVal startDelay As Single, ByVal endDelay As Single, Optional ByVal startState As Single = 0.0F) + Dim baBackground As BABackground = New BABackground(Texture, TransitionSpeed, FadeIn, FadeOut, EndState, startDelay, endDelay, startState) + AnimationSequence.Add(baBackground) End Sub End Class diff --git a/P3D/P3D.vbproj b/P3D/P3D.vbproj index 892230fc9..28784aeb7 100644 --- a/P3D/P3D.vbproj +++ b/P3D/P3D.vbproj @@ -27546,6 +27546,7 @@ PreserveNewest +