2023-05-18 20:25:38 +02:00
Imports P3D . Screens . UI
Namespace VoltorbFlip
Public Class VoltorbFlipScreen
Inherits Screen
2023-05-22 19:33:09 +02:00
' Variables & Properties
Private _screenTransitionY As Single = 0F
Public Shared _interfaceFade As Single = 0F
2023-05-25 18:37:37 +02:00
Private Delay As Integer = 0
2023-05-27 15:09:41 +02:00
Private MemoMenuX As Single = 0F
2023-05-25 18:37:37 +02:00
Private MemoMenuSize As New Size ( 112 , 112 )
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
Private Shared ReadOnly GameSize As New Size ( 576 , 544 )
2023-05-22 19:33:09 +02:00
Public Shared ReadOnly BoardSize As New Size ( 384 , 384 )
Public Shared ReadOnly TileSize As New Size ( 64 , 64 )
Private Shared ReadOnly GridSize As Integer = 5
2023-05-27 15:44:01 +02:00
Public Shared GameOrigin As New Vector2 ( CInt ( windowSize . Width / 2 - GameSize . Width / 2 - 32 ) , CInt ( windowSize . Height / 2 - GameSize . Height / 2 ) )
2023-05-27 15:09:41 +02:00
Public Shared BoardOrigin As New Vector2 ( GameOrigin . X + 32 , GameOrigin . Y + 160 )
2023-05-28 21:34:20 +02:00
Public Shared TutorialRectangle As New Rectangle ( CInt ( windowSize . Width / 2 - 512 / 2 ) , CInt ( windowSize . Height / 2 - 384 / 2 ) , 512 , 384 )
2023-05-18 20:25:38 +02:00
2023-05-19 17:02:59 +02:00
Private BoardCursorPosition As New Vector2 ( 0 , 0 )
Private BoardCursorDestination As New Vector2 ( 0 , 0 )
2023-05-18 20:25:38 +02:00
2023-05-28 09:58:33 +02:00
Private NewLevelMenuIndex As Integer = 0
2023-05-19 17:02:59 +02:00
Private MemoIndex As Integer = 0
2023-05-22 19:33:09 +02:00
Public Shared GameState As States = States . Opening
2023-05-24 14:30:38 +02:00
Public Shared Property PreviousLevel As Integer = 1
Public Shared Property CurrentLevel As Integer = 1
2023-05-22 19:33:09 +02:00
Public Shared ReadOnly MinLevel As Integer = 1
2023-05-24 11:49:18 +02:00
Public Shared ReadOnly MaxLevel As Integer = 7
Public Shared Property CurrentFlips As Integer = 0
Public Shared Property TotalFlips As Integer = 0
2023-05-22 19:33:09 +02:00
Public Shared Property CurrentCoins As Integer = 0
2023-05-27 15:09:41 +02:00
Public Shared Property TotalCoins As Integer = - 1
2023-05-27 16:10:30 +02:00
Public Shared Property ConsecutiveWins As Integer = 0
2023-05-27 15:09:41 +02:00
Public Shared MaxCoins As Integer = 1
2023-05-18 20:25:38 +02:00
2023-05-19 17:02:59 +02:00
Public Board As List ( Of List ( Of Tile ) )
2023-05-21 20:40:12 +02:00
Public VoltorbSums As List ( Of List ( Of Integer ) )
Public CoinSums As List ( Of List ( Of Integer ) )
2023-05-19 17:02:59 +02:00
Public Enum States
Opening
Closing
2023-05-22 19:33:09 +02:00
QuitQuestion
2023-05-19 17:02:59 +02:00
Game
Memo
GameWon
GameLost
2023-05-22 19:33:09 +02:00
FlipWon
FlipLost
2023-05-28 09:58:33 +02:00
NewLevelQuestion
2023-05-19 17:02:59 +02:00
NewLevel
End Enum
2023-05-18 20:25:38 +02:00
'Stuff related to blurred PreScreens
2023-05-22 19:33:09 +02:00
Private _blur As Resources . Blur . BlurHandler
2023-05-18 20:25:38 +02:00
Private _preScreenTexture As RenderTarget2D
Private _preScreenTarget As RenderTarget2D
Private _blurScreens As Identifications ( ) = { Identifications . BattleScreen ,
Identifications . OverworldScreen ,
Identifications . DirectTradeScreen ,
Identifications . WonderTradeScreen ,
Identifications . GTSSetupScreen ,
Identifications . GTSTradeScreen ,
Identifications . PVPLobbyScreen }
Public Sub New ( ByVal currentScreen As Screen )
2023-05-25 18:37:37 +02:00
GameState = States . Opening
2023-05-27 15:44:01 +02:00
GameOrigin = New Vector2 ( CInt ( windowSize . Width / 2 - GameSize . Width / 2 - 32 ) , CInt ( windowSize . Height / 2 - _screenTransitionY ) )
2023-05-27 15:09:41 +02:00
BoardOrigin = New Vector2 ( GameOrigin . X + 32 , GameOrigin . Y + 160 )
2023-05-28 21:34:20 +02:00
TutorialRectangle = New Rectangle ( CInt ( windowSize . Width / 2 - 512 / 2 ) , CInt ( windowSize . Height / 2 - 384 / 2 ) , 512 , 384 )
2023-05-25 18:37:37 +02:00
BoardCursorDestination = GetCursorOffset ( 0 , 0 )
BoardCursorPosition = GetCursorOffset ( 0 , 0 )
Board = CreateBoard ( CurrentLevel )
2023-05-27 15:09:41 +02:00
TotalCoins = 0
2023-05-18 20:25:38 +02:00
_preScreenTarget = New RenderTarget2D ( GraphicsDevice , windowSize . Width , windowSize . Height , False , SurfaceFormat . Color , DepthFormat . Depth24Stencil8 )
_blur = New Resources . Blur . BlurHandler ( windowSize . Width , windowSize . Height )
Identification = Identifications . VoltorbFlipScreen
PreScreen = currentScreen
Me . MouseVisible = True
Me . CanChat = Me . PreScreen . CanChat
Me . CanBePaused = Me . PreScreen . CanBePaused
End Sub
Public Overrides Sub Draw ( )
If _blurScreens . Contains ( PreScreen . Identification ) Then
DrawPrescreen ( )
Else
PreScreen . Draw ( )
End If
2023-05-25 18:37:37 +02:00
2023-05-18 20:25:38 +02:00
DrawBackground ( )
2023-05-23 14:14:15 +02:00
DrawMemoMenuAndButton ( )
2023-05-25 18:37:37 +02:00
If Board IsNot Nothing Then
DrawBoard ( )
DrawCursor ( )
End If
2023-05-28 09:58:33 +02:00
2023-05-25 18:37:37 +02:00
DrawHUD ( )
DrawQuitButton ( )
2023-05-28 21:34:20 +02:00
DrawTutorial ( )
2023-05-18 20:25:38 +02:00
2023-05-27 15:44:01 +02:00
ChooseBox . Draw ( )
TextBox . Draw ( )
2023-05-22 19:33:09 +02:00
End Sub
2023-05-18 20:25:38 +02:00
Private Sub DrawPrescreen ( )
If _preScreenTexture Is Nothing OrElse _preScreenTexture . IsContentLost Then
SpriteBatch . EndBatch ( )
Dim target As RenderTarget2D = _preScreenTarget
GraphicsDevice . SetRenderTarget ( target )
GraphicsDevice . Clear ( BackgroundColor )
SpriteBatch . BeginBatch ( )
PreScreen . Draw ( )
SpriteBatch . EndBatch ( )
GraphicsDevice . SetRenderTarget ( Nothing )
SpriteBatch . BeginBatch ( )
_preScreenTexture = target
End If
If _interfaceFade < 1 . 0F Then
SpriteBatch . Draw ( _preScreenTexture , windowSize , Color . White )
End If
SpriteBatch . Draw ( _blur . Perform ( _preScreenTexture ) , windowSize , New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade * 2 ) . Clamp ( 0 , 255 ) ) )
End Sub
Private Sub DrawBackground ( )
2023-05-22 19:33:09 +02:00
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
2023-05-18 20:25:38 +02:00
End If
2023-05-27 15:09:41 +02:00
Canvas . DrawImageBorder ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Background " ) , 2 , New Rectangle ( CInt ( GameOrigin . X ) , CInt ( GameOrigin . Y ) , CInt ( GameSize . Width ) , CInt ( GameSize . Height ) ) , mainBackgroundColor , False )
2023-05-25 18:37:37 +02:00
End Sub
Private Sub DrawHUD ( )
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
Dim Fontcolor As Color = New Color ( 0 , 0 , 0 )
If GameState = States . Closing Or GameState = States . Opening Then
Fontcolor = New Color ( 0 , 0 , 0 , CInt ( 255 * _interfaceFade ) )
End If
'Level
2023-05-27 16:52:36 +02:00
Dim LevelText As String = Localization . GetString ( " VoltorbFlip_LV. " , " LV. " ) & CurrentLevel . ToString
2023-05-27 15:09:41 +02:00
Canvas . DrawImageBorder ( TextureManager . GetTexture ( " Textures\VoltorbFlip\HUD " ) , 2 , New Rectangle ( CInt ( GameOrigin . X + 32 ) , CInt ( GameOrigin . Y + 32 ) , 96 , 96 ) , mainBackgroundColor , False )
SpriteBatch . DrawString ( FontManager . MainFont , LevelText , New Vector2 ( CInt ( GameOrigin . X + 80 + 4 - FontManager . MainFont . MeasureString ( LevelText ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 - FontManager . MainFont . MeasureString ( LevelText ) . Y / 2 ) ) , Fontcolor )
2023-05-25 18:37:37 +02:00
'Current Coins
2023-05-27 15:09:41 +02:00
Canvas . DrawImageBorder ( TextureManager . GetTexture ( " Textures\VoltorbFlip\HUD " ) , 2 , New Rectangle ( CInt ( GameOrigin . X + 128 + 24 ) , CInt ( GameOrigin . Y + 32 ) , 192 , 96 ) , mainBackgroundColor , False )
2023-05-25 18:37:37 +02:00
2023-05-27 16:52:36 +02:00
Dim CurrentCoinsText1 As String = Localization . GetString ( " VoltorbFlip_CurrentCoins_Line1 " , " Coins found " )
Dim CurrentCoinsText2 As String = Localization . GetString ( " VoltorbFlip_CurrentCoins_Line2 " , " in this LV. " )
2023-05-25 18:37:37 +02:00
Dim CurrentCoinsText3 As String = " "
CurrentCoinsText3 &= " [ "
If CurrentCoins < 10000 Then
CurrentCoinsText3 &= " 0 "
End If
If CurrentCoins < 1000 Then
CurrentCoinsText3 &= " 0 "
End If
If CurrentCoins < 100 Then
CurrentCoinsText3 &= " 0 "
End If
If CurrentCoins < 10 Then
CurrentCoinsText3 &= " 0 "
End If
CurrentCoinsText3 &= CurrentCoins . ToString & " ] "
2023-05-30 10:39:17 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , CurrentCoinsText1 , New Vector2 ( CInt ( GameOrigin . X + 232 + 24 - FontManager . MainFont . MeasureString ( CurrentCoinsText1 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 - FontManager . MainFont . MeasureString ( CurrentCoinsText2 ) . Y / 2 - FontManager . MainFont . MeasureString ( CurrentCoinsText1 ) . Y ) ) , Fontcolor )
SpriteBatch . DrawString ( FontManager . MainFont , CurrentCoinsText2 , New Vector2 ( CInt ( GameOrigin . X + 232 + 24 - FontManager . MainFont . MeasureString ( CurrentCoinsText2 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 - FontManager . MainFont . MeasureString ( CurrentCoinsText2 ) . Y / 2 ) ) , Fontcolor )
SpriteBatch . DrawString ( FontManager . MainFont , CurrentCoinsText3 , New Vector2 ( CInt ( GameOrigin . X + 232 + 24 - FontManager . MainFont . MeasureString ( CurrentCoinsText3 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 + FontManager . MainFont . MeasureString ( CurrentCoinsText2 ) . Y / 2 ) ) , Fontcolor )
2023-05-25 18:37:37 +02:00
'Total Coins
2023-05-27 15:09:41 +02:00
Canvas . DrawImageBorder ( TextureManager . GetTexture ( " Textures\VoltorbFlip\HUD " ) , 2 , New Rectangle ( CInt ( GameOrigin . X + 336 + 32 ) , CInt ( GameOrigin . Y + 32 ) , 192 , 96 ) , mainBackgroundColor , False )
2023-05-25 18:37:37 +02:00
2023-05-30 10:39:17 +02:00
Dim TotalCoinsText1 As String = Localization . GetString ( " VoltorbFlip_TotalCoins_Line1 " , " <player.name>'s " )
Dim TotalCoinsText2 As String = Localization . GetString ( " VoltorbFlip_TotalCoins_Line2 " , " earned Coins " )
2023-05-25 18:37:37 +02:00
Dim TotalCoinsText3 As String = " "
TotalCoinsText3 &= " [ "
2023-05-27 17:48:32 +02:00
If TotalCoins + Core . Player . Coins < 10000 Then
2023-05-25 18:37:37 +02:00
TotalCoinsText3 &= " 0 "
End If
2023-05-27 17:48:32 +02:00
If TotalCoins < 1000 + Core . Player . Coins Then
2023-05-25 18:37:37 +02:00
TotalCoinsText3 &= " 0 "
End If
2023-05-27 17:48:32 +02:00
If TotalCoins < 100 + Core . Player . Coins Then
2023-05-25 18:37:37 +02:00
TotalCoinsText3 &= " 0 "
End If
2023-05-27 17:48:32 +02:00
If TotalCoins < 10 + Core . Player . Coins Then
2023-05-25 18:37:37 +02:00
TotalCoinsText3 &= " 0 "
End If
2023-05-27 17:48:32 +02:00
TotalCoinsText3 &= CInt ( TotalCoins + Core . Player . Coins ) . ToString & " ] "
2023-05-25 18:37:37 +02:00
2023-05-30 10:39:17 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , TotalCoinsText1 , New Vector2 ( CInt ( GameOrigin . X + 440 + 32 - FontManager . MainFont . MeasureString ( TotalCoinsText1 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 - FontManager . MainFont . MeasureString ( TotalCoinsText2 ) . Y / 2 - FontManager . MainFont . MeasureString ( TotalCoinsText1 ) . Y ) ) , Fontcolor )
SpriteBatch . DrawString ( FontManager . MainFont , TotalCoinsText2 , New Vector2 ( CInt ( GameOrigin . X + 440 + 32 - FontManager . MainFont . MeasureString ( TotalCoinsText2 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 - FontManager . MainFont . MeasureString ( TotalCoinsText2 ) . Y / 2 ) ) , Fontcolor )
SpriteBatch . DrawString ( FontManager . MainFont , TotalCoinsText3 , New Vector2 ( CInt ( GameOrigin . X + 440 + 32 - FontManager . MainFont . MeasureString ( TotalCoinsText3 ) . X / 2 ) , CInt ( GameOrigin . Y + 80 + 4 + FontManager . MainFont . MeasureString ( TotalCoinsText2 ) . Y / 2 ) ) , Fontcolor )
2023-05-25 18:37:37 +02:00
2023-05-18 20:25:38 +02:00
End Sub
2023-05-28 21:34:20 +02:00
Private Sub DrawTutorial ( )
2023-05-29 09:57:39 +02:00
Dim MainColor As Color = New Color ( 255 , 255 , 255 )
2023-05-28 21:34:20 +02:00
If GameState = States . Closing Or GameState = States . Opening Then
2023-05-29 09:57:39 +02:00
MainColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
2023-05-28 21:34:20 +02:00
End If
Dim FontColor As Color = New Color ( 0 , 0 , 0 )
If GameState = States . Closing Or GameState = States . Opening Then
FontColor = New Color ( 0 , 0 , 0 , CInt ( 255 * _interfaceFade ) )
End If
2023-05-29 09:57:39 +02:00
If GameState = States . NewLevelQuestion Then
2023-05-28 21:34:20 +02:00
Select Case NewLevelMenuIndex
Case 2 'How to Play
2023-05-29 09:57:39 +02:00
SpriteBatch . DrawRectangle ( New Rectangle ( CInt ( GameOrigin . X ) , CInt ( GameOrigin . Y ) , GameSize . Width + 64 , GameSize . Height + 32 ) , New Color ( 0 , 0 , 0 , 128 ) )
2023-05-28 21:34:20 +02:00
Dim TutorialString1 As String = Localization . GetString ( " VoltorbFlip_Tutorial_HowToPlay_Image1 " , " If you flip the cards in this order, you'll collect: 3 x 1 x 2 x 1 x 3... A total of 18 Coins! And then... " )
Dim TutorialString2 As String = Localization . GetString ( " VoltorbFlip_Tutorial_HowToPlay_Image2 " , " If you select "" Quit "" , you'll keep those 18 Coins. " )
Dim TutorialString3 As String = Localization . GetString ( " VoltorbFlip_Tutorial_HowToPlay_Image3 " , " But if you find Voltorb, you'll lose all your Coins! " )
2023-05-29 09:57:39 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Tutorial_HowToPlay " ) , New Rectangle ( CInt ( TutorialRectangle . X ) , CInt ( TutorialRectangle . Y ) , TutorialRectangle . Width , TutorialRectangle . Height ) , MainColor )
2023-05-28 21:34:20 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , TutorialString1 . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) , New Vector2 ( CInt ( TutorialRectangle . X + 256 - FontManager . MainFont . MeasureString ( TutorialString1 . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . X / 2 ) , CInt ( TutorialRectangle . Y + 128 - FontManager . MainFont . MeasureString ( TutorialString1 . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . Y / 2 ) ) , FontColor )
SpriteBatch . DrawString ( FontManager . MainFont , TutorialString2 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) , New Vector2 ( CInt ( TutorialRectangle . X + 336 - FontManager . MainFont . MeasureString ( TutorialString2 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) ) . X / 2 ) , CInt ( TutorialRectangle . Y + 256 - FontManager . MainFont . MeasureString ( TutorialString2 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) ) . Y / 2 ) ) , FontColor )
SpriteBatch . DrawString ( FontManager . MainFont , TutorialString3 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) , New Vector2 ( CInt ( TutorialRectangle . X + 336 - FontManager . MainFont . MeasureString ( TutorialString2 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) ) . X / 2 ) , CInt ( TutorialRectangle . Y + 336 - FontManager . MainFont . MeasureString ( TutorialString3 . CropStringToWidth ( FontManager . MainFont , 1 , 304 ) ) . Y / 2 ) ) , FontColor )
2023-05-29 09:57:39 +02:00
Dim QuitButtonText As String = Localization . GetString ( " VoltorbFlip_QuitButton " , " Quit " )
SpriteBatch . DrawString ( FontManager . MainFont , QuitButtonText , New Vector2 ( CInt ( TutorialRectangle . X + 8 + 128 / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . X / 2 ) , CInt ( TutorialRectangle . Y + 228 + 56 / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . Y / 2 ) ) , FontColor )
SpriteBatch . DrawString ( FontManager . MainFont , QuitButtonText , New Vector2 ( CInt ( TutorialRectangle . X + 8 + 128 / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . X / 2 - 2 ) , CInt ( TutorialRectangle . Y + 228 + 56 / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . Y / 2 - 2 ) ) , MainColor )
2023-05-28 21:34:20 +02:00
Case 3 'Hint
2023-05-29 09:57:39 +02:00
SpriteBatch . DrawRectangle ( New Rectangle ( CInt ( GameOrigin . X ) , CInt ( GameOrigin . Y ) , GameSize . Width + 64 , GameSize . Height + 32 ) , New Color ( 0 , 0 , 0 , 128 ) )
2023-05-28 21:34:20 +02:00
Dim TutorialString As String = Localization . GetString ( " VoltorbFlip_Tutorial_Hint_Image " , " By looking at the numbers on the sides of the cards, you can see the hidden number and Voltorb totals. " )
2023-05-29 09:57:39 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Tutorial_Hint " ) , New Rectangle ( CInt ( TutorialRectangle . X ) , CInt ( TutorialRectangle . Y ) , TutorialRectangle . Width , TutorialRectangle . Height ) , MainColor )
2023-05-28 21:34:20 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) , New Vector2 ( CInt ( TutorialRectangle . X + 256 - FontManager . MainFont . MeasureString ( TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . X / 2 ) , CInt ( TutorialRectangle . Y + 320 - FontManager . MainFont . MeasureString ( TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . Y / 2 ) ) , FontColor )
Case 4 'About Memos
2023-05-29 09:57:39 +02:00
SpriteBatch . DrawRectangle ( New Rectangle ( CInt ( GameOrigin . X ) , CInt ( GameOrigin . Y ) , GameSize . Width + 64 , GameSize . Height + 32 ) , New Color ( 0 , 0 , 0 , 128 ) )
2023-05-28 21:34:20 +02:00
Dim TutorialString As String = Localization . GetString ( " VoltorbFlip_Tutorial_AboutMemos_Image " , " Select "" Open Memo "" to open the Memo Window. Select the cards and press [<system.button(enter1)>] to add and [<system.button(back1)>] to remove marks. " )
Dim ButtonTextTop As String = Localization . GetString ( " VoltorbFlip_MemoButton_Open_Line1 " , " Open " )
Dim ButtonTextBottom As String = Localization . GetString ( " VoltorbFlip_MemoButton_Open_Line2 " , " Memos " )
2023-05-29 09:57:39 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Tutorial_AboutMemos " ) , New Rectangle ( CInt ( TutorialRectangle . X ) , CInt ( TutorialRectangle . Y ) , TutorialRectangle . Width , TutorialRectangle . Height ) , MainColor )
2023-05-28 21:34:20 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) , New Vector2 ( CInt ( TutorialRectangle . X + 256 - FontManager . MainFont . MeasureString ( TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . X / 2 ) , CInt ( TutorialRectangle . Y + 304 - FontManager . MainFont . MeasureString ( TutorialString . CropStringToWidth ( FontManager . MainFont , 1 , 448 ) ) . Y / 2 ) ) , FontColor )
SpriteBatch . DrawString ( FontManager . MainFont , ButtonTextTop , New Vector2 ( CInt ( TutorialRectangle . X + 64 + MemoMenuSize . Width / 2 - FontManager . MainFont . MeasureString ( ButtonTextTop ) . X / 2 ) , CInt ( TutorialRectangle . Y + 104 ) ) , FontColor )
SpriteBatch . DrawString ( FontManager . MainFont , ButtonTextBottom , New Vector2 ( CInt ( TutorialRectangle . X + 64 + MemoMenuSize . Width / 2 - FontManager . MainFont . MeasureString ( ButtonTextBottom ) . X / 2 ) , CInt ( TutorialRectangle . Y + 104 + FontManager . MainFont . MeasureString ( ButtonTextTop ) . Y ) ) , FontColor )
End Select
End If
End Sub
2023-05-22 19:33:09 +02:00
Private Sub DrawBoard ( )
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
SpriteBatch . Draw ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Board " ) , New Rectangle ( CInt ( BoardOrigin . X ) , CInt ( BoardOrigin . Y ) , BoardSize . Width , BoardSize . Height ) , mainBackgroundColor )
DrawTiles ( )
2023-05-24 11:49:18 +02:00
DrawSums ( )
2023-05-22 19:33:09 +02:00
End Sub
Private Sub DrawTiles ( )
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Dim _tile As Tile = Board ( _row ) ( _column )
_tile . Draw ( )
Next
Next
End Sub
2023-05-23 14:14:15 +02:00
2023-05-24 11:49:18 +02:00
Private Sub DrawSums ( )
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
'Draw Rows
'Coins
For RowIndex = 0 To GridSize - 1
Dim CoinSumString As String = " 00 "
2023-05-27 15:09:41 +02:00
If GameState = States . Game Or GameState = States . Memo Or GameState = States . QuitQuestion Then
2023-05-24 11:49:18 +02:00
Dim CoinSumInteger As Integer = CoinSums ( 0 ) ( RowIndex )
If CoinSumInteger < 10 Then
CoinSumString = " 0 " & CoinSumInteger . ToString
Else
CoinSumString = CoinSumInteger . ToString
End If
End If
2023-05-27 15:09:41 +02:00
SpriteBatch . DrawString ( FontManager . VoltorbFlipFont , CoinSumString , New Vector2 ( CInt ( BoardOrigin . X + TileSize . Width * ( GridSize + 1 ) - 8 - FontManager . VoltorbFlipFont . MeasureString ( CoinSumString ) . X ) , BoardOrigin . Y + TileSize . Height * RowIndex + 8 ) , mainBackgroundColor )
2023-05-24 11:49:18 +02:00
Next
'Voltorbs
For RowIndex = 0 To GridSize - 1
Dim VoltorbSumString As String = " 0 "
2023-05-27 15:09:41 +02:00
If GameState = States . Game Or GameState = States . Memo Or GameState = States . QuitQuestion Then
2023-05-24 11:49:18 +02:00
VoltorbSumString = VoltorbSums ( 0 ) ( RowIndex ) . ToString
End If
2023-05-27 15:09:41 +02:00
SpriteBatch . DrawString ( FontManager . VoltorbFlipFont , VoltorbSumString , New Vector2 ( CInt ( BoardOrigin . X + TileSize . Width * ( GridSize + 1 ) - 8 - FontManager . VoltorbFlipFont . MeasureString ( VoltorbSumString ) . X ) , BoardOrigin . Y + TileSize . Height * RowIndex + 34 ) , mainBackgroundColor )
2023-05-24 11:49:18 +02:00
Next
'Draw Columns
'Coins
For ColumnIndex = 0 To GridSize - 1
Dim CoinSumString As String = " 00 "
2023-05-27 15:40:38 +02:00
If GameState = States . Game Or GameState = States . Memo Or GameState = States . QuitQuestion Then
2023-05-24 11:49:18 +02:00
Dim CoinSumInteger As Integer = CoinSums ( 1 ) ( ColumnIndex )
If CoinSumInteger < 10 Then
CoinSumString = " 0 " & CoinSumInteger . ToString
Else
CoinSumString = CoinSumInteger . ToString
End If
End If
2023-05-27 15:09:41 +02:00
SpriteBatch . DrawString ( FontManager . VoltorbFlipFont , CoinSumString , New Vector2 ( CInt ( BoardOrigin . X + TileSize . Width * ColumnIndex + TileSize . Width - 8 - FontManager . VoltorbFlipFont . MeasureString ( CoinSumString ) . X ) , BoardOrigin . Y + TileSize . Height * GridSize + 8 ) , mainBackgroundColor )
2023-05-24 11:49:18 +02:00
Next
'Voltorbs
For ColumnIndex = 0 To GridSize - 1
Dim VoltorbSumString As String = " 0 "
2023-05-27 15:40:38 +02:00
If GameState = States . Game Or GameState = States . Memo Or GameState = States . QuitQuestion Then
2023-05-24 11:49:18 +02:00
VoltorbSumString = VoltorbSums ( 1 ) ( ColumnIndex ) . ToString
End If
2023-05-27 15:09:41 +02:00
SpriteBatch . DrawString ( FontManager . VoltorbFlipFont , VoltorbSumString , New Vector2 ( CInt ( BoardOrigin . X + TileSize . Width * ColumnIndex + TileSize . Width - 8 - FontManager . VoltorbFlipFont . MeasureString ( VoltorbSumString ) . X ) , BoardOrigin . Y + TileSize . Height * GridSize + 34 ) , mainBackgroundColor )
2023-05-24 11:49:18 +02:00
Next
End Sub
2023-05-23 14:14:15 +02:00
Private Sub DrawMemoMenuAndButton ( )
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
2023-05-25 18:37:37 +02:00
Dim Fontcolor As Color = New Color ( 0 , 0 , 0 )
If GameState = States . Closing Or GameState = States . Opening Then
Fontcolor = New Color ( 0 , 0 , 0 , CInt ( 255 * _interfaceFade ) )
End If
2023-05-23 14:14:15 +02:00
'Draw Button
2023-05-27 15:09:41 +02:00
Dim ButtonOriginX As Integer = CInt ( BoardOrigin . X + BoardSize . Width + TileSize . Width / 4 )
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Button " , New Rectangle ( 0 , 0 , 56 , 56 ) ) , New Rectangle ( ButtonOriginX , CInt ( BoardOrigin . Y ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
2023-05-27 16:52:36 +02:00
Dim ButtonTextTop As String = Localization . GetString ( " VoltorbFlip_MemoButton_Open_Line1 " , " Open " )
Dim ButtonTextBottom As String = Localization . GetString ( " VoltorbFlip_MemoButton_Open_Line2 " , " Memos " )
2023-05-23 14:14:15 +02:00
If GameState = States . Memo Then
2023-05-27 16:52:36 +02:00
ButtonTextTop = Localization . GetString ( " VoltorbFlip_MemoButton_Close_Line1 " , " Close " )
ButtonTextBottom = Localization . GetString ( " VoltorbFlip_MemoButton_Close_Line2 " , " Memos " )
2023-05-23 14:14:15 +02:00
End If
2023-05-27 15:09:41 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , ButtonTextTop , New Vector2 ( CInt ( ButtonOriginX + MemoMenuSize . Width / 2 - FontManager . MainFont . MeasureString ( ButtonTextTop ) . X / 2 ) , CInt ( BoardOrigin . Y + 40 ) ) , Fontcolor )
SpriteBatch . DrawString ( FontManager . MainFont , ButtonTextBottom , New Vector2 ( CInt ( ButtonOriginX + MemoMenuSize . Width / 2 - FontManager . MainFont . MeasureString ( ButtonTextBottom ) . X / 2 ) , CInt ( BoardOrigin . Y + 40 + FontManager . MainFont . MeasureString ( ButtonTextTop ) . Y ) ) , Fontcolor )
2023-05-23 14:14:15 +02:00
'Draw Memo Menu
2023-05-27 15:09:41 +02:00
If MemoMenuX > 0 Then
Dim CurrentTile As Tile = Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) )
2023-05-23 14:14:15 +02:00
'Draw Background
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Background " , New Rectangle ( 0 , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
If GameState = States . Memo Then
'Draw lit up Memos in the Memo menu when it's enabled on a tile
If CurrentTile . GetMemo ( 0 ) = True Then 'Voltorb
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Enabled " , New Rectangle ( 0 , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
End If
If CurrentTile . GetMemo ( 1 ) = True Then 'x1
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Enabled " , New Rectangle ( 56 , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
End If
If CurrentTile . GetMemo ( 2 ) = True Then 'x2
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Enabled " , New Rectangle ( 56 + 56 , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
End If
If CurrentTile . GetMemo ( 3 ) = True Then 'x3
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Enabled " , New Rectangle ( 56 + 56 + 56 , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
End If
'Draw indicator of currently selected Memo
2023-05-27 15:09:41 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Memo_Index " , New Rectangle ( 56 * MemoIndex , 0 , 56 , 56 ) ) , New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height ) , mainBackgroundColor )
2023-05-23 14:14:15 +02:00
End If
End If
End Sub
Private Sub DrawCursor ( )
If GameState = States . Game OrElse GameState = States . Memo Then
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If GameState = States . Closing Or GameState = States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
Dim CursorImage As Texture2D = TextureManager . GetTexture ( " Textures\VoltorbFlip\Cursor_Game " )
If GameState = States . Memo Then
CursorImage = TextureManager . GetTexture ( " Textures\VoltorbFlip\Cursor_Memo " )
End If
SpriteBatch . Draw ( CursorImage , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + BoardCursorPosition . X ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + BoardCursorPosition . Y ) , TileSize . Width , TileSize . Height ) , mainBackgroundColor )
End If
End Sub
2023-05-25 18:37:37 +02:00
Private Sub DrawQuitButton ( )
2023-05-27 19:27:48 +02:00
Dim mainColor As Color = New Color ( 255 , 255 , 255 )
2023-05-25 18:37:37 +02:00
If GameState = States . Closing Or GameState = States . Opening Then
2023-05-27 19:27:48 +02:00
mainColor = New Color ( 255 , 255 , 255 , CInt ( 255 * _interfaceFade ) )
End If
Dim ShadowColor As Color = New Color ( 0 , 0 , 0 )
If GameState = States . Closing Or GameState = States . Opening Then
ShadowColor = New Color ( 0 , 0 , 0 , CInt ( 255 * _interfaceFade ) )
2023-05-25 18:37:37 +02:00
End If
2023-05-27 19:27:48 +02:00
2023-05-25 18:37:37 +02:00
Dim QuitButtonRectangle As New Rectangle ( CInt ( GameOrigin . X + 424 ) , CInt ( GameOrigin . Y + 448 ) , 128 , 56 )
2023-05-27 19:27:48 +02:00
SpriteBatch . Draw ( TextureManager . GetTexture ( " Textures\VoltorbFlip\Quit_Button " ) , QuitButtonRectangle , mainColor )
Dim QuitButtonText As String = Localization . GetString ( " VoltorbFlip_QuitButton " , " Quit " )
SpriteBatch . DrawString ( FontManager . MainFont , QuitButtonText , New Vector2 ( CInt ( QuitButtonRectangle . X + QuitButtonRectangle . Width / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . X / 2 ) , CInt ( QuitButtonRectangle . Y + QuitButtonRectangle . Height / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . Y / 2 ) ) , ShadowColor )
2023-05-28 09:54:20 +02:00
SpriteBatch . DrawString ( FontManager . MainFont , QuitButtonText , New Vector2 ( CInt ( QuitButtonRectangle . X + QuitButtonRectangle . Width / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . X / 2 - 2 ) , CInt ( QuitButtonRectangle . Y + QuitButtonRectangle . Height / 2 - FontManager . MainFont . MeasureString ( QuitButtonText ) . Y / 2 - 2 ) ) , mainColor )
2023-05-27 19:27:48 +02:00
2023-05-25 18:37:37 +02:00
End Sub
2023-05-23 14:14:15 +02:00
Private Function CreateBoard ( ByVal Level As Integer ) As List ( Of List ( Of Tile ) )
2023-05-18 20:25:38 +02:00
Dim Board As List ( Of List ( Of Tile ) ) = CreateGrid ( )
Dim Data As List ( Of Integer ) = GetLevelData ( Level )
Dim Spots As List ( Of List ( Of Integer ) ) = New List ( Of List ( Of Integer ) )
2023-05-27 15:09:41 +02:00
For i = 0 To Data ( 0 ) + Data ( 1 ) + Data ( 2 ) - 1
2023-05-18 20:25:38 +02:00
If Spots . Count > 0 Then
2023-05-27 15:09:41 +02:00
Dim ValueX As Integer = Random . Next ( 0 , 5 )
Dim ValueY As Integer = Random . Next ( 0 , 5 )
TryAgain :
Dim IsUnique As Boolean = True
For SpotIndex = 0 To Spots . Count - 1
If Spots ( SpotIndex ) ( 0 ) = ValueX AndAlso Spots ( SpotIndex ) ( 1 ) = ValueY Then
IsUnique = False
Exit For
End If
Next
If IsUnique = False Then
ValueX = Random . Next ( 0 , 5 )
ValueY = Random . Next ( 0 , 5 )
GoTo TryAgain
Else
Spots . Add ( New List ( Of Integer ) ( { ValueX , ValueY } . ToList ) )
End If
2023-05-18 20:25:38 +02:00
Else
2023-05-27 15:09:41 +02:00
Spots . Add ( New List ( Of Integer ) ( { Random . Next ( 0 , 5 ) , Random . Next ( 0 , 5 ) } . ToList ) )
2023-05-18 20:25:38 +02:00
End If
Next
2023-05-27 15:09:41 +02:00
If Data ( 0 ) > 0 Then
For a = 0 To Data ( 0 ) - 1
Dim TileX As Integer = Spots ( a ) ( 0 )
Dim TileY As Integer = Spots ( a ) ( 1 )
Board ( TileY ) ( TileX ) . Value = Tile . Values . Two
Next
End If
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
If Data ( 1 ) > 0 Then
For b = 0 To Data ( 1 ) - 1
Dim TileX As Integer = Spots ( b + Data ( 0 ) ) ( 0 )
Dim TileY As Integer = Spots ( b + Data ( 0 ) ) ( 1 )
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
Board ( TileY ) ( TileX ) . Value = Tile . Values . Three
Next
End If
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
If Data ( 2 ) > 0 Then
For c = 0 To Data ( 2 ) - 1
Dim TileX As Integer = Spots ( c + Data ( 0 ) + Data ( 1 ) ) ( 0 )
Dim TileY As Integer = Spots ( c + Data ( 0 ) + Data ( 1 ) ) ( 1 )
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
Board ( TileY ) ( TileX ) . Value = Tile . Values . Voltorb
Next
End If
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
If Data ( 0 ) > 0 AndAlso Data ( 1 ) > 0 Then
MaxCoins = CInt ( Math . Pow ( 2 , Data ( 0 ) ) * Math . Pow ( 3 , Data ( 1 ) ) )
End If
If Data ( 0 ) > 0 AndAlso Data ( 1 ) = 0 Then
MaxCoins = CInt ( Math . Pow ( 2 , Data ( 0 ) ) )
End If
If Data ( 0 ) = 0 AndAlso Data ( 1 ) > 0 Then
MaxCoins = CInt ( Math . Pow ( 3 , Data ( 1 ) ) )
End If
2023-05-18 20:25:38 +02:00
2023-05-21 20:40:12 +02:00
VoltorbSums = GenerateSums ( Board , True )
CoinSums = GenerateSums ( Board , False )
2023-05-18 20:25:38 +02:00
Return Board
End Function
2023-05-22 19:33:09 +02:00
''' <summary>
''' Returns an empty grid of Tiles
''' </summary>
''' <returns></returns>
2023-05-18 20:25:38 +02:00
Private Function CreateGrid ( ) As List ( Of List ( Of Tile ) )
Dim Grid As New List ( Of List ( Of Tile ) )
2023-05-25 18:37:37 +02:00
For _row = 0 To VoltorbFlipScreen . GridSize - 1
2023-05-18 20:25:38 +02:00
Dim Column As New List ( Of Tile )
2023-05-25 18:37:37 +02:00
For _column = 0 To VoltorbFlipScreen . GridSize - 1
2023-05-18 20:25:38 +02:00
Column . Add ( New VoltorbFlip . Tile ( _row , _column , VoltorbFlip . Tile . Values . One , False ) )
Next
Grid . Add ( Column )
Next
Return Grid
End Function
2023-05-21 20:40:12 +02:00
''' <summary>
2023-05-22 19:33:09 +02:00
''' Returns amount of either Coins or Voltorbs in each row and column of a grid of Tiles
2023-05-21 20:40:12 +02:00
''' </summary>
''' <param name="Board"></param> A grid of Tiles
''' <param name="CoinsOrVoltorbs"></param> True returns amount of Voltorbs, False returns amount of Coins
''' <returns></returns>
Private Function GenerateSums ( ByVal Board As List ( Of List ( Of Tile ) ) , ByVal CoinsOrVoltorbs As Boolean ) As List ( Of List ( Of Integer ) )
Dim RowSums As New List ( Of Integer )
Dim ColumnSums As New List ( Of Integer )
Dim RowBombs As New List ( Of Integer )
Dim ColumnBombs As New List ( Of Integer )
2023-05-25 18:37:37 +02:00
RowSums . AddRange ( { 0 , 0 , 0 , 0 , 0 } . ToList )
ColumnSums . AddRange ( { 0 , 0 , 0 , 0 , 0 } . ToList )
RowBombs . AddRange ( { 0 , 0 , 0 , 0 , 0 } . ToList )
ColumnBombs . AddRange ( { 0 , 0 , 0 , 0 , 0 } . ToList )
'Rows
2023-05-21 20:40:12 +02:00
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
If Board ( _row ) ( _column ) . Value = Tile . Values . Voltorb Then
2023-05-25 18:37:37 +02:00
RowBombs ( _row ) += 1
2023-05-21 20:40:12 +02:00
Else
2023-05-25 18:37:37 +02:00
RowSums ( _row ) += Board ( _row ) ( _column ) . Value
2023-05-21 20:40:12 +02:00
End If
Next
Next
2023-05-25 18:37:37 +02:00
'Columns
2023-05-21 20:40:12 +02:00
For _column = 0 To GridSize - 1
For _row = 0 To GridSize - 1
If Board ( _row ) ( _column ) . Value = Tile . Values . Voltorb Then
2023-05-25 18:37:37 +02:00
ColumnBombs ( _column ) += 1
2023-05-21 20:40:12 +02:00
Else
2023-05-25 18:37:37 +02:00
ColumnSums ( _column ) += Board ( _row ) ( _column ) . Value
2023-05-21 20:40:12 +02:00
End If
Next
Next
If CoinsOrVoltorbs = False Then
Dim Sums As New List ( Of List ( Of Integer ) )
Sums . AddRange ( { RowSums , ColumnSums } )
Return Sums
Else
Dim Voltorbs As New List ( Of List ( Of Integer ) )
Voltorbs . AddRange ( { RowBombs , ColumnBombs } )
Return Voltorbs
End If
End Function
2023-05-25 18:37:37 +02:00
Public Function GetCursorOffset ( Optional ByVal Column As Integer = 0 , Optional ByVal Row As Integer = 0 ) As Vector2
Return New Vector2 ( TileSize . Width * Column , TileSize . Height * Row )
2023-05-19 17:02:59 +02:00
End Function
2023-05-22 19:33:09 +02:00
''' <summary>
''' Get the tile that the cursor is on
''' </summary>
''' <returns></returns>
2023-05-19 17:02:59 +02:00
Public Function GetCurrentTile ( ) As Vector2
2023-05-25 18:37:37 +02:00
Return New Vector2 ( ( BoardCursorDestination . X / TileSize . Width ) . Clamp ( 0 , GridSize - 1 ) , ( BoardCursorDestination . Y / TileSize . Height ) . Clamp ( 0 , GridSize - 1 ) )
2023-05-22 19:33:09 +02:00
End Function
Public Function GetTileUnderMouse ( ) As Vector2
Dim AbsoluteMousePosition As Vector2 = MouseHandler . MousePosition . ToVector2
Dim RelativeMousePosition As Vector2 = New Vector2 ( Clamp ( AbsoluteMousePosition . X - BoardOrigin . X , 0 , BoardSize . Width ) , Clamp ( AbsoluteMousePosition . Y - BoardOrigin . Y , 0 , BoardSize . Height ) )
2023-05-25 18:37:37 +02:00
Return New Vector2 ( CInt ( Math . Floor ( RelativeMousePosition . X / TileSize . Width ) . Clamp ( 0 , GridSize - 1 ) ) , CInt ( Math . Floor ( RelativeMousePosition . Y / TileSize . Height ) . Clamp ( 0 , GridSize - 1 ) ) )
2023-05-19 17:02:59 +02:00
End Function
2023-05-21 20:40:12 +02:00
2023-05-18 20:25:38 +02:00
Public Function GetLevelData ( ByVal LevelNumber As Integer ) As List ( Of Integer )
Select Case LevelNumber
Case 1
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
2023-05-22 19:33:09 +02:00
Return { 3 , 1 , 6 } . ToList
2023-05-18 20:25:38 +02:00
Case 1
2023-05-22 19:33:09 +02:00
Return { 0 , 3 , 6 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
2023-05-22 19:33:09 +02:00
Return { 5 , 0 , 6 } . ToList
2023-05-18 20:25:38 +02:00
Case 3
Return { 2 , 2 , 6 } . ToList
Case 4
2023-05-22 19:33:09 +02:00
Return { 4 , 1 , 6 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 2
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
2023-05-22 19:33:09 +02:00
Return { 1 , 3 , 7 } . ToList
2023-05-18 20:25:38 +02:00
Case 1
2023-05-22 19:33:09 +02:00
Return { 6 , 0 , 7 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
Return { 3 , 2 , 7 } . ToList
Case 3
Return { 0 , 4 , 7 } . ToList
2023-05-22 19:33:09 +02:00
Case 4
Return { 5 , 1 , 7 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 3
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
2023-05-22 19:33:09 +02:00
Return { 2 , 3 , 8 } . ToList
2023-05-18 20:25:38 +02:00
Case 1
2023-05-22 19:33:09 +02:00
Return { 7 , 0 , 8 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
Return { 4 , 2 , 8 } . ToList
Case 3
Return { 1 , 4 , 8 } . ToList
2023-05-22 19:33:09 +02:00
Case 4
Return { 6 , 1 , 8 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 4
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
2023-05-22 19:33:09 +02:00
Return { 3 , 3 , 8 } . ToList
2023-05-18 20:25:38 +02:00
Case 1
2023-05-22 19:33:09 +02:00
Return { 0 , 5 , 8 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
2023-05-22 19:33:09 +02:00
Return { 8 , 0 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 3
2023-05-22 19:33:09 +02:00
Return { 5 , 2 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 4
2023-05-22 19:33:09 +02:00
Return { 2 , 4 , 10 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 5
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
Return { 7 , 1 , 10 } . ToList
2023-05-22 19:33:09 +02:00
Case 1
Return { 4 , 3 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
2023-05-22 19:33:09 +02:00
Return { 1 , 5 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 3
2023-05-22 19:33:09 +02:00
Return { 9 , 0 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 4
2023-05-22 19:33:09 +02:00
Return { 6 , 2 , 10 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 6
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
2023-05-22 19:33:09 +02:00
Return { 3 , 4 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 1
2023-05-22 19:33:09 +02:00
Return { 0 , 6 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
2023-05-22 19:33:09 +02:00
Return { 8 , 1 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 3
2023-05-22 19:33:09 +02:00
Return { 5 , 3 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 4
2023-05-22 19:33:09 +02:00
Return { 2 , 5 , 10 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case 7
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
Return { 7 , 2 , 10 } . ToList
2023-05-22 19:33:09 +02:00
Case 1
Return { 4 , 4 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 2
2023-05-22 19:33:09 +02:00
Return { 1 , 6 , 13 } . ToList
Case 3
Return { 9 , 1 , 13 } . ToList
Case 4
2023-05-18 20:25:38 +02:00
Return { 6 , 3 , 10 } . ToList
2023-05-22 19:33:09 +02:00
End Select
Case 8
Dim chance As Integer = CInt ( Random . Next ( 0 , 5 ) )
Select Case chance
Case 0
Return { 0 , 7 , 10 } . ToList
Case 1
Return { 8 , 2 , 10 } . ToList
Case 2
Return { 5 , 4 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 3
2023-05-22 19:33:09 +02:00
Return { 2 , 6 , 10 } . ToList
2023-05-18 20:25:38 +02:00
Case 4
2023-05-22 19:33:09 +02:00
Return { 7 , 3 , 10 } . ToList
2023-05-18 20:25:38 +02:00
End Select
Case Else
Return Nothing
End Select
Return Nothing
End Function
Protected Overrides Function GetFontRenderer ( ) As SpriteBatch
2023-05-24 14:30:38 +02:00
If IsCurrentScreen ( ) AndAlso _interfaceFade + 0 . 01F >= 1 . 0F Then
2023-05-18 20:25:38 +02:00
Return FontRenderer
Else
Return SpriteBatch
End If
End Function
2023-05-19 17:02:59 +02:00
Public Overrides Sub SizeChanged ( )
2023-05-27 15:44:01 +02:00
GameOrigin = New Vector2 ( CInt ( windowSize . Width / 2 - GameSize . Width / 2 - 32 ) , CInt ( windowSize . Height / 2 - _screenTransitionY ) )
2023-05-27 15:09:41 +02:00
BoardOrigin = New Vector2 ( GameOrigin . X + 32 , GameOrigin . Y + 160 )
2023-05-28 21:34:20 +02:00
TutorialRectangle = New Rectangle ( CInt ( windowSize . Width / 2 - 512 / 2 ) , CInt ( windowSize . Height / 2 - 384 / 2 ) , 512 , 384 )
2023-05-22 19:33:09 +02:00
BoardCursorDestination = GetCursorOffset ( 0 , 0 )
BoardCursorPosition = GetCursorOffset ( 0 , 0 )
End Sub
Public Sub UpdateTiles ( )
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Dim _tile As Tile = Board ( _row ) ( _column )
_tile . Update ( )
Next
Next
2023-05-19 17:02:59 +02:00
End Sub
2023-05-18 20:25:38 +02:00
Public Overrides Sub Update ( )
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
ChooseBox . Update ( )
2023-05-27 15:09:41 +02:00
If ChooseBox . Showing = False Then
TextBox . Update ( )
End If
2023-05-18 20:25:38 +02:00
2023-05-27 15:09:41 +02:00
If ChooseBox . Showing = False AndAlso TextBox . Showing = False Then
If Delay > 0 Then
Delay -= 1
If Delay <= 0 Then
Delay = 0
End If
2023-05-19 17:02:59 +02:00
End If
2023-05-25 18:37:37 +02:00
End If
2023-05-19 17:02:59 +02:00
2023-05-25 18:37:37 +02:00
If Board IsNot Nothing Then
UpdateTiles ( )
End If
If Delay = 0 Then
If ChooseBox . Showing = False AndAlso TextBox . Showing = False Then
If GameState = States . Game Or GameState = States . Memo Then
'Moving the cursor between Tiles on the board
If Controls . Up ( True , True , False ) Then
If BoardCursorDestination . Y > GetCursorOffset ( Nothing , 0 ) . Y Then
BoardCursorDestination . Y -= GetCursorOffset ( Nothing , 1 ) . Y
Else
BoardCursorDestination . Y = GetCursorOffset ( Nothing , 4 ) . Y
End If
End If
2023-05-19 17:02:59 +02:00
2023-05-25 18:37:37 +02:00
If Controls . Down ( True , True , False ) = True Then
If BoardCursorDestination . Y < GetCursorOffset ( Nothing , 4 ) . Y Then
BoardCursorDestination . Y += GetCursorOffset ( Nothing , 1 ) . Y
Else
BoardCursorDestination . Y = GetCursorOffset ( Nothing , 0 ) . Y
End If
End If
If Controls . Left ( True , True , False ) = True Then
If BoardCursorDestination . X > GetCursorOffset ( 0 , Nothing ) . X Then
BoardCursorDestination . X -= GetCursorOffset ( 1 , Nothing ) . X
Else
BoardCursorDestination . X = GetCursorOffset ( 4 , Nothing ) . X
End If
End If
If Controls . Right ( True , True , False ) = True Then
If BoardCursorDestination . X < GetCursorOffset ( 4 , Nothing ) . X Then
BoardCursorDestination . X += GetCursorOffset ( 1 , Nothing ) . X
Else
BoardCursorDestination . X = GetCursorOffset ( 0 , Nothing ) . X
End If
End If
'Animation of Cursor
BoardCursorPosition . X = MathHelper . Lerp ( BoardCursorPosition . X , BoardCursorDestination . X , 0 . 6F )
BoardCursorPosition . Y = MathHelper . Lerp ( BoardCursorPosition . Y , BoardCursorDestination . Y , 0 . 6F )
2023-05-19 17:02:59 +02:00
Else
2023-05-25 18:37:37 +02:00
'Reset cursor position between levels
BoardCursorDestination = GetCursorOffset ( 0 , 0 )
BoardCursorPosition = GetCursorOffset ( 0 , 0 )
2023-05-19 17:02:59 +02:00
End If
2023-05-25 18:37:37 +02:00
'Switching between Game and Memo GameStates (Keys & GamePad)
2023-05-27 15:09:41 +02:00
If KeyBoardHandler . KeyPressed ( KeyBindings . RunKey ) Or ControllerHandler . ButtonPressed ( Buttons . X ) Then
2023-05-25 18:37:37 +02:00
If GameState = States . Game Then
GameState = States . Memo
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
ElseIf GameState = States . Memo Then
GameState = States . Game
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Switching between Game and Memo GameStates (Mouse)
2023-05-27 15:09:41 +02:00
Dim ButtonRectangle As Rectangle = New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width + TileSize . Width / 4 ) , CInt ( BoardOrigin . Y ) , MemoMenuSize . Width , MemoMenuSize . Height )
If Controls . Accept ( True , False , False ) = True AndAlso MouseHandler . IsInRectangle ( ButtonRectangle ) AndAlso Delay = 0 Then
2023-05-25 18:37:37 +02:00
If GameState = States . Game Then
GameState = States . Memo
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
ElseIf GameState = States . Memo Then
GameState = States . Game
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-19 17:02:59 +02:00
2023-05-25 18:37:37 +02:00
If GameState = States . Memo Then
'Animate opening the Memo window
2023-05-27 15:09:41 +02:00
If MemoMenuX < MemoMenuSize . Width + TileSize . Width / 4 Then
MemoMenuX = MathHelper . Lerp ( CSng ( MemoMenuSize . Width + TileSize . Width / 4 ) , MemoMenuX , 0 . 9F )
If MemoMenuX >= MemoMenuSize . Width + TileSize . Width / 4 Then
MemoMenuX = CInt ( MemoMenuSize . Width + TileSize . Width / 4 )
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-19 17:02:59 +02:00
2023-05-25 18:37:37 +02:00
'Cycling through the 4 Memo types (Voltorb, One, Two, Three)
If Controls . Left ( True , False , True , False , False , False ) = True OrElse ControllerHandler . ButtonPressed ( Buttons . LeftShoulder ) Then
MemoIndex -= 1
If MemoIndex < 0 Then
MemoIndex = 3
End If
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
If Controls . Right ( True , False , True , False , False , False ) = True OrElse ControllerHandler . ButtonPressed ( Buttons . RightShoulder ) Then
MemoIndex += 1
If MemoIndex > 3 Then
MemoIndex = 0
End If
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
2023-05-23 14:14:15 +02:00
2023-05-25 18:37:37 +02:00
'Set the Memo type to the one under the mouse
2023-05-27 15:09:41 +02:00
Dim MemoMenuRectangle As New Rectangle ( CInt ( BoardOrigin . X + BoardSize . Width - MemoMenuSize . Width + MemoMenuX ) , CInt ( BoardOrigin . Y + MemoMenuSize . Height + TileSize . Height / 2 ) , MemoMenuSize . Width , MemoMenuSize . Height )
2023-05-25 18:37:37 +02:00
If Controls . Accept ( True , False , False ) = True Then
2023-05-27 15:09:41 +02:00
If MouseHandler . IsInRectangle ( New Rectangle ( MemoMenuRectangle . X , MemoMenuRectangle . Y , CInt ( MemoMenuRectangle . Width / 2 ) , CInt ( MemoMenuRectangle . Height / 2 ) ) ) = True Then
2023-05-25 18:37:37 +02:00
'Voltorb
MemoIndex = 0
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
2023-05-27 15:09:41 +02:00
If MouseHandler . IsInRectangle ( New Rectangle ( MemoMenuRectangle . X + CInt ( MemoMenuRectangle . Width / 2 ) , MemoMenuRectangle . Y , CInt ( MemoMenuRectangle . Width / 2 ) , CInt ( MemoMenuRectangle . Height / 2 ) ) ) = True Then
2023-05-25 18:37:37 +02:00
'One
MemoIndex = 1
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
2023-05-27 15:09:41 +02:00
If MouseHandler . IsInRectangle ( New Rectangle ( MemoMenuRectangle . X , MemoMenuRectangle . Y + CInt ( MemoMenuRectangle . Height / 2 ) , CInt ( MemoMenuRectangle . Width / 2 ) , CInt ( MemoMenuRectangle . Height / 2 ) ) ) = True Then
2023-05-25 18:37:37 +02:00
'Two
MemoIndex = 2
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
2023-05-27 15:09:41 +02:00
If MouseHandler . IsInRectangle ( New Rectangle ( MemoMenuRectangle . X + CInt ( MemoMenuRectangle . Width / 2 ) , MemoMenuRectangle . Y + CInt ( MemoMenuRectangle . Height / 2 ) , CInt ( MemoMenuRectangle . Width / 2 ) , CInt ( MemoMenuRectangle . Height / 2 ) ) ) = True Then
2023-05-25 18:37:37 +02:00
'Three
MemoIndex = 3
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
End If
End If
Else
'Animate Closing the Memo window
2023-05-27 15:09:41 +02:00
If MemoMenuX > 0F Then
MemoMenuX = MathHelper . Lerp ( 0F , MemoMenuX , 0 . 9F )
If MemoMenuX <= 0F Then
MemoMenuX = 0F
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-22 19:33:09 +02:00
End If
2023-05-19 17:02:59 +02:00
2023-05-27 19:27:48 +02:00
Dim QuitQuestionText As String = Localization . GetString ( " VoltorbFlip_QuitQuestion_Question_1 " , " If you quit now, you will~receive " ) & " " & CurrentCoins . ToString & " " & Localization . GetString ( " VoltorbFlip_QuitQuestion_Question_2 " , " Coin(s).*Will you quit? " ) & " % " & Localization . GetString ( " VoltorbFlip_QuitQuestion_AnswerYes " , " Yes " ) & " | " & Localization . GetString ( " VoltorbFlip_QuitQuestion_AnswerNo " , " No " ) & " % "
2023-05-27 15:09:41 +02:00
2023-05-25 18:37:37 +02:00
'Quiting Voltorb Flip
2023-05-27 15:09:41 +02:00
If Controls . Dismiss ( False , True , True ) AndAlso GameState = States . Game AndAlso Delay = 0 Then
TextBox . Show ( QuitQuestionText )
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
GameState = States . QuitQuestion
2023-05-19 17:02:59 +02:00
End If
2023-05-25 18:37:37 +02:00
'Quiting Voltorb Flip using the mouse
Dim QuitButtonRectangle As New Rectangle ( CInt ( GameOrigin . X + 424 ) , CInt ( GameOrigin . Y + 448 ) , 128 , 56 )
2023-05-27 15:09:41 +02:00
If Controls . Accept ( True , False , False ) AndAlso MouseHandler . IsInRectangle ( QuitButtonRectangle ) AndAlso GameState = States . Game AndAlso Delay = 0 Then
TextBox . Show ( QuitQuestionText )
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " select " )
2023-05-25 18:37:37 +02:00
GameState = States . QuitQuestion
2023-05-22 19:33:09 +02:00
End If
2023-05-27 15:09:41 +02:00
If GameState = States . QuitQuestion Then
2023-05-25 18:37:37 +02:00
If ChooseBox . readyForResult = True Then
If ChooseBox . result = 0 Then
Quit ( )
2023-05-28 18:52:51 +02:00
ChooseBox . readyForResult = False
2023-05-25 18:37:37 +02:00
Else
2023-05-27 15:09:41 +02:00
Delay = 15
2023-05-25 18:37:37 +02:00
GameState = States . Game
2023-05-28 18:52:51 +02:00
ChooseBox . readyForResult = False
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-22 19:33:09 +02:00
End If
2023-05-25 18:37:37 +02:00
'Flip currently selected Tile
2023-05-27 15:09:41 +02:00
If Controls . Accept ( False , True , True ) AndAlso GameState = States . Game AndAlso Delay = 0 Then
2023-05-25 18:37:37 +02:00
Dim CurrentTile As Vector2 = GetCurrentTile ( )
2023-05-27 15:40:38 +02:00
If Board ( CInt ( CurrentTile . Y ) ) ( CInt ( CurrentTile . X ) ) . Flipped = False Then
SoundManager . PlaySound ( " select " )
End If
2023-05-25 18:37:37 +02:00
Board ( CInt ( CurrentTile . Y ) ) ( CInt ( CurrentTile . X ) ) . Flip ( )
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Flip the Tile that the mouse is on
2023-05-27 15:09:41 +02:00
If Controls . Accept ( True , False , False ) AndAlso GameState = States . Game AndAlso MouseHandler . IsInRectangle ( New Rectangle ( CInt ( BoardOrigin . X ) , CInt ( BoardOrigin . Y ) , BoardSize . Width , BoardSize . Height ) ) AndAlso Delay = 0 Then
2023-05-25 18:37:37 +02:00
Dim TileUnderMouse As Vector2 = GetTileUnderMouse ( )
BoardCursorDestination = GetCursorOffset ( CInt ( TileUnderMouse . X ) , CInt ( TileUnderMouse . Y ) )
2023-05-27 15:40:38 +02:00
If Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . Flipped = False Then
SoundManager . PlaySound ( " select " )
End If
2023-05-25 18:37:37 +02:00
Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . Flip ( )
2023-05-27 15:40:38 +02:00
2023-05-25 18:37:37 +02:00
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Adding currently selected Memo to currently selected Tile
2023-05-27 15:09:41 +02:00
If Controls . Accept ( False , True , True ) AndAlso GameState = States . Memo AndAlso Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . Flipped = False AndAlso Delay = 0 Then
2023-05-27 15:40:38 +02:00
If Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . GetMemo ( MemoIndex ) = False Then
SoundManager . PlaySound ( " select " )
End If
2023-05-25 18:37:37 +02:00
Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . SetMemo ( MemoIndex , True )
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Adding currently selected Memo to Tile that the mouse is on
2023-05-27 15:14:35 +02:00
If Controls . Accept ( True , False , False ) AndAlso GameState = States . Memo AndAlso MouseHandler . IsInRectangle ( New Rectangle ( CInt ( BoardOrigin . X ) , CInt ( BoardOrigin . Y ) , BoardSize . Width , BoardSize . Height ) ) AndAlso Delay = 0 Then
2023-05-25 18:37:37 +02:00
Dim TileUnderMouse As Vector2 = GetTileUnderMouse ( )
BoardCursorDestination = GetCursorOffset ( CInt ( TileUnderMouse . X ) , CInt ( TileUnderMouse . Y ) )
2023-05-27 15:40:38 +02:00
If Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . Flipped = False Then
If Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . GetMemo ( MemoIndex ) = False Then
SoundManager . PlaySound ( " select " )
End If
2023-05-27 15:14:35 +02:00
Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . SetMemo ( MemoIndex , True )
End If
2023-05-25 18:37:37 +02:00
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Removing currently selected Memo from currently selected Tile
2023-05-27 15:09:41 +02:00
If Controls . Dismiss ( False , True , True ) AndAlso GameState = States . Memo AndAlso Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . Flipped = False AndAlso Delay = 0 Then
2023-05-27 15:40:38 +02:00
If Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . GetMemo ( MemoIndex ) = True Then
SoundManager . PlaySound ( " select " )
End If
2023-05-25 18:37:37 +02:00
Board ( CInt ( GetCurrentTile . Y ) ) ( CInt ( GetCurrentTile . X ) ) . SetMemo ( MemoIndex , False )
End If
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
'Removing currently selected Memo from Tile that the mouse is on
2023-05-27 15:14:35 +02:00
If Controls . Dismiss ( True , False , False ) AndAlso GameState = States . Memo AndAlso MouseHandler . IsInRectangle ( New Rectangle ( CInt ( BoardOrigin . X ) , CInt ( BoardOrigin . Y ) , BoardSize . Width , BoardSize . Height ) ) AndAlso Delay = 0 Then
2023-05-25 18:37:37 +02:00
Dim TileUnderMouse As Vector2 = GetTileUnderMouse ( )
BoardCursorDestination = GetCursorOffset ( CInt ( TileUnderMouse . X ) , CInt ( TileUnderMouse . Y ) )
2023-05-27 15:40:38 +02:00
If Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . Flipped = False Then
If Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . GetMemo ( MemoIndex ) = True Then
SoundManager . PlaySound ( " select " )
End If
2023-05-27 15:14:35 +02:00
Board ( CInt ( TileUnderMouse . Y ) ) ( CInt ( TileUnderMouse . X ) ) . SetMemo ( MemoIndex , False )
End If
2023-05-25 18:37:37 +02:00
End If
End If
2023-05-22 19:33:09 +02:00
End If
2023-05-27 15:09:41 +02:00
'Level complete!
If CurrentCoins >= MaxCoins AndAlso GameState = States . Game Then
2023-05-30 03:32:31 +02:00
Dim GameClearText = Localization . GetString ( " VoltorbFlip_GameWon_1 " , " Game clear!~You've found all of the~hidden x2 and x3 cards.*<player.name> received~ " ) & CurrentCoins . ToString & " " & Localization . GetString ( " VoltorbFlip_GameWon_2 " , " Coin(s)! " )
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " VoltorbFlip\WinGame " )
2023-05-27 15:09:41 +02:00
TextBox . Show ( GameClearText )
If Delay = 0 Then
PreviousLevel = CurrentLevel
2023-05-23 15:11:22 +02:00
2023-05-27 16:23:21 +02:00
If CurrentFlips >= 8 Then
TotalFlips += 1
End If
2023-05-27 15:09:41 +02:00
CurrentFlips = 0
2023-05-27 16:10:30 +02:00
ConsecutiveWins += 1
2023-05-23 15:11:22 +02:00
2023-05-27 16:23:21 +02:00
If ConsecutiveWins = 5 AndAlso TotalFlips = 5 Then
2023-05-27 15:09:41 +02:00
CurrentLevel = MaxLevel + 1
Else
2023-05-27 16:23:21 +02:00
If CurrentLevel + 1 > MaxLevel Then
CurrentLevel = MaxLevel
Else
CurrentLevel += 1
2023-05-25 18:37:37 +02:00
End If
2023-05-27 15:09:41 +02:00
End If
2023-05-23 15:11:22 +02:00
2023-05-27 15:09:41 +02:00
GameState = States . GameWon
Delay = 5
End If
End If
2023-05-24 14:30:38 +02:00
2023-05-27 15:09:41 +02:00
'Completed the level
If GameState = States . GameWon Then
If Core . Player . Coins + TotalCoins > 50000 Then
TotalCoins = 50000 - Core . Player . Coins
CurrentCoins = 0
2023-05-27 19:27:48 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_MaxCoins " , " Your Coin Case can't fit~any more Coin(s)! " ) )
2023-05-27 15:09:41 +02:00
Quit ( )
Else
TotalCoins += CurrentCoins
CurrentCoins = 0
End If
2023-05-24 14:30:38 +02:00
2023-05-27 15:09:41 +02:00
'Flip all Tiles to reveal contents
Dim ReadyAmount As Integer = 0
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Board ( _row ) ( _column ) . Reveal ( )
If Board ( _row ) ( _column ) . FlipProgress = 0 Then
ReadyAmount += 1
2023-05-25 18:37:37 +02:00
End If
2023-05-22 19:33:09 +02:00
Next
2023-05-27 15:09:41 +02:00
Next
2023-05-30 09:59:03 +02:00
If Controls . Accept = True AndAlso ReadyAmount = CInt ( GridSize * GridSize ) AndAlso TextBox . Showing = False Then
SoundManager . PlaySound ( " select " )
If Delay = 0 Then
Delay = 5
End If
If Delay > 3 Then
If CurrentLevel > PreviousLevel Then
TextBox . Show ( Localization . GetString ( " VoltorbFlip_NewLevel_Higher1 " , " Advanced to Game Lv. " ) & " " & CurrentLevel & Localization . GetString ( " VoltorbFlip_NewLevel_Higher2 " , " ! " ) )
End If
2023-05-27 15:09:41 +02:00
GameState = States . FlipWon
2023-05-25 18:37:37 +02:00
End If
2023-05-24 14:30:38 +02:00
End If
2023-05-22 19:33:09 +02:00
End If
'Revealed a Voltorb
If GameState = States . GameLost Then
2023-05-27 15:09:41 +02:00
CurrentCoins = 0
2023-05-23 15:11:22 +02:00
2023-05-27 15:09:41 +02:00
'Flip all Tiles to reveal contents
Dim ReadyAmount As Integer = 0
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Board ( _row ) ( _column ) . Reveal ( )
If Board ( _row ) ( _column ) . FlipProgress = 0 Then
ReadyAmount += 1
2023-05-24 14:30:38 +02:00
End If
2023-05-22 19:33:09 +02:00
Next
2023-05-27 15:09:41 +02:00
Next
2023-05-22 19:33:09 +02:00
2023-05-30 09:59:03 +02:00
If Controls . Accept = True AndAlso ReadyAmount = CInt ( GridSize * GridSize ) AndAlso TextBox . Showing = False Then
PreviousLevel = CurrentLevel
If CurrentFlips < CurrentLevel Then
CurrentLevel = Math . Max ( 1 , CurrentFlips )
Else
CurrentLevel = 1
End If
SoundManager . PlaySound ( " select " )
If Delay = 0 Then
Delay = 5
End If
If Delay > 3 Then
If CurrentLevel < PreviousLevel Then
TextBox . Show ( Localization . GetString ( " VoltorbFlip_NewLevel_Lower1 " , " Dropped to Game Lv. " ) & " " & CurrentLevel & Localization . GetString ( " VoltorbFlip_NewLevel_Lower2 " , " ! " ) )
2023-05-27 15:09:41 +02:00
End If
GameState = States . FlipLost
2023-05-25 18:37:37 +02:00
End If
2023-05-27 15:40:38 +02:00
End If
2023-05-25 18:37:37 +02:00
End If
2023-05-24 11:49:18 +02:00
2023-05-25 18:37:37 +02:00
'Increase Level, reset Tiles
If GameState = States . FlipWon Then
Dim ReadyAmount As Integer = 0
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Board ( _row ) ( _column ) . Reset ( )
If Board ( _row ) ( _column ) . FlipProgress = 0 Then
ReadyAmount += 1
2023-05-24 11:49:18 +02:00
End If
2023-05-25 18:37:37 +02:00
Next
Next
2023-05-24 14:30:38 +02:00
If ReadyAmount = CInt ( GridSize * GridSize ) Then
2023-05-29 09:57:39 +02:00
GameState = States . NewLevelQuestion
2023-05-22 19:33:09 +02:00
End If
2023-05-19 17:02:59 +02:00
End If
2023-05-24 14:30:38 +02:00
'Drop Level, reset Tiles
2023-05-30 09:59:03 +02:00
If GameState = States . FlipLost AndAlso TextBox . Showing = False Then
2023-05-24 14:30:38 +02:00
Dim ReadyAmount As Integer = 0
2023-05-25 18:37:37 +02:00
For _row = 0 To GridSize - 1
For _column = 0 To GridSize - 1
Board ( _row ) ( _column ) . Reset ( )
If Board ( _row ) ( _column ) . FlipProgress = 0 Then
ReadyAmount += 1
End If
2023-05-22 19:33:09 +02:00
Next
2023-05-25 18:37:37 +02:00
Next
2023-05-22 19:33:09 +02:00
2023-05-25 18:37:37 +02:00
CurrentFlips = 0
2023-05-22 19:33:09 +02:00
2023-05-24 14:30:38 +02:00
If ReadyAmount = CInt ( GridSize * GridSize ) Then
2023-05-29 09:57:39 +02:00
GameState = States . NewLevelQuestion
2023-05-22 19:33:09 +02:00
End If
End If
2023-05-28 09:58:33 +02:00
'The menu that appears before starting a new level
If GameState = States . NewLevelQuestion Then
Select Case NewLevelMenuIndex
Case 0 'Main Menu
2023-05-28 21:34:20 +02:00
If Delay = 0 AndAlso TextBox . Showing = False AndAlso ChooseBox . Showing = False Then
TextBox . Show ( Localization . GetString ( " VoltorbFlip_BeforeNewLevel_Main_Question_1 " , " Play Voltorb Flip Lv. " ) & " " & CurrentLevel . ToString & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_Main_Question_2 " , " ? " ) & " % " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_Main_Answer_Play " , " Play " ) & " | " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_Main_Answer_GameInfo " , " Game Info " ) & " | " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_Main_Answer_Quit " , " Quit " ) & " % " )
2023-05-28 09:58:33 +02:00
Delay = 5
End If
If ChooseBox . readyForResult = True Then
Select Case ChooseBox . result
Case 0
GameState = States . NewLevel
2023-05-29 09:57:39 +02:00
ChooseBox . readyForResult = False
2023-05-28 09:58:33 +02:00
Case 1
NewLevelMenuIndex = 1
2023-05-29 09:57:39 +02:00
ChooseBox . readyForResult = False
2023-05-28 09:58:33 +02:00
Case 2
GameState = States . Closing
2023-05-29 09:57:39 +02:00
ChooseBox . readyForResult = False
2023-05-28 09:58:33 +02:00
End Select
End If
Case 1 'Info Menu
2023-05-28 21:34:20 +02:00
If Delay = 0 AndAlso TextBox . Showing = False AndAlso ChooseBox . Showing = False Then
2023-05-30 03:32:31 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_BeforeNewLevel_GameInfo_Question " , " Which set of info? " ) & " % " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_GameInfo_Answer_HowToPlay " , " How to Play " ) & " | " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_GameInfo_Answer_Hint " , " Hint! " ) & " | " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_GameInfo_Answer_AboutMemos " , " About Memos " ) & " | " & Localization . GetString ( " VoltorbFlip_BeforeNewLevel_GameInfo_Back " , " Back " ) & " % " )
2023-05-28 09:58:33 +02:00
Delay = 5
End If
If ChooseBox . readyForResult = True Then
Select Case ChooseBox . result
Case 0
NewLevelMenuIndex = 2
Case 1
NewLevelMenuIndex = 3
Case 2
NewLevelMenuIndex = 4
2023-05-30 03:32:31 +02:00
Case 3
NewLevelMenuIndex = 0
2023-05-28 09:58:33 +02:00
End Select
End If
Case 2 'How to Play
If Delay = 0 Then
2023-05-28 21:34:20 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_Tutorial_HowToPlay_Message " , " Voltorb Flip is a game in which~you flip over cards to find~numbers hidden beneath them.*The cards are hiding the~numbers 1 through 3...~and Voltorb as well.*The first number you flip over~will give you that many Coins.*From then on, the next number~you find will multiply the~total amount of Coins you've~collected by that number.*If it's a 2, your total will~be multiplied by "" x2 "" .*If it's a 3, your total will~be multiplied by "" x3 "" .*But if you flip over a~Voltorb, it's game over.*When that happens, you'll lose~all the Coins you've collected~in the current level.*If you select "" Quit "" , you'll~withdraw from the level.*If you get to a difficult~spot, you might want to end~the game early.*Once you've found all the~hidden 2 and 3 cards,~you've cleared the game.*Once you've flipped over~all these cards, then you'll~advance to the next level.*As you move up in levels,~you will be able to receive~more Coins. Do your best! " ) )
2023-05-28 09:58:33 +02:00
Delay = 5
End If
2023-05-29 09:57:39 +02:00
If TextBox . Showing = False AndAlso Delay > 3 Then
ChooseBox . readyForResult = False
NewLevelMenuIndex = 1
End If
2023-05-28 09:58:33 +02:00
Case 3 'Hint!
If Delay = 0 Then
2023-05-28 21:34:20 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_Tutorial_Hint_Message " , " The numbers at the side~of the board give you a clue~about the numbers hidden on~the backs of the cards.*The larger the number, the~more likely it is that there~are many large numbers hidden~in that row or column.*In the same way, you can tell~how many Voltorb are hidden~in the row or column.*Consider the hidden number~totals and the Voltorb~totals carefully as you~flip over cards. " ) )
2023-05-28 09:58:33 +02:00
Delay = 5
End If
2023-05-29 09:57:39 +02:00
If TextBox . Showing = False AndAlso Delay > 3 Then
ChooseBox . readyForResult = False
NewLevelMenuIndex = 1
End If
2023-05-28 09:58:33 +02:00
Case 4 'About Memos
If Delay = 0 Then
2023-05-29 09:57:39 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_Tutorial_AboutMemos_Message " , " Select "" Open Memo "" or press~[<system.button(run)>] to open the~Memo Window.*You can mark the cards with~the numbers 1 through 3,~but also with a Voltorb mark.*When you have an idea of the~numbers hidden on the back~of the cards, open the Memo~Window, choose the type of~mark you want to use with~the Mouse Wheel or the~Gamepad's Shoulder Buttons~and then press [<system.button(enter1)>]~while highlighting the card~you want to mark.*If you want to remove a mark,~choose the type of mark you~want to remove with the~Mouse Wheel or the Gamepad's~Shoulder Buttons and then~press [<system.button(back1)>] while~highlighting the card you~want to remove the mark from.*You can also use the~mouse to select a~mark type or a card. " ) )
2023-05-28 09:58:33 +02:00
Delay = 5
End If
2023-05-29 09:57:39 +02:00
If TextBox . Showing = False AndAlso Delay > 3 Then
ChooseBox . readyForResult = False
NewLevelMenuIndex = 1
End If
2023-05-28 09:58:33 +02:00
End Select
End If
2023-05-22 19:33:09 +02:00
'Prepare new Level
If GameState = States . NewLevel Then
2023-05-25 18:37:37 +02:00
If TextBox . Showing = False Then
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " VoltorbFlip\StartGame " )
2023-05-25 18:37:37 +02:00
Board = CreateBoard ( CurrentLevel )
2023-05-27 16:23:21 +02:00
If CurrentLevel = 8 Then
TotalFlips = 0
ConsecutiveWins = 0
End If
2023-05-22 19:33:09 +02:00
2023-05-30 09:59:03 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_NewLevel_Ready1 " , " Ready to play Game Lv. " ) & " " & CurrentLevel & Localization . GetString ( " VoltorbFlip_NewLevel_Ready2 " , " ! " ) )
2023-05-25 18:37:37 +02:00
Else
2023-05-27 15:09:41 +02:00
Delay = 15
2023-05-22 19:33:09 +02:00
GameState = States . Game
End If
End If
'Animation of opening/closing the window
2023-05-19 17:02:59 +02:00
If GameState = States . Closing Then
2023-05-27 19:27:48 +02:00
CurrentCoins = 0
2023-05-24 14:30:38 +02:00
2023-05-18 20:25:38 +02:00
If _interfaceFade > 0F Then
_interfaceFade = MathHelper . Lerp ( 0 , _interfaceFade , 0 . 8F )
If _interfaceFade < 0F Then
_interfaceFade = 0F
End If
End If
2023-05-22 19:33:09 +02:00
If _screenTransitionY > 0 Then
_screenTransitionY = MathHelper . Lerp ( 0 , _screenTransitionY , 0 . 8F )
If _screenTransitionY <= 0 Then
_screenTransitionY = 0
2023-05-18 20:25:38 +02:00
End If
End If
2023-05-25 18:37:37 +02:00
2023-05-27 15:09:41 +02:00
GameOrigin . Y = CInt ( windowSize . Height / 2 - _screenTransitionY )
BoardOrigin = New Vector2 ( GameOrigin . X + 32 , GameOrigin . Y + 160 )
2023-05-25 18:37:37 +02:00
2023-05-22 19:33:09 +02:00
If _screenTransitionY <= 2 . 0F Then
2023-05-18 20:25:38 +02:00
SetScreen ( PreScreen )
End If
Else
2023-05-22 19:33:09 +02:00
Dim maxWindowHeight As Integer = CInt ( GameSize . Height / 2 )
If _screenTransitionY < maxWindowHeight Then
_screenTransitionY = MathHelper . Lerp ( maxWindowHeight , _screenTransitionY , 0 . 8F )
2023-05-25 18:37:37 +02:00
If _screenTransitionY >= maxWindowHeight - 0 . 8 Then
If GameState = States . Opening Then
2023-05-29 09:57:39 +02:00
GameState = States . NewLevelQuestion
2023-05-25 18:37:37 +02:00
End If
2023-05-22 19:33:09 +02:00
_screenTransitionY = maxWindowHeight
2023-05-18 20:25:38 +02:00
End If
End If
2023-05-27 15:09:41 +02:00
GameOrigin . Y = CInt ( windowSize . Height / 2 - _screenTransitionY )
BoardOrigin = New Vector2 ( GameOrigin . X + 32 , GameOrigin . Y + 160 )
2023-05-25 18:37:37 +02:00
2023-05-18 20:25:38 +02:00
If _interfaceFade < 1 . 0F Then
_interfaceFade = MathHelper . Lerp ( 1 , _interfaceFade , 0 . 95F )
2023-05-25 18:37:37 +02:00
If _interfaceFade = 1 . 0F Then
2023-05-18 20:25:38 +02:00
_interfaceFade = 1 . 0F
End If
End If
End If
End Sub
2023-05-24 14:30:38 +02:00
Public Sub Quit ( )
2023-05-27 15:40:38 +02:00
SoundManager . PlaySound ( " VoltorbFlip\QuitGame " , True )
2023-05-27 19:27:48 +02:00
TextBox . Show ( Localization . GetString ( " VoltorbFlip_QuitGame_1 " , " <player.name> received~ " ) & CurrentCoins . ToString & " " & Localization . GetString ( " VoltorbFlip_QuitGame_2 " , " Coin(s)! " ) )
2023-05-24 14:30:38 +02:00
2023-05-27 19:27:48 +02:00
If GameState = States . QuitQuestion Then
TotalCoins += CurrentCoins
CurrentFlips = 0
2023-05-24 14:30:38 +02:00
2023-05-27 19:27:48 +02:00
CurrentCoins = 0
End If
2023-05-29 09:57:39 +02:00
ChooseBox . readyForResult = False
2023-05-28 21:34:20 +02:00
GameState = States . NewLevelQuestion
2023-05-24 14:30:38 +02:00
End Sub
2023-05-18 20:25:38 +02:00
End Class
2023-05-22 19:33:09 +02:00
2023-05-18 20:25:38 +02:00
Public Class Tile
Public Enum Values
Voltorb
One
Two
Three
End Enum
Public Property Row As Integer = 0
Public Property Column As Integer = 0
Public Property Value As Integer = Tile . Values . Voltorb
Public Property Flipped As Boolean = False
2023-05-23 14:14:15 +02:00
Private Property MemoVoltorb As Boolean = False
2023-05-18 20:25:38 +02:00
Private Property Memo1 As Boolean = False
Private Property Memo2 As Boolean = False
Private Property Memo3 As Boolean = False
2023-05-25 18:37:37 +02:00
Private Property FlipWidth As Single = 1 . 0F
2023-05-22 19:33:09 +02:00
Private Property Activated As Boolean = False
2023-05-24 14:30:38 +02:00
Public Property FlipProgress As Integer = 0
2023-05-22 19:33:09 +02:00
2023-05-18 20:25:38 +02:00
Public Sub Flip ( )
If Flipped = False Then
2023-05-22 19:33:09 +02:00
FlipProgress = 3
2023-05-27 15:09:41 +02:00
If Value <> Values . Voltorb Then
VoltorbFlipScreen . CurrentFlips += 1
End If
2023-05-22 19:33:09 +02:00
End If
End Sub
Public Sub Reveal ( )
If Flipped = False Then
FlipProgress = 1
2023-05-18 20:25:38 +02:00
End If
End Sub
Public Sub Reset ( )
2023-05-22 19:33:09 +02:00
If Flipped = True Then
2023-05-24 14:30:38 +02:00
FlipProgress = 1
2023-05-22 19:33:09 +02:00
Activated = False
End If
2023-05-18 20:25:38 +02:00
End Sub
2023-05-22 19:33:09 +02:00
Public Sub Draw ( )
Dim mainBackgroundColor As Color = New Color ( 255 , 255 , 255 )
If VoltorbFlipScreen . GameState = VoltorbFlipScreen . States . Closing Or VoltorbFlipScreen . GameState = VoltorbFlipScreen . States . Opening Then
mainBackgroundColor = New Color ( 255 , 255 , 255 , CInt ( 255 * VoltorbFlipScreen . _interfaceFade ) )
End If
Dim TileWidth = VoltorbFlipScreen . TileSize . Width
Dim TileHeight = VoltorbFlipScreen . TileSize . Height
If FlipProgress = 1 OrElse FlipProgress = 3 Then
If FlipWidth > 0F Then
2023-05-25 18:37:37 +02:00
FlipWidth -= 0 . 1F
2023-05-22 19:33:09 +02:00
End If
If FlipWidth <= 0F Then
FlipWidth = 0F
2023-05-24 14:30:38 +02:00
If Flipped = False Then
2023-05-27 15:09:41 +02:00
SetMemo ( 0 , False )
SetMemo ( 1 , False )
SetMemo ( 2 , False )
SetMemo ( 3 , False )
2023-05-24 14:30:38 +02:00
Flipped = True
Else
Flipped = False
End If
2023-05-22 19:33:09 +02:00
FlipProgress += 1
End If
2023-05-27 16:10:30 +02:00
End If
2023-05-22 19:33:09 +02:00
If FlipProgress = 2 OrElse FlipProgress = 4 Then
If FlipWidth < 1 . 0F Then
2023-05-25 18:37:37 +02:00
FlipWidth += 0 . 1F
2023-05-22 19:33:09 +02:00
End If
If FlipWidth >= 1 . 0F Then
FlipWidth = 1 . 0F
FlipProgress = 0
End If
End If
2023-05-23 14:14:15 +02:00
'Draw Tile
2023-05-25 18:37:37 +02:00
SpriteBatch . Draw ( GetImage , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + TileWidth * Column + ( TileWidth - FlipWidth * TileWidth ) / 2 ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + TileHeight * Row ) , CInt ( TileWidth * FlipWidth ) , TileHeight ) , mainBackgroundColor )
2023-05-22 19:33:09 +02:00
2023-05-23 14:14:15 +02:00
'Draw Memos
If GetMemo ( 0 ) = True Then 'Voltorb
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Tile_MemoIcons " , New Rectangle ( 0 , 0 , 32 , 32 ) ) , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + TileWidth * Column + ( TileWidth - FlipWidth * TileWidth ) ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + TileHeight * Row ) , CInt ( TileWidth * FlipWidth ) , TileHeight ) , mainBackgroundColor )
End If
If GetMemo ( 1 ) = True Then 'x1
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Tile_MemoIcons " , New Rectangle ( 32 , 0 , 32 , 32 ) ) , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + TileWidth * Column + ( TileWidth - FlipWidth * TileWidth ) ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + TileHeight * Row ) , CInt ( TileWidth * FlipWidth ) , TileHeight ) , mainBackgroundColor )
End If
If GetMemo ( 2 ) = True Then 'x2
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Tile_MemoIcons " , New Rectangle ( 32 + 32 , 0 , 32 , 32 ) ) , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + TileWidth * Column + ( TileWidth - FlipWidth * TileWidth ) ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + TileHeight * Row ) , CInt ( TileWidth * FlipWidth ) , TileHeight ) , mainBackgroundColor )
End If
If GetMemo ( 3 ) = True Then 'x3
SpriteBatch . Draw ( TextureManager . GetTexture ( " VoltorbFlip\Tile_MemoIcons " , New Rectangle ( 32 + 32 + 32 , 0 , 32 , 32 ) ) , New Rectangle ( CInt ( VoltorbFlipScreen . BoardOrigin . X + TileWidth * Column + ( TileWidth - FlipWidth * TileWidth ) ) , CInt ( VoltorbFlipScreen . BoardOrigin . Y + TileHeight * Row ) , CInt ( TileWidth * FlipWidth ) , TileHeight ) , mainBackgroundColor )
End If
2023-05-22 19:33:09 +02:00
End Sub
Public Sub Update ( )
If FlipProgress <= 2 Then
Activated = False
Else
If Flipped = True Then
If Activated = False Then
If Me . Value = Values . Voltorb Then
2023-05-27 15:40:38 +02:00
If VoltorbFlipScreen . GameState = VoltorbFlipScreen . States . Game Then
SoundManager . PlaySound ( " VoltorbFlip\LoseGame " , True )
End If
2023-05-27 19:27:48 +02:00
Screen . TextBox . Show ( Localization . GetString ( " VoltorbFlip_GameLost " , " Oh no! You get 0 Coins! " ) )
2023-05-27 16:10:30 +02:00
VoltorbFlipScreen . ConsecutiveWins = 0
2023-05-22 19:33:09 +02:00
VoltorbFlipScreen . GameState = VoltorbFlipScreen . States . GameLost
Else
2023-05-27 15:09:41 +02:00
If VoltorbFlipScreen . CurrentCoins = 0 Then
VoltorbFlipScreen . CurrentCoins = Me . Value
Else
VoltorbFlipScreen . CurrentCoins *= Me . Value
End If
Activated = True
2023-05-22 19:33:09 +02:00
End If
End If
End If
End If
End Sub
Public Function GetImage ( ) As Texture2D
If Flipped = True Then
Return TextureManager . GetTexture ( " VoltorbFlip\Tile_Front " , New Rectangle ( Value * 32 , 0 , 32 , 32 ) )
Else
Return TextureManager . GetTexture ( " VoltorbFlip\Tile_Back " , New Rectangle ( 0 , 0 , 32 , 32 ) )
End If
End Function
2023-05-23 14:14:15 +02:00
2023-05-18 20:25:38 +02:00
Public Function GetMemo ( ByVal MemoNumber As Integer ) As Boolean
Select Case MemoNumber
2023-05-23 14:14:15 +02:00
Case 0
Return MemoVoltorb
2023-05-18 20:25:38 +02:00
Case 1
Return Memo1
Case 2
Return Memo2
Case 3
Return Memo3
Case Else
Return Nothing
End Select
End Function
2023-05-22 19:33:09 +02:00
2023-05-18 20:25:38 +02:00
Public Sub SetMemo ( ByVal MemoNumber As Integer , ByVal Value As Boolean )
Select Case MemoNumber
Case Tile . Values . Voltorb
2023-05-23 14:14:15 +02:00
MemoVoltorb = Value
2023-05-18 20:25:38 +02:00
Case Tile . Values . One
2023-05-23 14:14:15 +02:00
Memo1 = Value
2023-05-18 20:25:38 +02:00
Case Tile . Values . Two
2023-05-23 14:14:15 +02:00
Memo2 = Value
2023-05-18 20:25:38 +02:00
Case Tile . Values . Three
2023-05-23 14:14:15 +02:00
Memo3 = Value
2023-05-18 20:25:38 +02:00
End Select
End Sub
Public Sub New ( ByVal Row As Integer , ByVal Column As Integer , ByVal Value As Integer , ByVal Flipped As Boolean )
Me . Row = Row
Me . Column = Column
Me . Value = Value
Me . Flipped = Flipped
End Sub
End Class
End Namespace