Major lag in Underwatercave is fixed. Misc coding stuff is fixed as well.

This commit is contained in:
jianmingyong 2017-02-11 22:14:09 +08:00
parent 2243f58fbc
commit 0db122e2a4
6 changed files with 50 additions and 52 deletions

View File

@ -2,15 +2,12 @@
Public Class BattleScreen
Inherits Screen
'Used for after fainting switching
Public Shared OwnFaint As Boolean = False
Public Shared OppFaint As Boolean = False
'Used for lead picking in PvP Battles
Public Shared OwnLeadIndex As Integer = 0
Public Shared OppLeadIndex As Integer = 0
@ -873,6 +870,7 @@ nextIndex:
Lighting.UpdateLighting(Screen.Effect)
Camera.Update()
Level.Update()
SkyDome.Update()
TextBox.Update()
@ -975,6 +973,8 @@ nextIndex:
#End Region
Public Sub EndBattle(ByVal blackout As Boolean)
Level.StopOffsetMapUpdate()
Dim str As String = ""
'Call the EndBattle function of the abilities and Reverts battle only Pokemon formes.
For Each p As Pokemon In Core.Player.Pokemons
@ -1143,14 +1143,13 @@ nextIndex:
End While
Else
i = Core.Random.Next(0, Trainer.Pokemons.count)
i = Core.Random.Next(0, Trainer.Pokemons.Count)
While Trainer.Pokemons(i).Status = Pokemon.StatusProblems.Fainted OrElse OppPokemonIndex = i OrElse Trainer.Pokemons(i).HP <= 0
i = Core.Random.Next(0, Trainer.Pokemons.count)
i = Core.Random.Next(0, Trainer.Pokemons.Count)
End While
End If
End If
OppPokemonIndex = i
OppPokemon = Trainer.Pokemons(i)
@ -1416,7 +1415,6 @@ nextIndex:
End If
End If
While cData.Length > 0
If cData(0).ToString() = "|" AndAlso tempData(tempData.Length - 1).ToString() = "}" Then
newQueries.Add(tempData)
@ -1432,8 +1430,6 @@ nextIndex:
tempData = ""
End If
If s.Identification = Identifications.BattleScreen Then
CType(s, BattleScreen).BattleQuery.Clear()
For Each q As String In newQueries
@ -1545,7 +1541,7 @@ nextIndex:
''' Use this to download the sprites for the players.
''' </summary>
Private Sub DownloadOnlineSprites()
If Core.Player.IsGamejoltSave = True Then
If Core.Player.IsGameJoltSave = True Then
Dim t As New Threading.Thread(AddressOf DownloadSprites)
t.IsBackground = True
t.Start()
@ -1578,4 +1574,4 @@ nextIndex:
End Class
End Namespace
End Namespace

View File

