P3D-Legacy/P3D/Core/GameController.vb

169 lines
4.9 KiB
VB.net
Raw Normal View History

2016-11-25 21:24:46 +01:00
Imports System.Windows.Forms
2018-02-24 09:32:04 +01:00
Imports GameDevCommon
2016-09-07 18:50:38 +02:00
''' <summary>
''' Controls the game's main workflow.
''' </summary>
Public Class GameController
Inherits Microsoft.Xna.Framework.Game
2018-02-24 09:32:04 +01:00
Implements IGame
2016-09-07 18:50:38 +02:00
''' <summary>
''' The current version of the game.
''' </summary>
Public Const GAMEVERSION As String = "0.55"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The number of released iterations of the game.
''' </summary>
Public Const RELEASEVERSION As String = "94"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The development stage the game is in.
''' </summary>
Public Const GAMEDEVELOPMENTSTAGE As String = "Indev"
''' <summary>
''' The name of the game.
''' </summary>
2016-11-25 21:24:46 +01:00
Public Const GAMENAME As String = "Pokémon 3D"
2016-09-07 18:50:38 +02:00
''' <summary>
''' The name of the developer that appears on the title screen.
''' </summary>
Public Const DEVELOPER_NAME As String = "P3D Team"
2016-09-07 18:50:38 +02:00
''' <summary>
''' If the Debug Mode is active.
''' </summary>
#If DEBUG Or DEBUGNOCONTENT Then
Public Const IS_DEBUG_ACTIVE As Boolean = True
#Else
2016-09-07 18:50:38 +02:00
Public Const IS_DEBUG_ACTIVE As Boolean = False
#End If
2016-09-07 18:50:38 +02:00
''' <summary>
''' If the game should set the GameJolt online version to the current online version.
''' </summary>
Public Const UPDATEONLINEVERSION As Boolean = False
Public Graphics As GraphicsDeviceManager
Public FPSMonitor As FPSMonitor
Public Shared UpdateChecked As Boolean = False
2016-09-07 18:50:38 +02:00
2018-02-24 09:32:04 +01:00
Private _componentManager As ComponentManager
2016-09-07 18:50:38 +02:00
Public Sub New()
Graphics = New GraphicsDeviceManager(Me)
Content.RootDirectory = "Content"
Window.AllowUserResizing = True
AddHandler Window.ClientSizeChanged, AddressOf Window_ClientSizeChanged
'Dim gameForm As Form = CType(Form.FromHandle(Window.Handle), Form)
'gameForm.MinimumSize = New System.Drawing.Size(600, 360)
2016-09-07 18:50:38 +02:00
FPSMonitor = New FPSMonitor()
GameHacked = System.IO.File.Exists(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData & "\temp")
If GameHacked = True Then
Security.HackerAlerts.Activate()
End If
2018-02-24 09:32:04 +01:00
_componentManager = New ComponentManager()
GameInstanceProvider.SetInstance(Me)
2016-09-07 18:50:38 +02:00
End Sub
Protected Overrides Sub Initialize()
2018-02-24 09:32:04 +01:00
_componentManager.LoadComponents()
2016-09-07 18:50:38 +02:00
Core.Initialize(Me)
MyBase.Initialize()
End Sub
Protected Overrides Sub LoadContent()
End Sub
Protected Overrides Sub UnloadContent()
End Sub
Protected Overrides Sub Update(ByVal gameTime As GameTime)
Core.Update(gameTime)
MyBase.Update(gameTime)
GameJolt.SessionManager.Update()
FPSMonitor.Update(gameTime)
End Sub
Protected Overrides Sub Draw(ByVal gameTime As GameTime)
Core.Draw()
MyBase.Draw(gameTime)
FPSMonitor.DrawnFrame()
End Sub
Public Shared ReadOnly Property DecSeparator As String
Get
Return My.Application.Culture.NumberFormat.NumberDecimalSeparator
End Get
End Property
Protected Overrides Sub OnExiting(sender As Object, args As System.EventArgs)
GameJolt.SessionManager.Close()
If Core.ServersManager.ServerConnection.Connected = True Then
Core.ServersManager.ServerConnection.Abort()
End If
Logger.Debug("---Exit Game---")
End Sub
Protected Sub Window_ClientSizeChanged(ByVal sender As Object, ByVal e As EventArgs)
Core.windowSize = New Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height)
If Not Core.CurrentScreen Is Nothing Then
Core.CurrentScreen.SizeChanged()
Screen.TextBox.PositionY = Core.windowSize.Height - 160.0F
End If
NetworkPlayer.ScreenRegionChanged()
End Sub
Private Sub DGame_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
NetworkPlayer.ScreenRegionChanged()
End Sub
Private Sub DGame_Deactivated(sender As Object, e As System.EventArgs) Handles Me.Deactivated
NetworkPlayer.ScreenRegionChanged()
End Sub
2018-02-24 09:32:04 +01:00
Public Function GetGame() As Game Implements IGame.GetGame
Return Me
End Function
Public Function GetComponentManager() As ComponentManager Implements IGame.GetComponentManager
Return _componentManager
End Function
2016-09-07 18:50:38 +02:00
Private Shared GameHacked As Boolean = False 'Temp value that stores if a hacking file was detected at game start.
2016-09-19 03:26:44 +02:00
2016-09-07 18:50:38 +02:00
''' <summary>
2016-11-25 21:24:46 +01:00
''' If the player hacked any instance of Pokémon3D at some point.
2016-09-07 18:50:38 +02:00
''' </summary>
Public Shared ReadOnly Property Hacker() As Boolean
Get
Return GameHacked
End Get
End Property
''' <summary>
''' The path to the game folder.
''' </summary>
Public Shared ReadOnly Property GamePath() As String
Get
Return My.Application.Info.DirectoryPath
End Get
End Property
End Class