P3D-Legacy/P3D/Screens/Pokemon/TeachMovesScreen.vb

223 lines
7.9 KiB
VB.net
Raw Normal View History

2016-09-07 18:50:38 +02:00
Public Class TeachMovesScreen
Inherits Screen
Dim MovesList As New List(Of BattleSystem.Attack)
Dim Pokemon As Pokemon
Dim mainTexture As Texture2D
Dim index As Integer = 0
Dim scrollIndex As Integer = 0
Public Shared LearnedMove As Boolean = False
Public Sub New(ByVal currentScreen As Screen, ByVal PokemonIndex As Integer)
Me.PreScreen = currentScreen
Me.Pokemon = Core.Player.Pokemons(PokemonIndex)
Me.Identification = Identifications.TeachMovesScreen
For i = 0 To Pokemon.AttackLearns.Count - 1
Dim tutorMove As BattleSystem.Attack = Pokemon.AttackLearns.Values(i)
Dim learnLevel As Integer = Pokemon.AttackLearns.Keys(i)
If learnLevel <= Pokemon.Level Then
Dim canLearnMove As Boolean = True
2016-09-07 18:50:38 +02:00
For Each learnedAttack As BattleSystem.Attack In Pokemon.Attacks
If learnedAttack.ID = tutorMove.ID Then
canLearnMove = False
End If
Next
For Each move As BattleSystem.Attack In MovesList
If move.ID = tutorMove.ID Then
canLearnMove = False
End If
Next
If canLearnMove = True Then
MovesList.Add(tutorMove)
End If
End If
2016-09-07 18:50:38 +02:00
Next
Me.MouseVisible = False
Me.CanBePaused = True
Me.CanMuteAudio = True
2016-09-07 18:50:38 +02:00
LearnedMove = False
Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu")
End Sub
Public Sub New(ByVal currentScreen As Screen, ByVal PokemonIndex As Integer, ByVal MovesList() As BattleSystem.Attack)
Me.PreScreen = currentScreen
Me.Pokemon = Core.Player.Pokemons(PokemonIndex)
Me.Identification = Identifications.TeachMovesScreen
For Each a As BattleSystem.Attack In MovesList
Dim canLearnMove As Boolean = False
For Each tutorMove As BattleSystem.Attack In Pokemon.TutorAttacks
If a.ID = tutorMove.ID Then
canLearnMove = True
End If
Next
For i = 0 To Pokemon.AttackLearns.Count - 1
Dim learnAttack As BattleSystem.Attack = Pokemon.AttackLearns.Values(i)
If learnAttack.ID = a.ID Then
canLearnMove = True
End If
Next
For Each eggMoveID As Integer In Pokemon.EggMoves
If eggMoveID = a.ID Then
canLearnMove = True
End If
Next
For Each TMMoveID As Integer In Pokemon.Machines
If TMMoveID = a.ID Then
canLearnMove = True
End If
Next
For Each learnedAttack As BattleSystem.Attack In Pokemon.Attacks
If learnedAttack.ID = a.ID Then
canLearnMove = False
End If
Next
For Each move As BattleSystem.Attack In Me.MovesList
If move.ID = a.ID Then
canLearnMove = False
End If
Next
If canLearnMove = True Then
Me.MovesList.Add(a)
End If
Next
Me.MouseVisible = False
Me.CanBePaused = True
Me.CanMuteAudio = True
2016-09-07 18:50:38 +02:00
LearnedMove = False
Me.mainTexture = TextureManager.GetTexture("GUI\Menus\Menu")
End Sub
Public Overrides Sub Draw()
Me.PreScreen.Draw()
Canvas.DrawImageBorder(TextureManager.GetTexture(mainTexture, New Rectangle(0, 0, 48, 48)), 2, New Rectangle(60, 100, 800, 480))
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.Draw(Pokemon.GetTexture(True), New Rectangle(80, 100, 128, 128), Color.White)
Core.SpriteBatch.DrawString(FontManager.MiniFont, Pokemon.GetDisplayName() & Environment.NewLine & "Level: " & Pokemon.Level, New Vector2(80, 260), Color.Black)
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.DrawString(FontManager.MiniFont, "Pokémon's moves:", New Vector2(245, 140), Color.Black)
For i = 0 To Pokemon.Attacks.Count - 1
If i <= Pokemon.Attacks.Count - 1 Then
DrawAttack(245, i, Pokemon.Attacks(i), False)
End If
Next
If Me.MovesList.Count = 0 Then
Core.SpriteBatch.DrawString(FontManager.MiniFont, "The Pokémon cannot learn" & Environment.NewLine & "a new move here.", New Vector2(580, 140), Color.Black)
2016-09-07 18:50:38 +02:00
Else
Core.SpriteBatch.DrawString(FontManager.MiniFont, "Tutor moves (" & MovesList.Count & "):", New Vector2(580, 140), Color.Black)
For i = scrollIndex To scrollIndex + 3
If i <= MovesList.Count - 1 Then
DrawAttack(580, i, MovesList(i), True)
End If
Next
End If
Dim d As New Dictionary(Of Buttons, String)
d.Add(Buttons.A, "Learn")
d.Add(Buttons.B, "Close")
DrawGamePadControls(d)
End Sub
Private Sub DrawAttack(ByVal x As Integer, ByVal i As Integer, ByVal A As BattleSystem.Attack, ByVal isLearnMove As Boolean)
Dim y As Integer = i - scrollIndex
If isLearnMove = False Then
y = i
End If
Dim p As New Vector2(x, 160 + y * (64 + 32))
Dim CanvasTexture As Texture2D = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 0, 48, 48), "")
If Me.index = i And isLearnMove = True Then
CanvasTexture = TextureManager.GetTexture("GUI\Menus\Menu", New Rectangle(0, 48, 48, 48), "")
End If
Canvas.DrawImageBorder(CanvasTexture, 2, New Rectangle(CInt(p.X - 18), CInt(p.Y), 256, 64))
With Core.SpriteBatch
.DrawString(FontManager.MiniFont, A.Name, New Vector2(p.X, CInt(p.Y + 26)), Color.Black)
Dim c As Color = Color.Black
Dim per As Integer = CInt((A.CurrentPP / A.MaxPP) * 100)
If per <= 33 And per > 10 Then
c = Color.Orange
ElseIf per <= 10 Then
c = Color.IndianRed
End If
.DrawString(FontManager.MiniFont, Localization.GetString("PP") & " " & A.CurrentPP & " / " & A.MaxPP, New Vector2(p.X + 130, CInt(p.Y + 58)), c)
.Draw(TextureManager.GetTexture("GUI\Menus\Types", A.Type.GetElementImage(), ""), New Rectangle(CInt(p.X), CInt(p.Y + 54), 48, 16), Color.White)
End With
End Sub
Public Overrides Sub Update()
If Controls.Up(True, True, True, True, True) = True Then
Me.index -= 1
End If
If Controls.Down(True, True, True, True, True) = True Then
Me.index += 1
End If
index = index.Clamp(0, Me.MovesList.Count - 1)
If index - scrollIndex > 3 Then
scrollIndex += 1
End If
If index - scrollIndex < 0 Then
scrollIndex -= 1
End If
If Controls.Accept(True, True, True) = True Then
If Me.MovesList.Count = 0 Then
Core.SetScreen(Me.PreScreen)
Fix audio engine & contentpacks (#35) * Replaced existing Gen 2 SFX with better sounding ones (no ugly reverb) Replaced MediaPlayer with NAudio(and NAudio.Vorbis) for playing music in order to fix random stopping issues. The game now directly loads .ogg files instead of the .wma/.xnb combination from before. ContentPacks are now able to replace Music and SFX again (I haven't added a menu yet for choosing ContentPacks). To make older GameModes work with current versions, you can add the GameMode property EnterType and set it to "1", this will make the game use the older 2D NewGameScreen. * Delete GameController.vb * Add gamecontroller.vb back * Fix sfx missing * Battleintro doodle now doesn't loop anymore (for no trainer) Changed the shutter sound (aka Large Door sound) to something more large door-y Made the enter sound slightly louder The enter sound now plays when going through any warp to or from an indoor map (including falling through holes) The flying sound effect is played earlier in the animation after selecting a location Changed played sound effect when using the Escape Rope to "teleport" instead of "destroy" The bump noise now also plays when bumping into something in first person Fixed small gap between the end of the intro song and the start of the main song Replaced some songs with better songs * Fixed some more intro issues * Forgot to change a thing * Fixed an error where the main music would play, ignoring the muted musicmanager. * fix indenting in musicmanager * The music player will now only start playback on a new song if the music player is not muted, fixed the end time calculation of the intro of a song after muting, Music can't be unmuted now as long as a sound effect plays that stops the music. * Fixed league restplace position, fixed sound effects sharing the volume slider of the music, sound effects are now also muted when pressing M, changed music on/off popup to audio on/off, removed bump delay in first person, added more control on whether played songs should be looping or not. * Fixed some more scripts that turn on thirdperson mode but don't check if it was on before or set it back to what it was before afterwards, also fixed a small error in creditsscreen.vb. * Fixed indenting error in musicmanager.vb, fixed an error of mine where the loopsong parameter would be seen as the playintro parameter. * Added more music commands, added quite some menu select noises, will add more later * More select sound effects! * Fix music not resuming after soundeffect * Trainer using item now plays the single_heal soundeffect * Pokémon cries now sound louder * Possibly fixing crash when playing Pokémon cry at volume higher than 0.71 * Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720. * Sound effects now sound louder * Revert "Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720." This reverts commit 8c9296ed1a82144d17f303a52c3f2e9e65a5bfea. * Fixed the cause of why the title screen music plays even when the game is muted * Tabs to spaces * Revert Co-authored-by: darkfire006 <blazer257@live.com> Co-authored-by: JappaWakkaP3D <66885565+JappaWakkaP3D@users.noreply.github.com> Co-authored-by: JappaWakkaP3D <jasper.speelman@outlook.com> Co-authored-by: Vitaly Mikhailov <personal@aragas.org>
2020-07-09 19:59:42 +02:00
SoundManager.PlaySound("select")
2016-09-07 18:50:38 +02:00
Else
LearnMove(MovesList(index))
Fix audio engine & contentpacks (#35) * Replaced existing Gen 2 SFX with better sounding ones (no ugly reverb) Replaced MediaPlayer with NAudio(and NAudio.Vorbis) for playing music in order to fix random stopping issues. The game now directly loads .ogg files instead of the .wma/.xnb combination from before. ContentPacks are now able to replace Music and SFX again (I haven't added a menu yet for choosing ContentPacks). To make older GameModes work with current versions, you can add the GameMode property EnterType and set it to "1", this will make the game use the older 2D NewGameScreen. * Delete GameController.vb * Add gamecontroller.vb back * Fix sfx missing * Battleintro doodle now doesn't loop anymore (for no trainer) Changed the shutter sound (aka Large Door sound) to something more large door-y Made the enter sound slightly louder The enter sound now plays when going through any warp to or from an indoor map (including falling through holes) The flying sound effect is played earlier in the animation after selecting a location Changed played sound effect when using the Escape Rope to "teleport" instead of "destroy" The bump noise now also plays when bumping into something in first person Fixed small gap between the end of the intro song and the start of the main song Replaced some songs with better songs * Fixed some more intro issues * Forgot to change a thing * Fixed an error where the main music would play, ignoring the muted musicmanager. * fix indenting in musicmanager * The music player will now only start playback on a new song if the music player is not muted, fixed the end time calculation of the intro of a song after muting, Music can't be unmuted now as long as a sound effect plays that stops the music. * Fixed league restplace position, fixed sound effects sharing the volume slider of the music, sound effects are now also muted when pressing M, changed music on/off popup to audio on/off, removed bump delay in first person, added more control on whether played songs should be looping or not. * Fixed some more scripts that turn on thirdperson mode but don't check if it was on before or set it back to what it was before afterwards, also fixed a small error in creditsscreen.vb. * Fixed indenting error in musicmanager.vb, fixed an error of mine where the loopsong parameter would be seen as the playintro parameter. * Added more music commands, added quite some menu select noises, will add more later * More select sound effects! * Fix music not resuming after soundeffect * Trainer using item now plays the single_heal soundeffect * Pokémon cries now sound louder * Possibly fixing crash when playing Pokémon cry at volume higher than 0.71 * Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720. * Sound effects now sound louder * Revert "Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720." This reverts commit 8c9296ed1a82144d17f303a52c3f2e9e65a5bfea. * Fixed the cause of why the title screen music plays even when the game is muted * Tabs to spaces * Revert Co-authored-by: darkfire006 <blazer257@live.com> Co-authored-by: JappaWakkaP3D <66885565+JappaWakkaP3D@users.noreply.github.com> Co-authored-by: JappaWakkaP3D <jasper.speelman@outlook.com> Co-authored-by: Vitaly Mikhailov <personal@aragas.org>
2020-07-09 19:59:42 +02:00
SoundManager.PlaySound("select")
2016-09-07 18:50:38 +02:00
End If
End If
If Controls.Dismiss(True, True, True) = True Then
Core.SetScreen(Me.PreScreen)
Fix audio engine & contentpacks (#35) * Replaced existing Gen 2 SFX with better sounding ones (no ugly reverb) Replaced MediaPlayer with NAudio(and NAudio.Vorbis) for playing music in order to fix random stopping issues. The game now directly loads .ogg files instead of the .wma/.xnb combination from before. ContentPacks are now able to replace Music and SFX again (I haven't added a menu yet for choosing ContentPacks). To make older GameModes work with current versions, you can add the GameMode property EnterType and set it to "1", this will make the game use the older 2D NewGameScreen. * Delete GameController.vb * Add gamecontroller.vb back * Fix sfx missing * Battleintro doodle now doesn't loop anymore (for no trainer) Changed the shutter sound (aka Large Door sound) to something more large door-y Made the enter sound slightly louder The enter sound now plays when going through any warp to or from an indoor map (including falling through holes) The flying sound effect is played earlier in the animation after selecting a location Changed played sound effect when using the Escape Rope to "teleport" instead of "destroy" The bump noise now also plays when bumping into something in first person Fixed small gap between the end of the intro song and the start of the main song Replaced some songs with better songs * Fixed some more intro issues * Forgot to change a thing * Fixed an error where the main music would play, ignoring the muted musicmanager. * fix indenting in musicmanager * The music player will now only start playback on a new song if the music player is not muted, fixed the end time calculation of the intro of a song after muting, Music can't be unmuted now as long as a sound effect plays that stops the music. * Fixed league restplace position, fixed sound effects sharing the volume slider of the music, sound effects are now also muted when pressing M, changed music on/off popup to audio on/off, removed bump delay in first person, added more control on whether played songs should be looping or not. * Fixed some more scripts that turn on thirdperson mode but don't check if it was on before or set it back to what it was before afterwards, also fixed a small error in creditsscreen.vb. * Fixed indenting error in musicmanager.vb, fixed an error of mine where the loopsong parameter would be seen as the playintro parameter. * Added more music commands, added quite some menu select noises, will add more later * More select sound effects! * Fix music not resuming after soundeffect * Trainer using item now plays the single_heal soundeffect * Pokémon cries now sound louder * Possibly fixing crash when playing Pokémon cry at volume higher than 0.71 * Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720. * Sound effects now sound louder * Revert "Added better quality Pokémon cries, made random overworld cries slightly less loud, added cries for 719 and 720." This reverts commit 8c9296ed1a82144d17f303a52c3f2e9e65a5bfea. * Fixed the cause of why the title screen music plays even when the game is muted * Tabs to spaces * Revert Co-authored-by: darkfire006 <blazer257@live.com> Co-authored-by: JappaWakkaP3D <66885565+JappaWakkaP3D@users.noreply.github.com> Co-authored-by: JappaWakkaP3D <jasper.speelman@outlook.com> Co-authored-by: Vitaly Mikhailov <personal@aragas.org>
2020-07-09 19:59:42 +02:00
SoundManager.PlaySound("select")
2016-09-07 18:50:38 +02:00
End If
End Sub
Private Sub LearnMove(ByVal a As BattleSystem.Attack)
If Pokemon.Attacks.Count < 4 Then
LearnedMove = True
Pokemon.Attacks.Add(BattleSystem.Attack.GetAttackByID(a.ID))
TextBox.Show("... " & Pokemon.GetDisplayName() & " learned~" & a.Name & "!")
SoundManager.PlaySound("success_small", False)
Core.SetScreen(Me.PreScreen)
2016-09-07 18:50:38 +02:00
Else
Core.SetScreen(New LearnAttackScreen(Core.CurrentScreen.PreScreen, Me.Pokemon, BattleSystem.Attack.GetAttackByID(a.ID)))
End If
End Sub
End Class