P3D-Legacy/P3D/Entites/Enviroment/StrengthRock.vb

145 lines
4.9 KiB
VB.net
Raw Normal View History

2016-09-07 18:50:38 +02:00
Public Class StrengthRock
Inherits Entity
Public Overrides Sub Initialize()
MyBase.Initialize()
Me.CanMove = True
End Sub
Public Overrides Sub ClickFunction()
If Screen.Level.UsedStrength = True Then
Dim text As String = "Pokémon with Strength are~able to move this."
Screen.TextBox.Show(text, {Me})
SoundManager.PlaySound("select")
Else
Dim pName As String = ""
For Each p As Pokemon In Core.Player.Pokemons
If p.IsEgg() = False Then
For Each a As BattleSystem.Attack In p.Attacks
If a.Name = "Strength" Then
pName = p.GetDisplayName()
Exit For
End If
Next
End If
If pName <> "" Then
Exit For
End If
Next
2023-07-30 18:16:27 +02:00
Dim text As String = Localization.GetString("fieldmove_strength_1", "A Pokémon may be able~to move this.")
2016-09-07 18:50:38 +02:00
If pName <> "" And Badge.CanUseHMMove(Badge.HMMoves.Strength) = True Or GameController.IS_DEBUG_ACTIVE = True Or Core.Player.SandBoxMode = True Then
2023-07-30 18:16:27 +02:00
text &= Localization.GetString("fieldmove_strength_2", "*Do you want to use Strength?") & "%" & Localization.GetString("global_yes", "Yes") & "|" & Localization.GetString("global_no", "No") & "%"
2016-09-07 18:50:38 +02:00
End If
2023-07-30 18:16:27 +02:00
ChooseBox.CancelIndex = 1
2016-09-07 18:50:38 +02:00
Screen.TextBox.Show(text, {Me})
SoundManager.PlaySound("select")
End If
End Sub
Public Overrides Sub ResultFunction(Result As Integer)
If Result = 0 Then
Dim useP As Pokemon = Nothing
For Each p As Pokemon In Core.Player.Pokemons
If p.IsEgg() = False Then
For Each a As BattleSystem.Attack In p.Attacks
If a.Name = "Strength" Then
useP = p
Exit For
End If
Next
End If
If Not useP Is Nothing Then
Exit For
End If
Next
2023-09-13 10:46:31 +02:00
Dim pName As String = "MissingNo."
2016-09-07 18:50:38 +02:00
Dim pNumber As Integer = 23
If Not useP Is Nothing Then
pName = useP.GetDisplayName()
pNumber = useP.Number
End If
Screen.Level.UsedStrength = True
SoundManager.PlayPokemonCry(pNumber)
2023-07-30 18:16:27 +02:00
Screen.TextBox.Show(pName & " " & Localization.GetString("fieldmove_strength_used", "used~Strength!"), {}, True, False)
2016-09-07 18:50:38 +02:00
PlayerStatistics.Track("Strength used", 1)
End If
End Sub
Public Overrides Function WalkAgainstFunction() As Boolean
If Screen.Level.UsedStrength = True And Me.Moved = 0.0F Then
Dim newPosition As Vector3 = Screen.Camera.GetForwardMovedPosition()
newPosition.Y = newPosition.Y.ToInteger()
newPosition.X += Screen.Camera.GetMoveDirection().X
newPosition.Z += Screen.Camera.GetMoveDirection().Z
If CheckCollision(newPosition) = True Then
2023-03-09 17:14:56 +01:00
CType(Screen.Camera, OverworldCamera).IsPushingStrengthRock = True
2016-09-07 18:50:38 +02:00
Me.Moved = 1
Me.FaceDirection = Screen.Camera.GetPlayerFacingDirection()
2023-07-30 18:16:27 +02:00
SoundManager.PlaySound("FieldMove_Strength", False)
2016-09-07 18:50:38 +02:00
End If
End If
Return True
End Function
Private Function CheckCollision(ByVal newPosition As Vector3) As Boolean
newPosition = New Vector3(CInt(newPosition.X), CInt(newPosition.Y), CInt(newPosition.Z))
Dim HasFloor As Boolean = False
Dim Position2D As Vector3 = New Vector3(newPosition.X, newPosition.Y - 0.1F, newPosition.Z)
For Each Floor As Entity In Screen.Level.Floors
If Floor.boundingBox.Contains(Position2D) = ContainmentType.Contains Then
HasFloor = True
End If
Next
If HasFloor = False Then
Return False
End If
For Each Entity As Entity In Screen.Level.Entities
If Entity.boundingBox.Contains(newPosition) = ContainmentType.Contains Then
If Entity.Collision = True Then
Return False
End If
End If
Next
Return True
End Function
Public Overrides Sub UpdateEntity()
If Me.BaseModel Is BaseModel.getModelbyID(3) Then
If Me.Rotation.Y <> Screen.Camera.Yaw Then
Me.Rotation.Y = Screen.Camera.Yaw
CreatedWorld = False
End If
End If
2016-09-07 18:50:38 +02:00
MyBase.UpdateEntity()
End Sub
Public Overrides Sub Render()
If Me.Model Is Nothing Then
Me.Draw(Me.BaseModel, Textures, False)
Else
UpdateModel()
Draw(Me.BaseModel, Me.Textures, True, Me.Model)
End If
2016-09-07 18:50:38 +02:00
End Sub
End Class