Merge branch 'Offset_Map_Fix'

This commit is contained in:
jianmingyong 2017-03-23 01:25:55 +08:00
commit 0910fdadf6
2 changed files with 13 additions and 13 deletions

View File

@ -118,6 +118,9 @@ Public MustInherit Class Screen
Return _globalLevel Return _globalLevel
End Get End Get
Set(value As Level) Set(value As Level)
If _globalLevel IsNot Nothing Then
_globalLevel.StopOffsetMapUpdate()
End If
_globalLevel = value _globalLevel = value
End Set End Set
End Property End Property

View File

@ -1,3 +1,4 @@
Imports System.Threading
''' <summary> ''' <summary>
''' A class that manages the collection of entities to represent a map. ''' A class that manages the collection of entities to represent a map.
''' </summary> ''' </summary>
@ -29,7 +30,7 @@ Public Class Level
Private _offsetMapUpdateDelay As Integer = 50 ' Ticks until the next Offset Map update occurs. Private _offsetMapUpdateDelay As Integer = 50 ' Ticks until the next Offset Map update occurs.
' Map properties: ' Map properties:
Private _terrain As Terrain = New Terrain(net.Pokemon3D.Game.Terrain.TerrainTypes.Plain) Private _terrain As Terrain = New Terrain(Terrain.TerrainTypes.Plain)
Private _mapName As String = "" Private _mapName As String = ""
Private _musicLoop As String = "" Private _musicLoop As String = ""
Private _levelFile As String = "" Private _levelFile As String = ""
@ -686,7 +687,7 @@ Public Class Level
Public Sub StopOffsetMapUpdate() Public Sub StopOffsetMapUpdate()
Me._offsetTimer.Stop() Me._offsetTimer.Stop()
While Me._isUpdatingOffsetMaps While Me._isUpdatingOffsetMaps
System.Threading.Thread.Sleep(1) Thread.Sleep(1)
End While End While
Logger.Debug("Stopped Offset map update") Logger.Debug("Stopped Offset map update")
@ -713,7 +714,7 @@ Public Class Level
End If End If
' Create own player entity and OverworldPokémon entity and add them to the entity enumeration: ' Create own player entity and OverworldPokémon entity and add them to the entity enumeration:
OwnPlayer = New OwnPlayer(0, 0, 0, {net.Pokemon3D.Game.TextureManager.DefaultTexture}, Core.Player.Skin, 0, 0, "", "Gold", 0) OwnPlayer = New OwnPlayer(0, 0, 0, {TextureManager.DefaultTexture}, Core.Player.Skin, 0, 0, "", "Gold", 0)
OverworldPokemon = New OverworldPokemon(Screen.Camera.Position.X, Screen.Camera.Position.Y, Screen.Camera.Position.Z + 1) OverworldPokemon = New OverworldPokemon(Screen.Camera.Position.X, Screen.Camera.Position.Y, Screen.Camera.Position.Z + 1)
OverworldPokemon.ChangeRotation() OverworldPokemon.ChangeRotation()
Entities.AddRange({OwnPlayer, OverworldPokemon}) Entities.AddRange({OwnPlayer, OverworldPokemon})
@ -797,13 +798,16 @@ Public Class Level
If LevelLoader.IsBusy = False Then If LevelLoader.IsBusy = False Then
For i = 0 To Entities.Count - 1 For i = 0 To Entities.Count - 1
If i <= Entities.Count - 1 Then If i <= Entities.Count - 1 Then
If Entities.Count - 1 >= i AndAlso Entities(i).CanBeRemoved = True Then If Entities.Count - 1 >= i AndAlso Entities(i).CanBeRemoved Then
Entities.RemoveAt(i) Entities.RemoveAt(i)
i -= 1 i -= 1
Else Else
If Entities(i).NeedsUpdate = True Then If Entities(i).NeedsUpdate Then
Entities(i).Update() Entities(i).Update()
End If End If
' UpdateEntity for all entities:
Me.Entities(i).UpdateEntity()
End If End If
Else Else
Exit For Exit For
@ -811,13 +815,6 @@ Public Class Level
Next Next
End If End If
' UpdateEntity for all entities:
For i = 0 To Me.Entities.Count - 1
If i <= Me.Entities.Count - 1 Then
Me.Entities(i).UpdateEntity()
End If
Next
' UpdateEntity for all floors: ' UpdateEntity for all floors:
For i = 0 To Me.Floors.Count - 1 For i = 0 To Me.Floors.Count - 1
If i <= Me.Floors.Count - 1 Then If i <= Me.Floors.Count - 1 Then
@ -953,7 +950,7 @@ Public Class Level
Me.Surfing = Core.Player.startSurfing ' Set the Surfing property after map switch. Me.Surfing = Core.Player.startSurfing ' Set the Surfing property after map switch.
' Create player and Pokémon entities: ' Create player and Pokémon entities:
OwnPlayer = New OwnPlayer(0, 0, 0, {net.Pokemon3D.Game.TextureManager.DefaultTexture}, Core.Player.Skin, 0, 0, "", "Gold", 0) OwnPlayer = New OwnPlayer(0, 0, 0, {TextureManager.DefaultTexture}, Core.Player.Skin, 0, 0, "", "Gold", 0)
OwnPlayer.SetTexture(Core.Player.Skin, usingGameJoltTexture) OwnPlayer.SetTexture(Core.Player.Skin, usingGameJoltTexture)
OverworldPokemon = New OverworldPokemon(Screen.Camera.Position.X, Screen.Camera.Position.Y, Screen.Camera.Position.Z + 1) OverworldPokemon = New OverworldPokemon(Screen.Camera.Position.X, Screen.Camera.Position.Y, Screen.Camera.Position.Z + 1)