Fix for Invisible Pokémon in Battle

As well as some other fixes like the hit animation also working on models and making the timing more reliable
This commit is contained in:
Jasper "JappaWakka" Speelman 2022-07-23 16:41:00 +02:00
parent 9fa9f93659
commit 7d55ca2c64
5 changed files with 36 additions and 32 deletions

View File

@ -24,7 +24,7 @@
End Sub
Public Overrides Sub Render()
If startDelay = 0.0F AndAlso Me.BackgroundOpacity > 0.0F Then
If Date.Now >= startDelay 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

View File

@ -16,7 +16,7 @@
Me.TransitionSpeed = TransitionSpeed
Me.TargetEntity = entity
Me.TargetEntity.Opacity = StartState
Me.TargetEntity.NormalOpacity = StartState
Me.Visible = False
Me.AnimationType = AnimationTypes.Transition
@ -24,22 +24,22 @@
Public Overrides Sub DoActionActive()
If Me.FadeIn = True Then
If Me.EndState > TargetEntity.Opacity Then
TargetEntity.Opacity += Me.TransitionSpeed
If TargetEntity.Opacity >= Me.EndState Then
TargetEntity.Opacity = Me.EndState
If Me.EndState > TargetEntity.NormalOpacity Then
TargetEntity.NormalOpacity += Me.TransitionSpeed
If TargetEntity.NormalOpacity >= Me.EndState Then
TargetEntity.NormalOpacity = Me.EndState
End If
End If
Else
If Me.EndState < TargetEntity.Opacity Then
TargetEntity.Opacity -= Me.TransitionSpeed
If TargetEntity.Opacity <= Me.EndState Then
TargetEntity.Opacity = Me.EndState
If Me.EndState < TargetEntity.NormalOpacity Then
TargetEntity.NormalOpacity -= Me.TransitionSpeed
If TargetEntity.NormalOpacity <= Me.EndState Then
TargetEntity.NormalOpacity = Me.EndState
End If
End If
End If
If TargetEntity.Opacity = Me.EndState Then
If TargetEntity.NormalOpacity = Me.EndState Then
Me.Ready = True
End If
End Sub

View File

@ -23,15 +23,23 @@
Public AnimationType As AnimationTypes = AnimationTypes.Nothing
Public CanRemove As Boolean = False
Public Ready As Boolean = False
Public startDelay As Single
Public endDelay As Single
Public startDelay As Date
Public endDelay As Date
Public SpawnedEntity As Boolean = False
Public Started As Boolean = False
Private DelayDivide As Single = 6.0F
Private StartDelayWhole As Single
Private StartDelayFraction As Single
Private EndDelayWhole As Single
Private EndDelayFraction As Single
Public Sub New(ByVal Position As Vector3, ByVal Texture As Texture2D, ByVal Scale As Vector3, ByVal startDelay As Single, ByVal endDelay As Single, Optional SpawnedEntity As Boolean = False)
MyBase.New(Position.X, Position.Y, Position.Z, "BattleAnimation", {Texture}, {0, 0}, False, 0, Scale, BaseModel.BillModel, 0, "", New Vector3(1.0F))
Me.startDelay = startDelay
Me.endDelay = endDelay
StartDelayWhole = CSng(Math.Truncate(CDbl(startDelay / DelayDivide)))
StartDelayFraction = startDelay / DelayDivide - StartDelayWhole
EndDelayWhole = CSng(Math.Truncate(CDbl(endDelay / DelayDivide)))
EndDelayFraction = endDelay / DelayDivide - EndDelayWhole
Me.SpawnedEntity = SpawnedEntity
@ -40,26 +48,19 @@
End Sub
Public Overrides Sub Update()
If Started = False Then
Me.startDelay = Date.Now + New TimeSpan(0, 0, 0, CInt(StartDelayWhole), CInt(StartDelayFraction * 1000))
Me.endDelay = Date.Now + New TimeSpan(0, 0, 0, CInt(EndDelayWhole), CInt(EndDelayFraction * 1000))
Started = True
End If
If CanRemove = False Then
If Ready = True Then
If endDelay > 0.0F Then
endDelay -= 0.1F
If endDelay <= 0.0F Then
endDelay = 0.0F
End If
Else
If Date.Now >= endDelay Then
CanRemove = True
DoRemoveEntity()
End If
Else
If startDelay > 0.0F Then
startDelay -= 0.1F
If startDelay <= 0.0F Then
startDelay = 0.0F
End If
Else
If Date.Now >= startDelay Then
If SpawnedEntity = True Then
Ready = True
Else
@ -93,7 +94,7 @@
End Sub
Public Overrides Sub Render()
If Me.startDelay <= 0.0F Then
If Date.Now >= startDelay Then
If CanRemove = False Then
If Me.Model Is Nothing Then
Draw(Me.BaseModel, Me.Textures, True)

View File

@ -4377,9 +4377,11 @@
Public Sub ReduceHP(ByVal HPAmount As Integer, ByVal own As Boolean, ByVal from As Boolean, ByVal BattleScreen As BattleScreen, ByVal message As String, ByVal cause As String, ByVal sound As String)
Dim p As Pokemon = BattleScreen.OwnPokemon
Dim pNPC As Entity = BattleScreen.OwnPokemonNPC
Dim pModel As Entity = BattleScreen.OwnPokemonModel
If own = False Then
p = BattleScreen.OppPokemon
pNPC = BattleScreen.OppPokemonNPC
pModel = BattleScreen.OppPokemonModel
End If
If p.HP > 0 And p.Status <> Pokemon.StatusProblems.Fainted Then
@ -4396,13 +4398,14 @@
BattleScreen.BattleQuery.Add(New PlaySoundQueryObject(sound, False, 0.0F))
End If
If Core.Player.ShowBattleAnimations <> 0 Then
Dim HitAnimation As AnimationQueryObject = New AnimationQueryObject(pNPC, own)
Dim HitAnimation As AnimationQueryObject = New AnimationQueryObject(pNPC, own, pModel)
HitAnimation.AnimationFade(Nothing, False, 1, False, 0, 0, 0)
HitAnimation.AnimationFade(Nothing, False, 1, True, 1, 1, 0)
HitAnimation.AnimationFade(Nothing, False, 1, False, 0, 2, 0)
HitAnimation.AnimationFade(Nothing, False, 1, True, 1, 3, 0)
BattleScreen.BattleQuery.Add(HitAnimation)
End If
If own = True Then
BattleScreen.BattleQuery.Add(New MathHPQueryObject(p.HP, p.MaxHP, HPAmount, New Vector2(200, 256)))
Else

View File

@ -195,7 +195,7 @@
Else
FadeEntity = Entity
End If
If startState = -1.0F Then startState = FadeEntity.Opacity
If startState = -1 Then startState = FadeEntity.NormalOpacity
Dim baEntityOpacity As BAEntityOpacity = New BAEntityOpacity(FadeEntity, RemoveEntityAfter, TransitionSpeed, FadeIn, EndState, startDelay, endDelay, startState)
AnimationSequence.Add(baEntityOpacity)