Added Battle Animation type Background to temporarily draw a texture to the screen behind the Pokémon but in front of the world

This commit is contained in:
JappaWakka 2021-10-21 20:44:38 +02:00 committed by JappaWakkaP3D
parent 2c3f46cd2e
commit 673178616f
5 changed files with 142 additions and 4 deletions

View File

@ -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

View File

@ -17,6 +17,7 @@
Wait
ViewPokeBill
Sound
Background
End Enum
Public AnimationType As AnimationTypes = AnimationTypes.Nothing

View File

@ -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()

View File

@ -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

View File

@ -27546,6 +27546,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Compile Include="Battle\BattleAnimations\BAEntityColor.vb" />
<Compile Include="Battle\BattleAnimations\BABackground.vb" />
<Compile Include="Battle\BattleAnimations\BAEntityRotate.vb" />
<Compile Include="Battle\BattleAnimations\BAEntityMove.vb" />
<Compile Include="Battle\BattleAnimations\BAEntityOpacity.vb" />