Create AnimatedTile entity. Hopefully fixed invalid cast exception related to screen cameras, and some FPS issues.
This commit is contained in:
parent
18e31acc8b
commit
05c6d880cd
|
@ -208,6 +208,7 @@
|
|||
<Compile Include="Entites\Enviroment\WallBill.vb" />
|
||||
<Compile Include="Entites\Enviroment\WallBlock.vb" />
|
||||
<Compile Include="Entites\Enviroment\WarpBlock.vb" />
|
||||
<Compile Include="Entites\Enviroment\AnimatedTile.vb" />
|
||||
<Compile Include="Entites\Enviroment\Water.vb" />
|
||||
<Compile Include="Entites\Enviroment\Waterfall.vb" />
|
||||
<Compile Include="Entites\Enviroment\Whirlpool.vb" />
|
||||
|
|
|
@ -225,7 +225,7 @@
|
|||
Return v
|
||||
End Function
|
||||
|
||||
Public ReadOnly Property CPosition() As Vector3
|
||||
Public Overrides ReadOnly Property CPosition() As Vector3
|
||||
Get
|
||||
Return Me.Position + GetBattleMapOffset()
|
||||
End Get
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
Me.UpdateEntity()
|
||||
End Sub
|
||||
|
||||
Public Shared Function GetNewEntity(ByVal EntityID As String, ByVal Position As Vector3, ByVal Textures() As Texture2D, ByVal TextureIndex() As Integer, ByVal Collision As Boolean, ByVal Rotation As Vector3, ByVal Scale As Vector3, ByVal Model As BaseModel, ByVal ActionValue As Integer, ByVal AdditionalValue As String, ByVal Visible As Boolean, ByVal Shader As Vector3, ByVal ID As Integer, ByVal MapOrigin As String, ByVal SeasonColorTexture As String, ByVal Offset As Vector3, Optional ByVal Params() As Object = Nothing, Optional ByVal Opacity As Single = 1.0F) As Entity
|
||||
Public Shared Function GetNewEntity(ByVal EntityID As String, ByVal Position As Vector3, ByVal Textures() As Texture2D, ByVal TextureIndex() As Integer, ByVal Collision As Boolean, ByVal Rotation As Vector3, ByVal Scale As Vector3, ByVal Model As BaseModel, ByVal ActionValue As Integer, ByVal AdditionalValue As String, ByVal Visible As Boolean, ByVal Shader As Vector3, ByVal ID As Integer, ByVal MapOrigin As String, ByVal SeasonColorTexture As String, ByVal Offset As Vector3, Optional ByVal Params() As Object = Nothing, Optional ByVal Opacity As Single = 1.0F, Optional ByVal AnimationData As List(Of Integer) = Nothing) As Entity
|
||||
Dim newEnt As New Entity()
|
||||
Dim propertiesEnt As New Entity()
|
||||
|
||||
|
@ -146,6 +146,10 @@
|
|||
propertiesEnt.Offset = Offset
|
||||
|
||||
Select Case EntityID.ToLower()
|
||||
Case "animatedtile"
|
||||
newEnt = New AnimatedTile()
|
||||
SetProperties(newEnt, propertiesEnt)
|
||||
CType(newEnt, AnimatedTile).Initialize(AnimationData)
|
||||
Case "wallblock"
|
||||
newEnt = New WallBlock()
|
||||
SetProperties(newEnt, propertiesEnt)
|
||||
|
@ -363,19 +367,13 @@
|
|||
Dim CPosition As Vector3 = Screen.Camera.Position
|
||||
Dim ActionScriptActive As Boolean = False
|
||||
|
||||
SyncLock Screen.Camera
|
||||
If Not Core.CurrentScreen Is Nothing Then
|
||||
If Screen.Camera.Name.ToLower() = "overworld" Then
|
||||
CPosition = CType(Screen.Camera, OverworldCamera).CPosition
|
||||
End If
|
||||
If Screen.Camera.Name.ToLower() = "battlev2" Then
|
||||
CPosition = CType(Screen.Camera, BattleSystem.BattleCamera).CPosition
|
||||
End If
|
||||
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
|
||||
ActionScriptActive = Not CType(Core.CurrentScreen, OverworldScreen).ActionScript.IsReady
|
||||
End If
|
||||
|
||||
If Not Core.CurrentScreen Is Nothing Then
|
||||
CPosition = Screen.Camera.CPosition
|
||||
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
|
||||
ActionScriptActive = Not CType(Core.CurrentScreen, OverworldScreen).ActionScript.IsReady
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
|
||||
|
||||
CameraDistance = CalculateCameraDistance(CPosition)
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
Public Class AnimatedTile
|
||||
|
||||
Inherits Entity
|
||||
|
||||
Shared TileTexturesTemp As New Dictionary(Of String, Texture2D)
|
||||
Dim TileTextureName As String = ""
|
||||
|
||||
Dim tileAnimation As Animation
|
||||
Dim currentRectangle As New Rectangle(0, 0, 0, 0)
|
||||
|
||||
Dim rows, columns, animationSpeed, startRow, startColumn As Integer
|
||||
|
||||
|
||||
Public Overloads Sub Initialize(ByVal AnimationData As List(Of Integer))
|
||||
MyBase.Initialize()
|
||||
rows = AnimationData(0)
|
||||
columns = AnimationData(1)
|
||||
animationSpeed = AnimationData(2)
|
||||
startRow = AnimationData(3)
|
||||
startColumn = AnimationData(4)
|
||||
|
||||
tileAnimation = New Animation(TextureManager.GetTexture("Textures\Routes"), rows, columns, 16, 16, animationSpeed, startRow, startColumn)
|
||||
|
||||
CreateTileTextureTemp()
|
||||
End Sub
|
||||
|
||||
Public Shared Sub ClearAnimationResources()
|
||||
TileTexturesTemp.Clear()
|
||||
End Sub
|
||||
|
||||
Private Sub CreateTileTextureTemp()
|
||||
'If Core.GameOptions.GraphicStyle = 1 Then
|
||||
Dim textureData As List(Of String) = Me.AdditionalValue.Split(CChar(",")).ToList()
|
||||
If textureData.Count >= 5 Then
|
||||
Dim r As New Rectangle(CInt(textureData(1)), CInt(textureData(2)), CInt(textureData(3)), CInt(textureData(4)))
|
||||
Dim texturePath As String = textureData(0)
|
||||
Me.TileTextureName = AdditionalValue
|
||||
If AnimatedTile.TileTexturesTemp.ContainsKey(AdditionalValue & "_0") = False Then
|
||||
For i = 0 To Me.rows - 1
|
||||
For j = 0 To Me.columns - 1
|
||||
AnimatedTile.TileTexturesTemp.Add(AdditionalValue & "_" & (j + columns * i).ToString, TextureManager.GetTexture(texturePath, New Rectangle(r.X + r.Width * j, r.Y + r.Height * i, r.Width, r.Height)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
Logger.Log(Logger.LogTypes.ErrorMessage, "AnimatedTile.vb: invalid AdditionalValue parameters")
|
||||
End If
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub ClickFunction()
|
||||
Me.Surf()
|
||||
End Sub
|
||||
|
||||
Public Overrides Function WalkAgainstFunction() As Boolean
|
||||
WalkOntoFunction()
|
||||
Return MyBase.WalkAgainstFunction()
|
||||
End Function
|
||||
|
||||
Public Overrides Function WalkIntoFunction() As Boolean
|
||||
WalkOntoFunction()
|
||||
Return MyBase.WalkIntoFunction()
|
||||
End Function
|
||||
|
||||
Public Overrides Sub WalkOntoFunction()
|
||||
If Screen.Level.Surfing = True Then
|
||||
Dim canSurf As Boolean = False
|
||||
|
||||
For Each Entity As Entity In Screen.Level.Entities
|
||||
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
||||
If Entity.EntityID = "Water" Then
|
||||
canSurf = True
|
||||
Else
|
||||
If Entity.Collision = True Then
|
||||
canSurf = False
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
If canSurf = True Then
|
||||
Screen.Camera.Move(1)
|
||||
|
||||
Screen.Level.PokemonEncounter.TryEncounterWildPokemon(Me.Position, Spawner.EncounterMethods.Surfing, "")
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Surf()
|
||||
If Screen.Camera.Turning = False Then
|
||||
If Screen.Level.Surfing = False Then
|
||||
If Badge.CanUseHMMove(Badge.HMMoves.Surf) = True Or GameController.IS_DEBUG_ACTIVE = True Or Core.Player.SandBoxMode = True Then
|
||||
If Screen.ChooseBox.Showing = False Then
|
||||
Dim canSurf As Boolean = False
|
||||
|
||||
If Me.ActionValue = 0 Then
|
||||
For Each Entity As Entity In Screen.Level.Entities
|
||||
If Entity.boundingBox.Contains(Screen.Camera.GetForwardMovedPosition()) = ContainmentType.Contains Then
|
||||
If Entity.EntityID = "Water" Then
|
||||
If Core.Player.SurfPokemon > -1 Then
|
||||
canSurf = True
|
||||
End If
|
||||
Else
|
||||
If Entity.Collision = True Then
|
||||
canSurf = False
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If Screen.Level.Riding = True Then
|
||||
canSurf = False
|
||||
End If
|
||||
|
||||
If canSurf = True Then
|
||||
Dim message As String = "Do you want to Surf?%Yes|No%"
|
||||
Screen.TextBox.Show(message, {Me}, True, True)
|
||||
SoundManager.PlaySound("select")
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Overrides Function CalculateCameraDistance(CPosition As Vector3) As Single
|
||||
Return MyBase.CalculateCameraDistance(CPosition) - 0.25F
|
||||
End Function
|
||||
|
||||
Public Overrides Sub UpdateEntity()
|
||||
If Not tileAnimation Is Nothing Then
|
||||
tileAnimation.Update(0.01)
|
||||
If currentRectangle <> tileAnimation.TextureRectangle Then
|
||||
ChangeTexture()
|
||||
|
||||
currentRectangle = tileAnimation.TextureRectangle
|
||||
End If
|
||||
End If
|
||||
|
||||
MyBase.UpdateEntity()
|
||||
End Sub
|
||||
|
||||
Private Sub ChangeTexture()
|
||||
'If Core.GameOptions.GraphicStyle = 1 Then
|
||||
If TileTexturesTemp.Count = 0 Then
|
||||
ClearAnimationResources()
|
||||
CreateTileTextureTemp()
|
||||
End If
|
||||
Dim i = tileAnimation.CurrentRow
|
||||
Dim j = tileAnimation.CurrentColumn
|
||||
Me.Textures(0) = AnimatedTile.TileTexturesTemp(TileTextureName & "_" & (j + columns * i))
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub ResultFunction(ByVal Result As Integer)
|
||||
If Result = 0 Then
|
||||
Screen.TextBox.Show(Core.Player.Pokemons(Core.Player.SurfPokemon).GetDisplayName() & " used~Surf!", {Me})
|
||||
Screen.Level.Surfing = True
|
||||
Screen.Camera.Move(1)
|
||||
PlayerStatistics.Track("Surf used", 1)
|
||||
|
||||
With Screen.Level.OwnPlayer
|
||||
Core.Player.TempSurfSkin = .SkinName
|
||||
|
||||
Dim pokemonNumber As Integer = Core.Player.Pokemons(Core.Player.SurfPokemon).Number
|
||||
Dim SkinName As String = "[POKEMON|N]" & pokemonNumber & PokemonForms.GetOverworldAddition(Core.Player.Pokemons(Core.Player.SurfPokemon))
|
||||
If Core.Player.Pokemons(Core.Player.SurfPokemon).IsShiny = True Then
|
||||
SkinName = "[POKEMON|S]" & pokemonNumber & PokemonForms.GetOverworldAddition(Core.Player.Pokemons(Core.Player.SurfPokemon))
|
||||
End If
|
||||
|
||||
.SetTexture(SkinName, False)
|
||||
|
||||
.UpdateEntity()
|
||||
|
||||
SoundManager.PlayPokemonCry(pokemonNumber)
|
||||
|
||||
If Screen.Level.IsRadioOn = False OrElse GameJolt.PokegearScreen.StationCanPlay(Screen.Level.SelectedRadioStation) = False Then
|
||||
MusicManager.PlayMusic("surf", True)
|
||||
End If
|
||||
End With
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Overrides Sub Render()
|
||||
Dim setRasterizerState As Boolean = Me.Model.ID <> 0
|
||||
|
||||
Me.Draw(Me.Model, Textures, setRasterizerState)
|
||||
End Sub
|
||||
|
||||
End Class
|
|
@ -97,5 +97,9 @@
|
|||
Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(newFOV), Core.GraphicsDevice.Viewport.AspectRatio, 0.01, Me.FarPlane)
|
||||
Me.FOV = newFOV
|
||||
End Sub
|
||||
|
||||
Public Overridable ReadOnly Property CPosition As Vector3
|
||||
Get
|
||||
Return Me.Position
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
|
@ -63,7 +63,7 @@ Public Class OverworldCamera
|
|||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property CPosition() As Vector3
|
||||
Public Overrides ReadOnly Property CPosition() As Vector3
|
||||
Get
|
||||
Return _cPosition
|
||||
End Get
|
||||
|
|
|
@ -851,23 +851,26 @@ Public Class Level
|
|||
Me._offsetMapUpdateDelay = Core.GameOptions.LoadOffsetMaps - 1 'Set the new delay
|
||||
|
||||
' Remove entities that CanBeRemoved (see what I did there?):
|
||||
' Now it also updates the remaining entities.
|
||||
For i = 0 To OffsetmapEntities.Count - 1
|
||||
If i <= OffsetmapEntities.Count - 1 Then
|
||||
If OffsetmapEntities(i).CanBeRemoved = True Then
|
||||
If OffsetmapEntities(i).CanBeRemoved Then
|
||||
OffsetmapEntities.RemoveAt(i)
|
||||
i -= 1
|
||||
Else
|
||||
OffsetmapEntities(i).UpdateEntity()
|
||||
End If
|
||||
Else
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
' Call UpdateEntity on all offset map entities:
|
||||
For i = Me.OffsetmapEntities.Count - 1 To 0 Step -1
|
||||
If i <= Me.OffsetmapEntities.Count - 1 Then
|
||||
Me.OffsetmapEntities(i).UpdateEntity()
|
||||
End If
|
||||
Next
|
||||
'' Call UpdateEntity on all offset map entities:
|
||||
'For i = Me.OffsetmapEntities.Count - 1 To 0 Step -1
|
||||
' If i <= Me.OffsetmapEntities.Count - 1 Then
|
||||
' Me.OffsetmapEntities(i).UpdateEntity()
|
||||
' End If
|
||||
'Next
|
||||
|
||||
' Call UpdateEntity on all offset map floors:
|
||||
For i = Me.OffsetmapFloors.Count - 1 To 0 Step -1
|
||||
|
|
|
@ -806,6 +806,11 @@
|
|||
AdditionalValue = CStr(GetTag(Tags, "AdditionalValue"))
|
||||
End If
|
||||
|
||||
Dim AnimationData As List(Of Integer) = Nothing
|
||||
If TagExists(Tags, "AnimationData") = True Then
|
||||
AnimationData = CType(GetTag(Tags, "AnimationData"), List(Of Integer))
|
||||
End If
|
||||
|
||||
Dim Rotation As Vector3 = Entity.GetRotationFromInteger(CInt(GetTag(Tags, "Rotation")))
|
||||
|
||||
Dim Visible As Boolean = True
|
||||
|
@ -865,6 +870,9 @@
|
|||
End If
|
||||
End If
|
||||
|
||||
If AnimationData IsNot Nothing AndAlso AnimationData.Count = 5 Then
|
||||
|
||||
End If
|
||||
If DoAdd = True Then
|
||||
Dim newEnt As Entity = Entity.GetNewEntity(EntityID,
|
||||
New Vector3(Position.X + X, Position.Y + Y, Position.Z + Z),
|
||||
|
@ -883,7 +891,8 @@
|
|||
SeasonTexture,
|
||||
Offset,
|
||||
{},
|
||||
Opacity)
|
||||
Opacity,
|
||||
AnimationData)
|
||||
newEnt.IsOffsetMapContent = loadOffsetMap
|
||||
|
||||
If Not newEnt Is Nothing Then
|
||||
|
|
Loading…
Reference in New Issue