Fixed previewer interaction with boxes for SummaryScreen

This commit is contained in:
CaptainSegis 2017-03-23 00:00:50 -05:00
parent d39eb53bbd
commit 0f839cce23

View File

@ -13,6 +13,9 @@
'Pointer
Private _pointerDest As Integer = 0
Private _pointerPos As Single = 0F
Private _pokemonDest As Integer = 0
Private _pokemonPos As Single = 0F
Private _previewerOffset As Integer = 0
'Fade in animation:
Private _fadeIn As Single = 0F
@ -56,9 +59,10 @@
_partyIndex = partyIndex
_party = party
SetPointerDest(_partyIndex)
SetDest(_partyIndex)
GetYOffset()
_pointerPos = _pointerDest
_pokemonPos = _pokemonDest
_moveSelectorPosition = GetMoveSelectorDest(_moveIndex)
End Sub
@ -71,9 +75,10 @@
_pageIndex = Player.Temp.PokemonSummaryPageIndex
_selectedPokemon = selectedPokemon
SetPointerDest(_partyIndex)
SetDest(_partyIndex)
GetYOffset()
_pointerPos = _pointerDest
_pokemonPos = _pokemonDest
_moveSelectorPosition = GetMoveSelectorDest(_moveIndex)
End Sub
@ -138,7 +143,7 @@
If _partyIndex > -1 Then
For i = 0 To _party.Count - 1
Dim pokemonPos As Double = GetPointerDest(i) - 16
Dim pokemonPos As Double = GetPokemonDest(i) - 16 - (64 + 16) * (_pokemonDest - _pokemonPos)
Core.SpriteBatch.Draw(_party(i).GetMenuTexture(), New Rectangle(CInt(pokemonPos), 16, 64, 64), mainBackgroundColor)
Next
@ -600,7 +605,7 @@
If _partyIndex > 0 Then
_partyIndex -= 1
GetYOffset()
SetPointerDest(_partyIndex)
SetDest(_partyIndex)
End If
End If
@ -608,7 +613,7 @@
If _partyIndex < _party.Count - 1 Then
_partyIndex += 1
GetYOffset()
SetPointerDest(_partyIndex)
SetDest(_partyIndex)
End If
End If
@ -743,39 +748,60 @@
_pointerPos = _pointerDest
End If
End If
If _pokemonPos < _pokemonDest Then
_pokemonPos = MathHelper.Lerp(_pokemonDest, _pokemonPos, 0.8F)
If _pokemonPos >= _pokemonDest Then
_pokemonPos = _pokemonDest
End If
ElseIf _pokemonPos > _pokemonDest Then
_pokemonPos = MathHelper.Lerp(_pokemonDest, _pokemonPos, 0.8F)
If _pokemonPos <= _pokemonDest Then
_pokemonPos = _pokemonDest
End If
End If
End Sub
Private Function GetPointerDest(ByVal partyIndex As Integer) As Integer
Private Function GetDest(ByVal partyIndex As Integer) As Integer
Dim pointerX As Double = Core.ScreenSize.Width / 2
If _party.Length Mod 2 = 0 Then
'Even:
Dim half As Integer = CInt(_party.Length / 2)
If partyIndex < _party.Length / 2 Then
pointerX -= (8 + 64 * (half - partyIndex) + 16 * ((half - 1) - partyIndex))
Else
pointerX += (8 + (64 + 16) * (partyIndex - half))
End If
Else
'Odd:
Dim half As Integer = CInt(Math.Floor(_party.Length / 2))
If partyIndex < half Then
pointerX -= (16 + 64) * (half - partyIndex)
ElseIf partyIndex > half Then
pointerX += (16 + 64) * (partyIndex - half)
End If
pointerX += (64 + 16) * (partyIndex - half)
End If
Return CInt(pointerX)
End Function
Private Sub SetPointerDest(ByVal partyIndex As Integer)
Private Function GetPointerDest(ByVal partyIndex As Integer) As Integer
Dim pointerX As Double = GetDest(partyIndex)
_previewerOffset = 0
While pointerX > Core.ScreenSize.Width - (64 + 16)
pointerX -= (64 + 16)
_previewerOffset -= 1
End While
While pointerX < (64)
pointerX += (64 + 16)
_previewerOffset += 1
End While
Return CInt(pointerX)
End Function
Private Function GetPokemonDest(ByVal partyIndex As Integer) As Integer
Dim pointerX As Double = GetDest(partyIndex)
pointerX += (_previewerOffset * (64 + 16))
Return CInt(pointerX)
End Function
Private Sub SetDest(ByVal partyIndex As Integer)
_fadeIn = 0F
_pixelFade = 0F
_pointerDest = GetPointerDest(partyIndex)
_pokemonDest = _previewerOffset
If GetPokemon().IsEgg() = False Then
GetPokemon().PlayCry()
End If