Added PlayerPosition tag to Map Screen

This commit is contained in:
Jasper "JappaWakka" Speelman 2022-04-10 19:12:30 +02:00
parent 044a3d2489
commit 53d9823387
1 changed files with 113 additions and 17 deletions

View File

@ -50,9 +50,9 @@
Me.FillMap()
Dim v As Vector2 = GetPlayerPosition()
Dim v As Vector2 = GetCursorPosition()
If v.X <> 0 Or v.Y <> 0 Then
Me.CursorPosition = Me.GetPlayerPosition() + New Vector2(mapOffsetX, mapOffsetY)
Me.CursorPosition = Me.GetCursorPosition() + New Vector2(mapOffsetX, mapOffsetY)
Else
Me.CursorPosition = New Vector2(MouseHandler.MousePosition.X, MouseHandler.MousePosition.Y)
End If
@ -132,13 +132,16 @@
Case "large", "4"
CitySize = City.CitySize.Large
End Select
Dim PlayerPositionList As List(Of String) = "-1,-1".Split(CChar(",")).ToList()
If Tags.ContainsKey("playerposition") = True Then
PlayerPositionList = Tags("playerposition").Split(CChar(",")).ToList()
End If
If Tags.ContainsKey("flyto") = True Then
Dim FlyTo As New List(Of String)
FlyTo = Tags("flyto").Split(CChar(",")).ToList()
cities.Add(New City(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), CitySize, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3)))))
cities.Add(New City(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), CitySize, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3))), CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
Else
cities.Add(New City(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), CitySize, "", Nothing))
cities.Add(New City(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), CitySize, "", Nothing, CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
End If
Case "route"
Dim Name As String = Tags("name")
@ -190,13 +193,16 @@
Case "water", "1"
RouteType = Route.RouteTypes.Water
End Select
Dim PlayerPositionList As List(Of String) = "-1,-1".Split(CChar(",")).ToList()
If Tags.ContainsKey("playerposition") = True Then
PlayerPositionList = Tags("playerposition").Split(CChar(",")).ToList()
End If
If Tags.ContainsKey("flyto") = True Then
Dim FlyTo As New List(Of String)
FlyTo = Tags("flyto").Split(CChar(",")).ToList()
routes.Add(New Route(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), RouteDirection, RouteType, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3)))))
routes.Add(New Route(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), RouteDirection, RouteType, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3))), CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
Else
routes.Add(New Route(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), RouteDirection, RouteType, "", Nothing))
routes.Add(New Route(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), RouteDirection, RouteType, "", Nothing, CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
End If
Case "place"
Dim Name As String = Tags("name")
@ -220,13 +226,16 @@
Case "large", "5"
PlaceSize = Place.PlaceSizes.Large
End Select
Dim PlayerPositionList As List(Of String) = "-1,-1".Split(CChar(",")).ToList()
If Tags.ContainsKey("playerposition") = True Then
PlayerPositionList = Tags("playerposition").Split(CChar(",")).ToList()
End If
If Tags.ContainsKey("flyto") = True Then
Dim FlyTo As New List(Of String)
FlyTo = Tags("flyto").Split(CChar(",")).ToList()
places.Add(New Place(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), PlaceSize, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3)))))
places.Add(New Place(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), PlaceSize, FlyTo(0), New Vector3(CSng(FlyTo(1)), CSng(FlyTo(2)), CSng(FlyTo(3))), CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
Else
places.Add(New Place(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), PlaceSize, "", Nothing))
places.Add(New Place(Name, MapFiles, CInt(PositionList(0)), CInt(PositionList(1)), PlaceSize, "", Nothing, CInt(PlayerPositionList(0)), CInt(PlayerPositionList(1))))
End If
End Select
@ -636,7 +645,7 @@
CType(CType(Core.CurrentScreen, TransitionScreen).NewScreen, OverworldScreen).ActionScript.StartScript(s, 2, False)
End Sub
Private Function GetPlayerPosition() As Vector2
Private Function GetCursorPosition() As Vector2
Dim v As Vector2 = New Vector2(0, 0)
Dim r As New Rectangle(0, 0, 0, 0)
Dim mapOffset As New Vector2(mapOffsetX, mapOffsetY)
@ -662,6 +671,49 @@
Return (v + New Vector2(CInt(r.Width / 2), CInt(r.Height / 2)))
End Function
Private Function GetPlayerPosition() As Vector2
Dim v As Vector2 = New Vector2(0, 0)
Dim r As New Rectangle(0, 0, 0, 0)
Dim mapOffset As New Vector2(mapOffsetX, mapOffsetY)
Dim sizeX = 1 * MapScreen.RasterSize
Dim sizeY = 1 * MapScreen.RasterSize
For Each City As City In Me.cities
If City.ContainFiles.Contains(Level.LevelFile.ToLower()) = True Then
If City.PlayerPositionX <> -1 AndAlso City.PlayerPositionY <> -1 Then
v = City.getPlayerPosition()
r = New Rectangle(CInt(City.getPlayerPosition().X + mapOffset.X), CInt(City.getPosition().Y + mapOffset.Y), sizeX, sizeY)
Else
v = City.getPosition()
r = City.getRectangle(mapOffset)
End If
End If
Next
For Each Place As Place In Me.places
If Place.ContainFiles.Contains(Level.LevelFile.ToLower()) = True Then
If Place.PlayerPositionX <> -1 AndAlso Place.PlayerPositionY <> -1 Then
v = Place.getPlayerPosition()
r = New Rectangle(CInt(Place.getPlayerPosition().X + mapOffset.X), CInt(Place.getPosition().Y + mapOffset.Y), sizeX, sizeY)
Else
v = Place.getPosition()
r = Place.getRectangle(mapOffset)
End If
End If
Next
For Each Route As Route In Me.routes
If Route.ContainFiles.Contains(Level.LevelFile.ToLower()) = True Then
If Route.PlayerPositionX <> -1 AndAlso Route.PlayerPositionY <> -1 Then
v = Route.getPlayerPosition()
r = New Rectangle(CInt(Route.getPlayerPosition().X + mapOffset.X), CInt(Route.getPosition().Y + mapOffset.Y), sizeX, sizeY)
Else
v = Route.getPosition()
r = Route.getRectangle(mapOffset)
End If
End If
Next
Return (v + New Vector2(CInt(r.Width / 2), CInt(r.Height / 2)))
End Function
Public Class City
@ -675,6 +727,8 @@
Public Name As String = "???"
Public ContainFiles As New List(Of String)
Public PlayerPositionX As Integer = -1
Public PlayerPositionY As Integer = -1
Public PositionX As Integer = 0
Public PositionY As Integer = 0
Public FlyToFile As String = ""
@ -683,7 +737,7 @@
Dim T As Texture2D = Nothing
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal Size As CitySize, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing)
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal Size As CitySize, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing, Optional PlayerPositionX As Integer = -1, Optional PlayerPositionY As Integer = -1)
Me.Name = Name
For Each file As String In ContainFiles
@ -692,6 +746,16 @@
Me.PositionX = PositionX
Me.PositionY = PositionY
If PlayerPositionX <> -1 Then
Me.PlayerPositionX = PlayerPositionX
Else
Me.PlayerPositionX = PositionX
End If
If PlayerPositionY <> -1 Then
Me.PlayerPositionY = PlayerPositionY
Else
Me.PlayerPositionY = PositionY
End If
Me.Size = Size
Me.FlyToFile = FlyToFile
@ -702,6 +766,10 @@
Return New Vector2(Me.PositionX * MapScreen.RasterSize, Me.PositionY * MapScreen.RasterSize)
End Function
Public Function getPlayerPosition() As Vector2
Return New Vector2(Me.PlayerPositionX * MapScreen.RasterSize, Me.PlayerPositionY * MapScreen.RasterSize)
End Function
Public Function getRectangle(ByVal offset As Vector2) As Rectangle
Dim sizeX As Integer = 0
Dim sizeY As Integer = 0
@ -813,6 +881,8 @@
Public Name As String = ""
Public PositionX As Integer = 0
Public PositionY As Integer = 0
Public PlayerPositionX As Integer = -1
Public PlayerPositionY As Integer = -1
Public ContainFiles As New List(Of String)
Public FlyToFile As String = ""
Public FlyToPosition As Vector3 = New Vector3(0)
@ -822,7 +892,7 @@
Dim T As Texture2D = Nothing
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal RouteDirection As RouteDirections, ByVal RouteType As RouteTypes, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing)
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal RouteDirection As RouteDirections, ByVal RouteType As RouteTypes, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing, Optional PlayerPositionX As Integer = -1, Optional PlayerPositionY As Integer = -1)
Me.Name = Name
Me.PositionX = PositionX
Me.PositionY = PositionY
@ -832,7 +902,16 @@
For Each file As String In ContainFiles
Me.ContainFiles.Add(file.ToLower())
Next
If PlayerPositionX <> -1 Then
Me.PlayerPositionX = PlayerPositionX
Else
Me.PlayerPositionX = PositionX
End If
If PlayerPositionY <> -1 Then
Me.PlayerPositionY = PlayerPositionY
Else
Me.PlayerPositionY = PositionY
End If
Me.FlyToFile = FlyToFile
Me.FlyToPosition = FlyToPosition
End Sub
@ -840,6 +919,9 @@
Public Function getPosition() As Vector2
Return New Vector2(Me.PositionX * MapScreen.RasterSize, Me.PositionY * MapScreen.RasterSize)
End Function
Public Function getPlayerPosition() As Vector2
Return New Vector2(Me.PlayerPositionX * MapScreen.RasterSize, Me.PlayerPositionY * MapScreen.RasterSize)
End Function
Public Function getRectangle(ByVal offset As Vector2) As Rectangle
Dim sizeX As Single = 1.0F
@ -968,6 +1050,8 @@
Public ContainFiles As New List(Of String)
Public PositionX As Integer
Public PositionY As Integer
Public PlayerPositionX As Integer = -1
Public PlayerPositionY As Integer = -1
Public PlaceSize As PlaceSizes
Public FlyToFile As String = ""
@ -975,7 +1059,7 @@
Dim T As Texture2D = Nothing
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal PlaceSize As PlaceSizes, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing)
Public Sub New(ByVal Name As String, ByVal ContainFiles() As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal PlaceSize As PlaceSizes, Optional ByVal FlyToFile As String = "", Optional ByVal FlyToPosition As Vector3 = Nothing, Optional PlayerPositionX As Integer = -1, Optional PlayerPositionY As Integer = -1)
Me.Name = Name
Me.PositionX = PositionX
Me.PositionY = PositionY
@ -984,6 +1068,16 @@
For Each file As String In ContainFiles
Me.ContainFiles.Add(file.ToLower())
Next
If PlayerPositionX <> -1 Then
Me.PlayerPositionX = PlayerPositionX
Else
Me.PlayerPositionX = PositionX
End If
If PlayerPositionY <> -1 Then
Me.PlayerPositionY = PlayerPositionY
Else
Me.PlayerPositionY = PositionY
End If
Me.FlyToFile = FlyToFile
Me.FlyToPosition = FlyToPosition
@ -992,7 +1086,9 @@
Public Function getPosition() As Vector2
Return New Vector2(Me.PositionX * MapScreen.RasterSize, Me.PositionY * MapScreen.RasterSize)
End Function
Public Function getPlayerPosition() As Vector2
Return New Vector2(Me.PlayerPositionX * MapScreen.RasterSize, Me.PlayerPositionY * MapScreen.RasterSize)
End Function
Public Function getRectangle(ByVal offset As Vector2) As Rectangle
Dim sizeX As Single = 1.0F
Dim sizeY As Single = 1.0F