@ -1,57 +1,57 @@
Public Class MainGameFunctions
Public Shared Sub FunctionKeys()
If KeyBoardHandler.KeyPressed(KeyBindings.ScreenshotKey) = True And Core.CurrentScreen.CanTakeScreenshot = True Then
If KeyBoardHandler.KeyPressed(KeyBindings.GUIControlKey) = True Then
Core.GameOptions.ShowGUI = Not Core.GameOptions.ShowGUI
Core.GameOptions.SaveOptions()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.ScreenshotKey) AndAlso Core.CurrentScreen.CanTakeScreenshot Then
CaptureScreen()
End If
If KeyBoardHandler.KeyPressed(KeyBindings.FullScreenKey) = True Then
If Core.CurrentScreen.CanGoFullscreen = True Then
ToggleFullScreen()
End If
End If
If KeyBoardHandler.KeyPressed(KeyBindings.DebugKey) = True Then
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.DebugKey) Then
Core.GameOptions.ShowDebug += 1
If Core.GameOptions.ShowDebug >= 2 Then
Core.GameOptions.ShowDebug = 0
End If
Core.GameOptions.SaveOptions()
End If
If KeyBoardHandler.KeyPressed(KeyBindings.GUIControlKey) = True Then
Core.GameOptions.ShowGUI = Not Core.GameOptions.ShowGUI
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.LightKey) Then
Core.GameOptions.LightingEnabled = Not Core.GameOptions.LightingEnabled
Core.GameOptions.SaveOptions()
End If
If KeyBoardHandler.KeyPressed(KeyBindings.MuteMusicKey) = True And Core.CurrentScreen.CanMuteMusic = True Then
If Core.GameOptions.LightingEnabled Then
Core.GameMessage.ShowMessage(Localization.GetString("game_message_lighting_on", "Lighting Enabled"), 12, FontManager.MainFont, Color.White)
Else
Core.GameMessage.ShowMessage(Localization.GetString("game_message_lighting_off", "Lighting Disabled"), 12, FontManager.MainFont, Color.White)
End If
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.FullScreenKey) AndAlso Core.CurrentScreen.CanGoFullscreen Then
ToggleFullScreen()
ElseIf KeyBoardHandler.KeyPressed(KeyBindings.MuteMusicKey) AndAlso Core.CurrentScreen.CanMuteMusic Then
MusicManager.Mute(Not MediaPlayer.IsMuted)
SoundManager.Mute(MediaPlayer.IsMuted)
Core.GameOptions.SaveOptions()
Core.CurrentScreen.ToggledMute()
End If
If KeyBoardHandler.KeyPressed(KeyBindings.LightKey) = True Then
Core.GameOptions.LightingEnabled = Not Core.GameOptions.LightingEnabled
End If
If KeyBoardHandler.KeyDown(KeyBindings.DebugKey) = True Then
If KeyBoardHandler.KeyPressed(Keys.F) = True Then
If KeyBoardHandler.KeyPressed(Keys.F) Then
TextureManager.TextureList.Clear()
End If
If KeyBoardHandler.KeyPressed(Keys.S) = True Then
Core.GameMessage.ShowMessage(Localization.GetString("game_message_debug_texture_list_clear", "Texture list have cleared"), 12, FontManager.MainFont, Color.White)
ElseIf KeyBoardHandler.KeyPressed(Keys.S) Then
Core.SetWindowSize(New Vector2(1200, 680))
ElseIf KeyBoardHandler.KeyPressed(Keys.L) Then
Logger.DisplayLog = Not Logger.DisplayLog
ElseIf KeyBoardHandler.KeyPressed(Keys.B) Then
Entity.drawViewBox = Not Entity.drawViewBox
End If
End If
If ControllerHandler.ButtonPressed(Buttons.Back, True) = True Then
Core.GameOptions.GamePadEnabled = Not Core.GameOptions.GamePadEnabled
If Core.GameOptions.GamePadEnabled = True Then
If Core.GameOptions.GamePadEnabled Then
Core.GameMessage.ShowMessage("Enabled XBOX 360 GamePad support.", 12, FontManager.MainFont, Color.White)
Else
Core.GameMessage.ShowMessage("Disabled XBOX 360 GamePad support.", 12, FontManager.MainFont, Color.White)
End If
Core.GameOptions.SaveOptions()
End If
If KeyBoardHandler.KeyPressed(Keys.L) = True And KeyBoardHandler.KeyDown(KeyBindings.DebugKey) = True Then
Logger.DisplayLog = Not Logger.DisplayLog
End If
If KeyBoardHandler.KeyPressed(Keys.B) = True And KeyBoardHandler.KeyDown(KeyBindings.DebugKey) = True Then
Entity.drawViewBox = Not Entity.drawViewBox
End If
End Sub
Private Shared Sub CaptureScreen()
@ -88,12 +88,12 @@
End If
If Core.GraphicsManager.IsFullScreen = False Then
Dim b As New System.Drawing.Bitmap(Core.windowSize.Width, Core.windowSize.Height)
Using g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(b)
g.CopyFromScreen(Core.window.ClientBounds.X, Core.window.ClientBounds.Y, 0, 0, New System.Drawing.Size(b.Width, b.Height))
Dim b As New Drawing.Bitmap(Core.windowSize.Width, Core.windowSize.Height)
Using g As Drawing.Graphics = Drawing.Graphics.FromImage(b)
g.CopyFromScreen(Core.window.ClientBounds.X, Core.window.ClientBounds.Y, 0, 0, New Drawing.Size(b.Width, b.Height))
End Using
b.Save(GameController.GamePath & "\screenshots\" & fileName, System.Drawing.Imaging.ImageFormat.Png)
b.Save(GameController.GamePath & "\screenshots\" & fileName, Drawing.Imaging.ImageFormat.Png)
Else
Dim screenshot As New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Core.GraphicsDevice.SetRenderTarget(screenshot)
@ -119,11 +119,11 @@
' MonoGame Bug > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width != System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
' MonoGame Bug > GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height != System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
' Temp Fix just in case someone else face this as well.
If GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width <> System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width OrElse
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height <> System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height Then
Core.GraphicsManager.PreferredBackBufferWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Core.GraphicsManager.PreferredBackBufferHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
Core.windowSize = New Rectangle(0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height)
If GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width <> Windows.Forms.Screen.PrimaryScreen.Bounds.Width OrElse
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height <> Windows.Forms.Screen.PrimaryScreen.Bounds.Height Then
Core.GraphicsManager.PreferredBackBufferWidth = Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Core.GraphicsManager.PreferredBackBufferHeight = Windows.Forms.Screen.PrimaryScreen.Bounds.Height
Core.windowSize = New Rectangle(0, 0, Windows.Forms.Screen.PrimaryScreen.Bounds.Width, Windows.Forms.Screen.PrimaryScreen.Bounds.Height)
Else
Core.GraphicsManager.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
Core.GraphicsManager.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height

View File

@ -164,9 +164,9 @@ Public Class Animation
End Sub
''' <summary>
''' Stopps the animation and returns to start.
''' Stops the animation and returns to start.
''' </summary>
Public Sub Stopp()
Public Sub [Stop]()
_Running = PlayMode.Stopped
CurrentRow = StartRow
CurrentColumn = StartColumn

View File

@ -329,7 +329,7 @@ Public Class OverworldScreen
d.Add(Buttons.A, "Interact")
d.Add(Buttons.X, "Menu")
If Core.Player.hasPokegear = True Then
If Core.Player.HasPokegear = True Then
d.Add(Buttons.Y, "Pokégear")
End If
@ -394,7 +394,7 @@ Public Class OverworldScreen
Thread.Sleep(20)
x = x + 1
End While
If String.IsNullOrEmpty(Level.MusicLoop)
If String.IsNullOrEmpty(Level.MusicLoop) Then
Return
End If

View File

@ -59,7 +59,7 @@
End If
End Sub
Public Overrides Sub Draw()
Public Overrides Sub Draw()
If reduce = False Then
OldScreen.Draw()
Else

View File

@ -685,7 +685,9 @@ Public Class Level
Public Sub StopOffsetMapUpdate()
Me._offsetTimer.Stop()
While Me._isUpdatingOffsetMaps : End While
While Me._isUpdatingOffsetMaps
System.Threading.Thread.Sleep(1)
End While
Logger.Debug("Stopped Offset map update")
End Sub