P3D-Legacy/P3D/Pokemon/Monster/Element.vb

1033 lines
40 KiB
VB.net
Raw Normal View History

2016-09-19 03:26:44 +02:00
''' <summary>
2016-09-07 18:50:38 +02:00
''' Represents the Element of a Pokémon or move type.
''' </summary>
Public Class Element
2023-12-10 20:19:14 +01:00
Public IsGameModeElement As Boolean = False
2016-09-07 18:50:38 +02:00
''' <summary>
''' The Type an Element can be.
''' </summary>
Public Enum Types
Normal
Fighting
Flying
Poison
Ground
Rock
Bug
Ghost
Steel
Fire
Water
Grass
Electric
Psychic
Ice
Dragon
Dark
Fairy
Shadow
Blank
End Enum
Private _type As Types = Types.Blank
2023-12-10 20:19:14 +01:00
'GameMode Element Properties
Private gmType As Integer = 0
Public gmOriginalName As String = "Normal"
Public gmTypeRectangle As Rectangle = New Rectangle(0, 0, 48, 16)
Public gmMachineTextureSource As String = "Items\ItemSheet"
Public gmMachineTextureRectangle As Rectangle = New Rectangle(144, 168, 24, 24)
Public gmEffectivenessAttack As New Dictionary(Of Integer, Single)
Public gmEffectivenessDefense As New Dictionary(Of Integer, Single)
2016-09-07 18:50:38 +02:00
''' <summary>
''' The Type of this Element.
''' </summary>
2023-12-10 20:19:14 +01:00
Public Property Type As Integer
2016-09-07 18:50:38 +02:00
Get
2023-12-10 20:19:14 +01:00
If Me.IsGameModeElement = True Then
Return Me.gmType
Else
Return Me._type
End If
2016-09-07 18:50:38 +02:00
End Get
2023-12-10 20:19:14 +01:00
Set(value As Integer)
If Me.IsGameModeElement = True Then
Me.gmType = value
Else
Me._type = CType(value, Types)
End If
2016-09-07 18:50:38 +02:00
End Set
End Property
2023-12-10 20:19:14 +01:00
''' <summary>
''' Creates a new instance of the Element class for GameMode Elements.
''' </summary>
'''
Public Sub New()
End Sub
2016-09-07 18:50:38 +02:00
''' <summary>
''' Creates a new instance of the Element class.
''' </summary>
''' <param name="TypeID">The ID of the type.</param>
Public Sub New(ByVal TypeID As Integer)
Select Case TypeID
Case 0
Me._type = Types.Normal
Case 1
Me._type = Types.Fighting
Case 2
Me._type = Types.Flying
Case 3
Me._type = Types.Poison
Case 4
Me._type = Types.Ground
Case 5
Me._type = Types.Rock
Case 6
Me._type = Types.Bug
Case 7
Me._type = Types.Ghost
Case 8
Me._type = Types.Steel
Case 9
Me._type = Types.Fire
Case 10
Me._type = Types.Water
Case 11
Me._type = Types.Grass
Case 12
Me._type = Types.Electric
Case 13
Me._type = Types.Psychic
Case 14
Me._type = Types.Ice
Case 15
Me._type = Types.Dragon
Case 16
Me._type = Types.Dark
Case 17
Me._type = Types.Blank
Case 18
Me._type = Types.Fairy
End Select
End Sub
''' <summary>
''' Creates a new instance of the Element class.
''' </summary>
''' <param name="Type">The Type as string.</param>
Public Sub New(ByVal Type As String)
Select Case Type.ToLower()
Case "normal"
Me._type = Types.Normal
Case "fighting"
Me._type = Types.Fighting
Case "flying"
Me._type = Types.Flying
Case "poison"
Me._type = Types.Poison
Case "ground"
Me._type = Types.Ground
Case "rock"
Me._type = Types.Rock
Case "bug"
Me._type = Types.Bug
Case "ghost"
Me._type = Types.Ghost
Case "steel"
Me._type = Types.Steel
Case "fire"
Me._type = Types.Fire
Case "water"
Me._type = Types.Water
Case "grass"
Me._type = Types.Grass
Case "electric"
Me._type = Types.Electric
Case "psychic"
Me._type = Types.Psychic
Case "ice"
Me._type = Types.Ice
Case "dragon"
Me._type = Types.Dragon
Case "dark"
Me._type = Types.Dark
Case "fairy"
Me._type = Types.Fairy
Case "shadow"
Me._type = Types.Shadow
Case "blank"
Me._type = Types.Blank
Case Else
Me._type = Types.Blank
End Select
End Sub
''' <summary>
''' Creates a new instance of the Element class.
''' </summary>
''' <param name="Type">The Type to set this Element to.</param>
Public Sub New(ByVal Type As Types)
Me._type = Type
End Sub
''' <summary>
''' Returns a multiplier which represents the connection between an attacking and a defending element.
''' </summary>
''' <param name="AttackElement">The attacking element.</param>
''' <param name="DefenseElement">The defending element.</param>
Public Shared Function GetElementMultiplier(ByVal AttackElement As Element, ByVal DefenseElement As Element) As Single
Dim a As Element = AttackElement
Dim d As Element = DefenseElement
If d Is Nothing Or a Is Nothing Then
Return 1
End If
2023-12-10 20:19:14 +01:00
If d.Type = Types.Blank Or a.Type = Types.Blank Then
2016-09-07 18:50:38 +02:00
Return 1
End If
2023-12-10 20:19:14 +01:00
If a.IsGameModeElement = False Then
If d.IsGameModeElement = False Then
Select Case a.Type
2016-09-07 18:50:38 +02:00
Case Types.Normal
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 0.5F
Case Types.Bug
Return 1
Case Types.Ghost
Return 0
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Fighting
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 2
Case Types.Fighting
Return 1
Case Types.Flying
Return 0.5F
Case Types.Poison
Return 0.5F
Case Types.Ground
Return 1
Case Types.Rock
Return 2
Case Types.Bug
Return 0.5F
Case Types.Ghost
Return 0
Case Types.Steel
Return 2
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 0.5F
Case Types.Ice
Return 2
Case Types.Dragon
Return 1
Case Types.Dark
Return 2
Case Types.Fairy
Return 0.5F
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Flying
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 2
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 0.5F
Case Types.Bug
Return 2
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 2
Case Types.Electric
Return 0.5F
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Poison
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 0.5F
Case Types.Ground
Return 0.5F
Case Types.Rock
Return 0.5F
Case Types.Bug
Return 1
Case Types.Ghost
Return 0.5F
Case Types.Steel
Return 0
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 2
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Types.Fairy
Return 2
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Ground
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 0
Case Types.Poison
Return 2
Case Types.Ground
Return 1
Case Types.Rock
Return 2
Case Types.Bug
Return 0.5F
Case Types.Ghost
Return 1
Case Types.Steel
Return 2
Case Types.Fire
Return 2
Case Types.Water
Return 1
Case Types.Grass
Return 0.5F
Case Types.Electric
Return 2
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Rock
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 0.5F
Case Types.Flying
Return 2
Case Types.Poison
Return 1
Case Types.Ground
Return 0.5F
Case Types.Rock
Return 1
Case Types.Bug
Return 2
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 2
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 2
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Bug
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 0.5F
Case Types.Flying
Return 0.5F
Case Types.Poison
Return 0.5F
Case Types.Ground
Return 1
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 0.5F
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 0.5F
Case Types.Water
Return 1
Case Types.Grass
Return 2
Case Types.Electric
Return 1
Case Types.Psychic
Return 2
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 2
Case Types.Fairy
Return 0.5F
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Ghost
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 0
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 2
Case Types.Steel
Return 1
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 2
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 0.5F
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Steel
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 2
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 0.5F
Case Types.Water
Return 0.5F
Case Types.Grass
Return 1
Case Types.Electric
Return 0.5F
Case Types.Psychic
Return 1
Case Types.Ice
Return 2
Case Types.Dragon
Return 1
Case Types.Dark
Return 1
Case Types.Fairy
Return 2
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Fire
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 0.5F
Case Types.Bug
Return 2
Case Types.Ghost
Return 1
Case Types.Steel
Return 2
Case Types.Fire
Return 0.5F
Case Types.Water
Return 0.5F
Case Types.Grass
Return 2
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 2
Case Types.Dragon
Return 0.5F
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Water
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 2
Case Types.Rock
Return 2
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 1
Case Types.Fire
Return 2
Case Types.Water
Return 0.5F
Case Types.Grass
Return 0.5F
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 0.5F
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Grass
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 0.5F
Case Types.Poison
Return 0.5F
Case Types.Ground
Return 2
Case Types.Rock
Return 2
Case Types.Bug
Return 0.5F
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 0.5F
Case Types.Water
Return 2
Case Types.Grass
Return 0.5F
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 0.5F
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Electric
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 2
Case Types.Poison
Return 1
Case Types.Ground
Return 0
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 1
Case Types.Fire
Return 1
Case Types.Water
Return 2
Case Types.Grass
Return 0.5F
Case Types.Electric
Return 0.5F
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 0.5F
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Psychic
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 2
Case Types.Flying
Return 1
Case Types.Poison
Return 2
Case Types.Ground
Return 1
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 0.5F
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 0
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Ice
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 2
Case Types.Poison
Return 1
Case Types.Ground
Return 2
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 0.5F
Case Types.Water
Return 0.5F
Case Types.Grass
Return 2
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 0.5F
Case Types.Dragon
Return 2
Case Types.Dark
Return 1
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Dragon
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 1
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 1
Case Types.Steel
Return 0.5F
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 1
Case Types.Ice
Return 1
Case Types.Dragon
Return 2
Case Types.Dark
Return 1
Case Types.Fairy
Return 0
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Dark
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Normal
Return 1
Case Types.Fighting
Return 0.5F
Case Types.Flying
Return 1
Case Types.Poison
Return 1
Case Types.Ground
Return 1
Case Types.Rock
Return 1
Case Types.Bug
Return 1
Case Types.Ghost
Return 2
Case Types.Steel
Return 1
Case Types.Fire
Return 1
Case Types.Water
Return 1
Case Types.Grass
Return 1
Case Types.Electric
Return 1
Case Types.Psychic
Return 2
Case Types.Ice
Return 1
Case Types.Dragon
Return 1
Case Types.Dark
Return 0.5F
Case Types.Fairy
Return 0.5F
Case Else
Return 1
End Select
2016-09-07 18:50:38 +02:00
Case Types.Fairy
2023-12-10 20:19:14 +01:00
Select Case d.Type
Case Types.Fire
Return 0.5F
Case Types.Fighting
Return 2.0F
Case Types.Poison
Return 0.5F
Case Types.Dragon
Return 2.0F
Case Types.Dark
Return 2.0F
Case Types.Steel
Return 0.5F
End Select
Case Types.Shadow
Select Case d.Type
Case Types.Shadow
Return 0.5F
Case Else
Return 2
End Select
2016-09-07 18:50:38 +02:00
Case Else
Return 1
End Select
2023-12-10 20:19:14 +01:00
Else
If d.gmEffectivenessDefense.ContainsKey(a.Type) Then
Return d.gmEffectivenessDefense(a.Type)
End If
End If
Else
If a.gmEffectivenessDefense.ContainsKey(d.Type) Then
Return a.gmEffectivenessDefense(d.Type)
End If
End If
2016-09-07 18:50:38 +02:00
Return 1
End Function
''' <summary>
''' Returns the rectangle from the texture "GUI\Menus\Types" that represents the Type of this Element.
''' </summary>
Public Function GetElementImage() As Rectangle
Dim r As New Rectangle(0, 0, 0, 0)
2023-12-10 20:19:14 +01:00
If Me.IsGameModeElement = False Then
Select Case Me._type
Case Types.Normal
r = New Rectangle(0, 0, 48, 16)
Case Types.Grass
r = New Rectangle(0, 16, 48, 16)
Case Types.Fire
r = New Rectangle(0, 32, 48, 16)
Case Types.Water
r = New Rectangle(0, 48, 48, 16)
Case Types.Electric
r = New Rectangle(0, 64, 48, 16)
Case Types.Ground
r = New Rectangle(0, 80, 48, 16)
Case Types.Rock
r = New Rectangle(0, 96, 48, 16)
Case Types.Ice
r = New Rectangle(0, 112, 48, 16)
Case Types.Steel
r = New Rectangle(0, 128, 48, 16)
Case Types.Bug
r = New Rectangle(48, 0, 48, 16)
Case Types.Fighting
r = New Rectangle(48, 16, 48, 16)
Case Types.Flying
r = New Rectangle(48, 32, 48, 16)
Case Types.Poison
r = New Rectangle(48, 48, 48, 16)
Case Types.Ghost
r = New Rectangle(48, 64, 48, 16)
Case Types.Dark
r = New Rectangle(48, 80, 48, 16)
Case Types.Psychic
r = New Rectangle(48, 96, 48, 16)
Case Types.Dragon
r = New Rectangle(48, 128, 48, 16)
Case Types.Fairy
r = New Rectangle(96, 48, 48, 16)
Case Types.Shadow
r = New Rectangle(96, 64, 48, 16)
Case Types.Blank
r = New Rectangle(48, 112, 48, 16)
Case Else
r = New Rectangle(48, 112, 48, 16)
End Select
Else
r = gmTypeRectangle
End If
2016-09-07 18:50:38 +02:00
Return r
End Function
Public Overrides Function ToString() As String
2023-12-10 20:19:14 +01:00
If IsGameModeElement = False Then
Select Case Me._type
Case Types.Blank
Return "Blank"
Case Types.Bug
Return "Bug"
Case Types.Dark
Return "Dark"
Case Types.Dragon
Return "Dragon"
Case Types.Electric
Return "Electric"
Case Types.Fairy
Return "Fairy"
Case Types.Fighting
Return "Fighting"
Case Types.Fire
Return "Fire"
Case Types.Flying
Return "Flying"
Case Types.Ghost
Return "Ghost"
Case Types.Grass
Return "Grass"
Case Types.Ground
Return "Ground"
Case Types.Ice
Return "Ice"
Case Types.Normal
Return "Normal"
Case Types.Poison
Return "Poison"
Case Types.Psychic
Return "Psychic"
Case Types.Rock
Return "Rock"
Case Types.Shadow
Return "Shadow"
Case Types.Steel
Return "Steel"
Case Types.Water
Return "Water"
Case Else
Return "Blank"
End Select
Else
If Localization.TokenExists("type_" & gmOriginalName) = True Then
Return Localization.GetString("type_" & gmOriginalName, gmOriginalName)
Else
Return gmOriginalName
End If
2023-12-10 20:19:14 +01:00
End If
2016-09-07 18:50:38 +02:00
End Function
Public Shared Operator =(ByVal Element1 As Element, ByVal Element2 As Element) As Boolean
2023-12-10 20:19:14 +01:00
Return Element1.Type = Element2.Type
2016-09-07 18:50:38 +02:00
End Operator
Public Shared Operator <>(ByVal Element1 As Element, ByVal Element2 As Element) As Boolean
2023-12-10 20:19:14 +01:00
Return Element1.Type <> Element2.Type
2016-09-07 18:50:38 +02:00
End Operator
2016-09-19 03:26:44 +02:00
End Class