P3D-Legacy/P3D/Network/MysteryEventScreen.vb

218 lines
9.2 KiB
VB.net
Raw Normal View History

2016-09-07 18:50:38 +02:00
Public Class MysteryEventScreen
Inherits Screen
Public Shared ActivatedMysteryEvents As New List(Of MysteryEvent)
Enum EventTypes
EXPMultiplier
MoneyMultiplier
PointsMultiplier
ShinyMultiplier
End Enum
Public Class MysteryEvent
Public EventType As EventTypes
Public Name As String
Public Description As String
Public Value As String
Public ID As String
Public Sub New(ByVal ID As String, ByVal EventTypeSTR As String, ByVal Name As String, ByVal Description As String, ByVal Value As String)
Me.ID = ID
Select Case EventTypeSTR.ToLower()
Case "exp"
Me.EventType = EventTypes.EXPMultiplier
Case "money"
Me.EventType = EventTypes.MoneyMultiplier
Case "points"
Me.EventType = EventTypes.PointsMultiplier
Case "shiny"
Me.EventType = EventTypes.ShinyMultiplier
End Select
Me.Name = Name
Me.Description = Description
Me.Value = Value
If Me.EventType = EventTypes.ShinyMultiplier AndAlso Me.Value = "0" Then
Me.Value = "0.1"
End If
2016-09-07 18:50:38 +02:00
End Sub
Public Overrides Function ToString() As String
Return "ID: " & ID & "|EVENT TYPE: " & Me.EventType.ToString() & "|NAME: " & Name & "|DESCRIPTION: " & Description & "|VALUE: " & Me.Value
End Function
Public Function IsEventActivated() As Boolean
For Each cEvent As MysteryEvent In ActivatedMysteryEvents
If cEvent.ID = Me.ID Then
Return True
End If
Next
Return False
End Function
End Class
Dim failedDownload As Boolean = False
Dim finishedDownload As Boolean = False
Dim EventData As New List(Of MysteryEvent)
Dim cursor As Integer = 0
Public Sub New(ByVal currentScreen As Screen)
Me.PreScreen = currentScreen
Me.Identification = Identifications.MysteryEventScreen
Me.MouseVisible = True
Dim t As New Threading.Thread(AddressOf DownloadInformation)
t.Start()
End Sub
Private Sub DownloadInformation()
'File Format: ID|EventType|Name|Description|Value
Me.EventData.Clear()
Me.failedDownload = False
Me.finishedDownload = False
Try
Dim w As New System.Net.WebClient
Dim data() As String = w.DownloadString("https://raw.githubusercontent.com/P3D-Legacy/P3D-Legacy-Data/master/Events.txt").SplitAtNewline()
2016-09-07 18:50:38 +02:00
For Each line As String In data
If line.Contains("|") = True Then
Dim eventData() As String = line.Split(CChar("|"))
If eventData.Count = 5 Then
Me.EventData.Add(New MysteryEvent(eventData(0), eventData(1), eventData(2), eventData(3), eventData(4)))
End If
End If
Next
finishedDownload = True
failedDownload = False
Catch ex As Exception
Logger.Log(Logger.LogTypes.ErrorMessage, "MysteryEventScreen.vb: Failed to download event data!")
finishedDownload = True
failedDownload = True
ClearActivatedEvents()
End Try
End Sub
Public Overrides Sub Draw()
Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\GTS"), Core.windowSize, New Rectangle(320, 176, 192, 160), Color.White)
Dim header As String = "Mystery Event"
Core.SpriteBatch.DrawString(FontManager.InGameFont, header, New Vector2(52, 52), Color.Black)
Core.SpriteBatch.DrawString(FontManager.InGameFont, header, New Vector2(50, 50), Color.White)
If Me.finishedDownload = False Then
Dim t As String = "Downloading Mystery Event data. Please wait" & LoadingDots.Dots
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(52, 152), Color.Black)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(50, 150), Color.White)
Else
If Me.failedDownload = True Then
Dim t As String = "Failed to download Mystery Event data." & Environment.NewLine & "Please check your internet connection and try again."
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(52, 152), Color.Black)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(50, 150), Color.White)
Else
If EventData.Count = 0 Then
Dim t As String = "There are no Mystery Events available" & Environment.NewLine & "at the moment. Please try again later."
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(52, 152), Color.Black)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(50, 150), Color.White)
Else
Dim t As String = "Please select the Mystery Events that" & Environment.NewLine & "you want to activate for your gameplay session:"
2016-09-07 18:50:38 +02:00
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(52, 152), Color.Black)
Core.SpriteBatch.DrawString(FontManager.InGameFont, t, New Vector2(50, 150), Color.White)
Dim startY As Integer = 240
For i = 0 To Me.EventData.Count - 1
Dim cEvent As MysteryEvent = Me.EventData(i)
Dim textColor As Color = Color.White
Dim backColor As Color = Color.Transparent
Dim borderColor As Color = Color.White
If i = cursor Then
textColor = Color.Black
backColor = Color.White
borderColor = Color.Black
End If
Canvas.DrawRectangle(New Rectangle(50, startY + i * 100, 400, 60), backColor)
Canvas.DrawBorder(2, New Rectangle(50, startY + i * 100, 400, 60), borderColor)
Dim activated As String = "Activated"
If cEvent.IsEventActivated() = False Then
activated = "Not activated"
Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\GTS"), New Rectangle(58, startY + i * 100 + 13, 32, 32), New Rectangle(368, 96, 16, 16), Color.White)
Else
Core.SpriteBatch.Draw(TextureManager.GetTexture("GUI\Menus\GTS"), New Rectangle(58, startY + i * 100 + 13, 32, 32), New Rectangle(384, 96, 16, 16), Color.White)
End If
Core.SpriteBatch.DrawString(FontManager.MiniFont, cEvent.EventType.ToString() & ": " & cEvent.Name & Environment.NewLine & activated, New Vector2(100, startY + i * 100 + 8), textColor)
2016-09-07 18:50:38 +02:00
Next
Canvas.DrawGradient(New Rectangle(500, startY, 400, 300), Color.White, Color.Gray, False, -1)
Dim sEvent As MysteryEvent = EventData(cursor)
Core.SpriteBatch.DrawString(FontManager.MiniFont, "Name: " & sEvent.Name & Environment.NewLine & Environment.NewLine &
"Type: " & sEvent.EventType.ToString() & Environment.NewLine & Environment.NewLine &
"Multiplicator: " & sEvent.Value & "x" & Environment.NewLine & Environment.NewLine &
"Description:" & Environment.NewLine &
2016-09-07 18:50:38 +02:00
sEvent.Description.CropStringToWidth(FontManager.MiniFont, 300), New Vector2(512, startY + 12), Color.Black)
End If
End If
End If
End Sub
Public Overrides Sub Update()
If Controls.Up(True, True, True, True, True, True) = True Then
cursor -= 1
End If
If Controls.Down(True, True, True, True, True, True) = True Then
cursor += 1
End If
cursor = cursor.Clamp(0, Me.EventData.Count - 1)
If Controls.Accept(True, True, True) = True Then
If EventData.Count > 0 Then
Dim cEvent As MysteryEvent = EventData(cursor)
If cEvent.IsEventActivated() = True Then
For i = 0 To ActivatedMysteryEvents.Count - 1
If cEvent.ID = ActivatedMysteryEvents(i).ID Then
ActivatedMysteryEvents.RemoveAt(i)
Exit For
End If
Next
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
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
ActivatedMysteryEvents.Add(cEvent)
End If
End If
End If
If Controls.Dismiss(True) = True Then
Core.SetScreen(New TransitionScreen(Me, Me.PreScreen, Color.White, False))
End If
End Sub
Public Overrides Sub ChangeTo()
MusicManager.Play("gts", True)
2016-09-07 18:50:38 +02:00
End Sub
Public Shared Sub ClearActivatedEvents()
ActivatedMysteryEvents.Clear()
End Sub
End Class