P3D-Legacy/P3D/Screens/BattleIntroScreen.vb

597 lines
28 KiB
VB.net
Raw Normal View History

2016-09-07 18:50:38 +02:00
Public Class BattleIntroScreen
Inherits Screen
Dim oldX, oldY As Integer
Dim AnimationType As Integer
Dim Animations As New List(Of Rectangle)
Public OldScreen As Screen
Public NewScreen As Screen
Dim ready As Boolean = False
Dim value As Integer = 0
Dim Trainer As Trainer
Dim minDelay As Single = 4.0F
2016-09-07 18:50:38 +02:00
Dim startTime As Date
Dim duration As TimeSpan
Public MusicLoop As String = ""
Public Sub New(ByVal OldScreen As Screen, ByVal NewScreen As Screen, ByVal IntroType As Integer)
Dim musicLoop As String = Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild_intro"
2021-10-26 23:43:23 +02:00
If Not BattleSystem.BattleScreen.CustomBattleMusic = "" OrElse MusicManager.SongExists(BattleSystem.BattleScreen.CustomBattleMusic) = True Then
musicLoop = BattleSystem.BattleScreen.CustomBattleMusic & "_intro"
Else
If BattleSystem.BattleScreen.RoamingBattle = True Then
If BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop <> "" Then
musicLoop = BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop & "_intro"
End If
2016-09-07 18:50:38 +02:00
End If
End If
If MusicManager.SongExists(musicLoop) = False Then
musicLoop = "johto_wild_intro"
End If
Me.Constructor(OldScreen, NewScreen, Nothing, musicLoop, IntroType)
End Sub
Public Sub New(ByVal OldScreen As Screen, ByVal NewScreen As Screen, ByVal IntroType As Integer, ByVal MusicLoop As String)
If MusicLoop = "" Then
MusicLoop = Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild_intro"
2022-04-19 18:13:18 +02:00
If MusicManager.SongExists(MusicLoop) = True Then
2016-09-07 18:50:38 +02:00
If BattleSystem.BattleScreen.RoamingBattle = True Then
If BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop <> "" Then
MusicLoop = BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop & "_intro"
End If
End If
End If
2022-04-19 18:13:18 +02:00
If MusicManager.SongExists(MusicLoop) = False Then
MusicLoop = "johto_wild_intro"
End If
End If
2016-09-07 18:50:38 +02:00
Me.Constructor(OldScreen, NewScreen, Nothing, MusicLoop, IntroType)
End Sub
Public Sub New(ByVal OldScreen As Screen, ByVal NewScreen As Screen, ByVal Trainer As Trainer, ByVal MusicLoop As String, ByVal IntroType As Integer)
Me.Constructor(OldScreen, NewScreen, Trainer, MusicLoop, IntroType)
End Sub
Private Sub Constructor(ByVal OldScreen As Screen, ByVal NewScreen As Screen, ByVal Trainer As Trainer, ByVal MusicLoop As String, ByVal IntroType As Integer)
Me.OldScreen = OldScreen
Me.NewScreen = NewScreen
Me.CanChat = False
Me.CanBePaused = False
Me.Trainer = Trainer
Me.MusicLoop = MusicLoop
Me.AnimationType = IntroType
If Screen.Level.IsDark = True And Me.AnimationType > 4 Then
Me.AnimationType -= 5
End If
Me.Identification = Identifications.BattleIniScreen
End Sub
Public Overrides Sub Draw()
OldScreen.Draw()
Dim c As Color = Color.Black
If AnimationType > 4 Then
c = Color.White
End If
Select Case AnimationType
Case 0, 1, 2, 3, 5, 6, 7, 8
For Each Animation As Rectangle In Animations
Canvas.DrawRectangle(Animation, c)
Next
Case 4, 9
For Each Animation As Rectangle In Animations
Canvas.DrawBorder(value, Animation, c)
Next
Case 10
DrawTrainerIntro()
Case 11
DrawFaceshotIntro()
Case 12
DrawBlurIntro()
End Select
End Sub
Dim blurTexture As Texture2D = Nothing
Dim blurLayers As New List(Of Rectangle)
Dim whiteLayers As New List(Of Rectangle)
Dim blurDelay As Single = 0.5F
Dim currentBlurPosition As New Vector2(0.0F)
Dim currentBlurIntensity As Single = 10.0F
Dim currentBlurZoom As Integer = 0
Private Sub DrawBlurIntro()
If Not blurTexture Is Nothing Then
Dim startIndex As Integer = 0
If blurLayers.Count > 10 Then
startIndex = blurLayers.Count - 10
End If
For i = startIndex To blurLayers.Count - 1
Dim usedZoom As Integer = blurLayers(i).Width - Core.windowSize.Width
Dim rot As Single = CSng(Math.Sin(usedZoom * 0.01F) * 0.1F)
Dim r As Rectangle = blurLayers(i)
Dim origin As New Vector2(Core.windowSize.Width / 2.0F, Core.windowSize.Height / 2.0F)
Core.SpriteBatch.Draw(blurTexture, New Rectangle(r.X + CInt(r.Width / 2), r.Y + CInt(r.Height / 2), r.Width, r.Height), Nothing, New Color(255, 255, 255, 100), rot, origin, SpriteEffects.None, 0.0F)
Next
For i = 0 To Me.whiteLayers.Count - 1
Canvas.DrawRectangle(New Rectangle(0, 0, Core.windowSize.Width, Core.windowSize.Height), New Color(255, 255, 255, 50))
Next
End If
End Sub
Private Sub UpdateBlurIntro()
If blurTexture Is Nothing Then
Dim r As New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height)
Core.GraphicsDevice.SetRenderTarget(r)
Core.Draw()
Core.GraphicsDevice.SetRenderTarget(Nothing)
blurTexture = r
End If
blurDelay -= 0.1F
If blurDelay <= 0.0F Then
blurDelay = 0.5F
If Core.Random.Next(0, 75) < Me.currentBlurIntensity Then
Me.whiteLayers.Add(Core.windowSize)
End If
Dim v As New Vector2(Core.Random.Next(CInt(currentBlurPosition.X - currentBlurIntensity), CInt(currentBlurPosition.X + currentBlurIntensity)), Core.Random.Next(CInt(currentBlurPosition.Y - currentBlurIntensity), CInt(currentBlurPosition.Y + currentBlurIntensity)))
Me.blurLayers.Add(New Rectangle(CInt(v.X - (currentBlurZoom / 2)), CInt(v.Y - (currentBlurZoom / 2)), Core.windowSize.Width + currentBlurZoom, Core.windowSize.Height + currentBlurZoom))
Me.currentBlurIntensity += 2
Me.currentBlurZoom += 55
End If
If Me.currentBlurIntensity = 80 Or SongOver() = True Then
ready = True
End If
End Sub
Dim animationAfterReady As Integer = 0
Private Sub DrawTrainerIntro()
Dim barPosition As Vector2 = New Vector2(Trainer.BarImagePosition.X * 128, Trainer.BarImagePosition.Y * 128)
Dim VSPosition As Vector2 = New Vector2(Trainer.VSImagePosition.X * 128, Trainer.VSImagePosition.Y * 128 + 64)
Dim TrainerTexture1 As Texture2D = TextureManager.GetTexture("Textures\NPC\" & Trainer.SpriteName)
Dim TrainerTexture2 As Texture2D = Nothing
Dim Trainer1FrameSize As Size = Nothing
Dim Trainer2FrameSize As Size = Nothing
2016-09-07 18:50:38 +02:00
If Trainer.VSImageOrigin <> "VSIntro" Then
VSPosition.Y -= 64
End If
If TrainerTexture1.Width = TrainerTexture1.Height / 2 Then
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 2), CInt(TrainerTexture1.Height / 4))
ElseIf TrainerTexture1.Width = TrainerTexture1.Height Then
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 4), CInt(TrainerTexture1.Height / 4))
Else
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 3), CInt(TrainerTexture1.Height / 4))
End If
2016-09-07 18:50:38 +02:00
Dim t1 As Texture2D = TextureManager.GetTexture("GUI\Intro\VSIntro", New Rectangle(CInt(barPosition.X), CInt(barPosition.Y), 128, 64), "")
Dim t2 As Texture2D = TextureManager.GetTexture("GUI\Intro\" & Trainer.VSImageOrigin, New Rectangle(CInt(VSPosition.X), CInt(VSPosition.Y), Trainer.VSImageSize.Width, Trainer.VSImageSize.Height), "")
Dim t3 As Texture2D = TextureManager.GetTexture("NPC\" & Trainer.SpriteName, New Rectangle(0, Trainer1FrameSize.Height * 2, Trainer1FrameSize.Width, Trainer1FrameSize.Height))
2016-09-07 18:50:38 +02:00
Dim t4 As Texture2D = Nothing
If Trainer.DoubleTrainer = True Then
TrainerTexture2 = TextureManager.GetTexture("Textures\NPC\" & Trainer.SpriteName2)
If TrainerTexture1.Width = TrainerTexture1.Height / 2 Then
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 2), CInt(TrainerTexture2.Height / 4))
ElseIf TrainerTexture1.Width = TrainerTexture1.Height Then
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 4), CInt(TrainerTexture2.Height / 4))
Else
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 3), CInt(TrainerTexture2.Height / 4))
End If
t4 = TextureManager.GetTexture("NPC\" & Trainer.SpriteName2, New Rectangle(0, Trainer2FrameSize.Height * 2, Trainer2FrameSize.Width, Trainer2FrameSize.Height))
2016-09-07 18:50:38 +02:00
End If
If Trainer.GameJoltID <> "" Then
If GameJolt.Emblem.HasDownloadedSprite(Trainer.GameJoltID) = True Then
Dim t As Texture2D = GameJolt.Emblem.GetOnlineSprite(Trainer.GameJoltID)
If Not t Is Nothing Then
Dim spriteSize As New Vector2(CInt(t.Width / 3), CInt(t.Height / 4))
t3 = TextureManager.GetTexture(t, New Rectangle(0, CInt(spriteSize.Y * 2), CInt(spriteSize.X), CInt(spriteSize.Y)))
2016-09-07 18:50:38 +02:00
End If
End If
End If
Canvas.DrawRectangle(New Rectangle(0, 0, Core.windowSize.Width, CInt(((value / 1140) * Core.windowSize.Height * 1.5F))), Color.Black)
For i = -256 To Core.windowSize.Width Step 256
Dim offset As Integer = value + (animationAfterReady * 7)
While offset >= 256
offset -= 256
End While
Core.SpriteBatch.Draw(t1, New Rectangle(CInt(i + offset), CInt(Core.windowSize.Height / 2 - 64), 256, 128), Color.White)
Next
If Trainer.DoubleTrainer = True Then
Dim t As String = ReplaceIntroName(Trainer.TrainerType) & " " & ReplaceIntroName(Trainer.Name) & " & " & ReplaceIntroName(Trainer.TrainerType2) & " " & ReplaceIntroName(Trainer.Name2)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(Core.windowSize.Width - FontManager.InGameFont.MeasureString(t).X - 50, CInt(Core.windowSize.Height / 2 + 20)), Color.White)
Core.SpriteBatch.Draw(t3, New Rectangle(Core.windowSize.Width - 540, CInt(Core.windowSize.Height / 2 - 230), 256, 256), Color.White)
Core.SpriteBatch.Draw(t4, New Rectangle(Core.windowSize.Width - 280, CInt(Core.windowSize.Height / 2 - 230), 256, 256), Color.White)
Else
Dim t As String = ReplaceIntroName(Trainer.TrainerType) & " " & ReplaceIntroName(Trainer.Name)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(Core.windowSize.Width - FontManager.InGameFont.MeasureString(t).X - 50, CInt(Core.windowSize.Height / 2 + 20)), Color.White)
Core.SpriteBatch.Draw(t3, New Rectangle(Core.windowSize.Width - 310, CInt(Core.windowSize.Height / 2 - 230), 256, 256), Color.White)
End If
Core.SpriteBatch.Draw(t2, New Rectangle(420 - CInt(CInt(1.29 * value) / 3), CInt(Core.windowSize.Height / 2 - 20) - CInt(CInt(1 * value) / 3), CInt(1.12 * CInt(value / 1.5F)), 1 * CInt(value / 1.5F)), Color.White)
End Sub
Private Function ReplaceIntroName(ByVal Name As String) As String
Dim n As String = Name.Replace("<rivalname>", Core.Player.RivalName)
n = n.Replace("<playername>", Core.Player.Name)
n = n.Replace("<player.name>", Core.Player.Name)
n = n.Replace("[POKE]", "Poké")
Return n
End Function
Dim blackPosition As Integer = 0
Dim trainerPosition As Integer = 0
Dim barOffset As Integer = 0
Dim textPosition As Integer = 0
Private Sub DrawFaceshotIntro()
Dim barPosition As Vector2 = New Vector2(Trainer.BarImagePosition.X * 128, Trainer.BarImagePosition.Y * 128)
Dim VSPosition As Vector2 = New Vector2(Trainer.VSImagePosition.X * 128, Trainer.VSImagePosition.Y * 128 + 64)
Dim TrainerTexture1 As Texture2D = TextureManager.GetTexture("Textures\NPC\" & Trainer.SpriteName)
Dim TrainerTexture2 As Texture2D = Nothing
Dim Trainer1FrameSize As Size = Nothing
Dim Trainer2FrameSize As Size = Nothing
If TrainerTexture1.Width = TrainerTexture1.Height / 2 Then
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 2), CInt(TrainerTexture1.Height / 4))
ElseIf TrainerTexture1.Width = TrainerTexture1.Height Then
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 4), CInt(TrainerTexture1.Height / 4))
Else
Trainer1FrameSize = New Size(CInt(TrainerTexture1.Width / 3), CInt(TrainerTexture1.Height / 4))
End If
2016-09-07 18:50:38 +02:00
Dim t1 As Texture2D = TextureManager.GetTexture("GUI\Intro\VSIntro", New Rectangle(CInt(barPosition.X), CInt(barPosition.Y), 128, 64), "")
Dim t2 As Texture2D = TextureManager.GetTexture("GUI\Intro\VSIntro", New Rectangle(CInt(VSPosition.X), CInt(VSPosition.Y), 61, 54), "")
Dim t3 As Texture2D = TextureManager.GetTexture(TrainerTexture1, New Rectangle(0, Trainer1FrameSize.Height * 2, Trainer1FrameSize.Width, Trainer1FrameSize.Height))
2016-09-07 18:50:38 +02:00
Dim t4 As Texture2D = Nothing
If Trainer.DoubleTrainer = True Then
TrainerTexture2 = TextureManager.GetTexture("Textures\NPC\" & Trainer.SpriteName2)
If TrainerTexture1.Width = TrainerTexture1.Height / 2 Then
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 2), CInt(TrainerTexture2.Height / 4))
ElseIf TrainerTexture1.Width = TrainerTexture1.Height Then
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 4), CInt(TrainerTexture2.Height / 4))
Else
Trainer2FrameSize = New Size(CInt(TrainerTexture2.Width / 3), CInt(TrainerTexture2.Height / 4))
End If
t4 = TextureManager.GetTexture("NPC\" & Trainer.SpriteName2, New Rectangle(0, Trainer2FrameSize.Height * 2, Trainer2FrameSize.Width, Trainer2FrameSize.Height))
2016-09-07 18:50:38 +02:00
End If
If Trainer.GameJoltID <> "" Then
If GameJolt.Emblem.HasDownloadedSprite(Trainer.GameJoltID) = True Then
Dim t As Texture2D = GameJolt.Emblem.GetOnlineSprite(Trainer.GameJoltID)
If Not t Is Nothing Then
Dim spriteSize As Vector2
If t.Width = t.Height / 2 Then
spriteSize = New Vector2(CInt(t.Width / 2), CInt(t.Height / 4))
ElseIf t.Width = t.Height Then
spriteSize = New Vector2(CInt(t.Width / 4), CInt(t.Height / 4))
Else
spriteSize = New Vector2(CInt(t.Width / 3), CInt(t.Height / 4))
End If
t3 = TextureManager.GetTexture(t, New Rectangle(0, CInt(spriteSize.Y * 2), CInt(spriteSize.X), CInt(spriteSize.Y)))
2016-09-07 18:50:38 +02:00
End If
End If
End If
For i = -512 To Core.windowSize.Width Step 512
Dim offset As Integer = barOffset + (animationAfterReady * 7)
While offset >= 512
offset -= 512
End While
Core.SpriteBatch.Draw(t1, New Rectangle(CInt(i + offset), CInt(Core.windowSize.Height / 2 - 128), 512, 256), Color.White)
Next
Canvas.DrawRectangle(New Rectangle(0, 0, Core.windowSize.Width, blackPosition), Color.Black)
Core.SpriteBatch.Draw(t3, New Rectangle(CInt(Core.windowSize.Width - trainerPosition), CInt(Core.windowSize.Height / 2 - 96), 256, 224), New Rectangle(0, 0, t3.Width, CInt(t3.Height * 0.875)), Color.White)
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.Draw(t2, New Rectangle(trainerPosition - 61 * 4, CInt(Core.windowSize.Height / 2) - 96, 61 * 4, 54 * 4), Color.White)
Canvas.DrawRectangle(New Rectangle(0, Core.windowSize.Height - blackPosition, Core.windowSize.Width, blackPosition), Color.Black)
If textPosition > 0 Then
Dim tWidth As Integer = CInt(FontManager.InGameFont.MeasureString(Trainer.TrainerType).X * 3.0F)
Core.SpriteBatch.DrawString(FontManager.InGameFont, Trainer.TrainerType, New Vector2((textPosition - tWidth).Clamp(-tWidth, CInt(Core.windowSize.Width / 2 - tWidth / 2)), 50), Color.White, 0.0F, New Vector2(0), 3.0F, SpriteEffects.None, 0.0F)
If textPosition > 300 Then
tWidth = CInt(FontManager.InGameFont.MeasureString(Trainer.Name).X * 3.0F)
Core.SpriteBatch.DrawString(FontManager.InGameFont, Trainer.Name, New Vector2((Core.windowSize.Width - (textPosition - 300)).Clamp(CInt(Core.windowSize.Width / 2 - tWidth / 2), Core.windowSize.Width), Core.windowSize.Height - 180), Color.White, 0.0F, New Vector2(0), 3.0F, SpriteEffects.None, 0.0F)
End If
End If
End Sub
Public Overrides Sub Update()
If minDelay > 0.0F Then
minDelay -= 0.1F
If minDelay <= 0.0F Then
minDelay = 0.0F
End If
End If
If ready = True Then
animationAfterReady += 1
If Me.minDelay = 0.0F And SongOver() Then
Core.SetScreen(Me.NewScreen)
If Me.NewScreen.GetType() Is GetType(BattleSystem.BattleScreen) Then
Dim b As BattleSystem.BattleScreen = CType(Me.NewScreen, BattleSystem.BattleScreen)
If b.IsPVPBattle = True Then
b.InitializePVP(b.Trainer, b.OverworldScreen)
Else
If b.IsTrainerBattle = True Then
b.InitializeTrainer(b.Trainer, b.OverworldScreen, b.defaultMapType)
Else
If Screen.Level.IsSafariZone = True Then
b.InitializeSafari(b.WildPokemon, b.OverworldScreen, b.defaultMapType)
Else
If Screen.Level.IsBugCatchingContest = True Then
b.InitializeBugCatch(b.WildPokemon, b.OverworldScreen, b.defaultMapType)
Else
b.InitializeWild(b.WildPokemon, b.OverworldScreen, b.defaultMapType)
End If
End If
End If
End If
End If
End If
Else
Select Case AnimationType
Case 0, 5
UpdateRectangleIntro()
Case 1, 6
UpdateHorizontalBars()
Case 2, 7
UpdateVerticalBars()
Case 3, 8
UpdateBlockIn()
Case 4, 9
UpdateBlockOut()
Case 10
UpdateTrainerVS()
Case 11
UpdateFaceshotIntro()
Case 12
UpdateBlurIntro()
End Select
End If
ResetCursor()
End Sub
Private Sub UpdateFaceshotIntro()
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
Me.barOffset += 18
Me.blackPosition = (Me.blackPosition + 10).Clamp(0, CInt(Core.windowSize.Height / 2 - 128))
2016-09-07 18:50:38 +02:00
If blackPosition >= CInt(Core.windowSize.Height / 2 - 128) Then
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
trainerPosition = (trainerPosition + 20).Clamp(0, 420)
2016-09-07 18:50:38 +02:00
If trainerPosition >= 420 Then
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
textPosition += CInt(Math.Ceiling(Core.windowSize.Width / 50))
2016-09-07 18:50:38 +02:00
If textPosition >= CInt(Core.windowSize.Width / 2 - CInt(FontManager.InGameFont.MeasureString(Trainer.Name).X) / 2) + 1200 Then
Me.ready = True
End If
End If
End If
End Sub
Private Sub UpdateRectangleIntro()
Dim rectangleSize As Integer = Me.GetRectangleSize()
Dim fullRecs As Integer = CInt(Math.Ceiling(Core.windowSize.Height / rectangleSize)) * CInt(Math.Ceiling(Core.windowSize.Width / rectangleSize))
Dim currentRecs As Integer = Animations.Count
If fullRecs > currentRecs Then
Dim validPosition As Boolean = False
Dim Pos As Vector2
While validPosition = False
Pos = New Vector2(Core.Random.Next(0, CInt(Math.Ceiling((Core.windowSize.Width - rectangleSize) / rectangleSize)) + 1) * rectangleSize, Core.Random.Next(0, CInt(Math.Ceiling((Core.windowSize.Height - rectangleSize) / rectangleSize)) + 1) * rectangleSize)
validPosition = True
If Animations.Count > 0 Then
For Each R As Rectangle In Animations
If R.X = Pos.X And R.Y = Pos.Y Then
validPosition = False
Exit For
End If
Next
End If
End While
Animations.Add(New Rectangle(CInt(Pos.X), CInt(Pos.Y), rectangleSize, rectangleSize))
Else
ready = True
End If
End Sub
Private Function GetRectangleSize() As Integer
Dim blocksOnScreen As Double = 81.6
Dim pixelAmount As Double = Core.windowSize.Width * Core.windowSize.Height
Dim perRectanglePixels As Double = pixelAmount / blocksOnScreen
Return CInt(Math.Ceiling(Math.Sqrt(perRectanglePixels)))
End Function
Private Sub UpdateHorizontalBars()
If Animations.Count < 20 Then
If Core.Random.Next(0, 4) = 0 Then
Dim validPosition As Boolean = False
Dim Pos As Vector2
While validPosition = False
Pos = New Vector2(0, CInt(Core.windowSize.Height / 20) * Core.Random.Next(0, 20))
validPosition = True
If Animations.Count > 0 Then
For Each R As Rectangle In Animations
If R.X = Pos.X And R.Y = Pos.Y Then
validPosition = False
Exit For
End If
Next
End If
End While
Animations.Add(New Rectangle(CInt(Pos.X), CInt(Pos.Y), Core.windowSize.Width, CInt(Core.windowSize.Height / 20)))
End If
Else
ready = True
End If
End Sub
Private Sub UpdateVerticalBars()
If Animations.Count < 20 Then
If Core.Random.Next(0, 4) = 0 Then
Dim validPosition As Boolean = False
Dim Pos As Vector2
While validPosition = False
Pos = New Vector2(CInt(Core.windowSize.Width / 20) * Core.Random.Next(0, 20), 0)
validPosition = True
If Animations.Count > 0 Then
For Each R As Rectangle In Animations
If R.X = Pos.X And R.Y = Pos.Y Then
validPosition = False
Exit For
End If
Next
End If
End While
Animations.Add(New Rectangle(CInt(Pos.X), CInt(Pos.Y), CInt(Core.windowSize.Width / 20), Core.windowSize.Height))
End If
Else
ready = True
End If
End Sub
Private Sub UpdateBlockIn()
If Animations.Count = 0 Then
Animations.Add(New Rectangle(CInt(Core.windowSize.Width / 2 - (Core.windowSize.Width / 100 / 2)), CInt(Core.windowSize.Height / 2 - (Core.windowSize.Height / 100 / 2)), CInt(Core.windowSize.Width / 100), CInt(Core.windowSize.Height / 100)))
2016-09-07 18:50:38 +02:00
Else
Dim Speed As Integer = CInt(Me.duration.TotalMilliseconds / Core.windowSize.Height * 4)
If Animations(0).Height >= Core.windowSize.Height + 128 Then
2016-09-07 18:50:38 +02:00
ready = True
End If
Dim a As Rectangle = Animations(0)
2016-09-07 18:50:38 +02:00
a.X -= CInt(Speed)
a.Y -= CInt(Speed / 16 * 9)
2016-09-07 18:50:38 +02:00
a.Width += Speed * 2
a.Height += CInt(Speed * 2 / 16 * 9)
2016-09-07 18:50:38 +02:00
Animations.RemoveAt(0)
Animations.Add(a)
2016-09-07 18:50:38 +02:00
End If
End Sub
Private Sub UpdateBlockOut()
If Animations.Count = 0 Then
Animations.Add(New Rectangle(0, 0, Core.windowSize.Width, Core.windowSize.Height))
Else
If value >= Core.windowSize.Height / 2 + 4 Then
2016-09-07 18:50:38 +02:00
ready = True
Else
value += CInt(Math.Ceiling(Me.duration.TotalMilliseconds / Core.windowSize.Height * 3))
2016-09-07 18:50:38 +02:00
End If
End If
End Sub
Private Sub UpdateTrainerVS()
value += 7
If value >= 1140 Then
ready = True
End If
End Sub
Public Sub ResetCursor()
If Core.GameInstance.IsActive = True Then
Mouse.SetPosition(CInt(Core.windowSize.Width / 2), CInt(Core.windowSize.Height / 2))
oldX = CInt(Core.windowSize.Width / 2)
oldY = CInt(Core.windowSize.Height / 2)
End If
End Sub
Public Overrides Sub ChangeTo()
Player.Temp.IsInBattle = True
Player.Temp.BeforeBattlePosition = Screen.Camera.Position
Player.Temp.BeforeBattleLevelFile = Screen.Level.LevelFile
Player.Temp.BeforeBattleFacing = Screen.Camera.GetPlayerFacingDirection()
Dim b As BattleSystem.BattleScreen = CType(Me.NewScreen, BattleSystem.BattleScreen)
2016-09-07 18:50:38 +02:00
2021-10-26 23:43:23 +02:00
If BattleSystem.BattleScreen.CustomBattleMusic = "" OrElse MusicManager.SongExists(BattleSystem.BattleScreen.CustomBattleMusic) = False Then
If b.IsPVPBattle = True Then
MusicManager.Play(MusicLoop, False, 0.0F, False, "pvp")
Else
2021-10-26 23:43:23 +02:00
If b.IsTrainerBattle = True Then
MusicManager.Play(MusicLoop, False, 0.0F, False, Trainer.GetBattleMusicName())
ElseIf Screen.Level.IsSafariZone = True Or Screen.Level.IsBugCatchingContest = True Then
If MusicManager.SongExists(Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild") = True Then
MusicManager.Play(MusicLoop, False, 0.0F, False, Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild")
Else
MusicManager.Play(MusicLoop, False, 0.0F, False, "johto_wild")
End If
Else
If BattleSystem.BattleScreen.RoamingBattle = True AndAlso BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop <> "" AndAlso MusicManager.SongExists(BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop) = True Then
MusicManager.Play(MusicLoop, True, 0.0F, False, BattleSystem.BattleScreen.RoamingPokemonStorage.MusicLoop)
Else
If MusicManager.SongExists(Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild") = True Then
MusicManager.Play(MusicLoop, False, 0.0F, False, Screen.Level.CurrentRegion.Split(CChar(","))(0) & "_wild")
Else
MusicManager.Play(MusicLoop, False, 0.0F, False, "johto_wild")
End If
End If
End If
End If
2021-10-26 23:43:23 +02:00
Else
MusicManager.Play(MusicLoop, True, 0.0F, False, BattleSystem.BattleScreen.CustomBattleMusic)
End If
If Not MusicLoop Is Nothing Then
Me.duration = MusicManager.GetSong(MusicLoop).Duration
2016-09-07 18:50:38 +02:00
Else
Me.duration = New TimeSpan(0)
End If
Me.startTime = Date.Now
End Sub
Private Function SongOver() As Boolean
Return startTime + duration < Date.Now
2016-09-07 18:50:38 +02:00
End Function
'Protected Overrides Sub Finalize()
' If blurTexture IsNot Nothing
' blurTexture.Dispose()
' End If
'End Sub
2016-09-07 18:50:38 +02:00
End Class