Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit On
- Option Infer Off
- Option Strict On
- Imports Project3.main
- Public Class WorldMap
- Private _map As Image
- Private _name As String
- Private _movementGrid(23, 23) As Point
- Private _obsticleGrid(23, 23) As Integer
- Private _DestList(23, 23) As globalCordinate
- Private _spritePosition(12) As Point
- Private _counter As Integer = 0
- Public Sub New(ByVal argDestList() As globalCordinate, ByVal argMovementGrid(,) As Point, ByVal argname As String)
- 'argdestlist will be a list of global cords that will corospond with 2's in the obsticle grid. if somehow we get errors then they are in the database.
- _name = argname
- _movementGrid = argMovementGrid
- Dim count As Integer = 0
- For i As Integer = 0 To 23 Step 1
- For j As Integer = 0 To 23 Step 1
- If _obsticleGrid(i, j) = 2 Then
- _DestList(i, j) = argDestList(count)
- End If
- Next
- Next
- For i As Integer = 0 To 12 Step 1
- _spritePosition(i) = New Point(-1, -1)
- Next
- _map = Image.FromFile("art\maps\" & _name & ".png")
- _obsticleGrid = GetDefaultObsticleGrid()
- End Sub
- Private Function GetDefaultObsticleGrid() As Integer(,)
- Dim CollisionMap As New Bitmap("art\maps\" & _name & "_COLLISION.png")
- Dim obsticlegrid(23, 23) As Integer
- For i As Integer = 0 To 23 Step 1
- For j As Integer = 0 To 23 Step 1
- If CollisionMap.GetPixel(_movementGrid(i, j).X, _movementGrid(i, j).Y) = Color.FromArgb(237, 28, 36) Then
- obsticlegrid(i, j) = 1
- ElseIf CollisionMap.GetPixel(_movementGrid(i, j).X, _movementGrid(i, j).Y) = Color.FromArgb(255, 242, 0) Then
- obsticlegrid(i, j) = 2
- ElseIf CollisionMap.GetPixel(_movementGrid(i, j).X, _movementGrid(i, j).Y) = Color.FromArgb(237, 28, 36) Or CollisionMap.GetPixel(_movementGrid(i, j).X, _movementGrid(i, j).Y) = Color.FromArgb(237, 28, 36) Then
- obsticlegrid(i, j) = 0
- Else
- obsticlegrid(i, j) = 0
- End If
- Next
- Next
- Return obsticlegrid
- End Function
- Public Function AddPlayer(ByVal argPoint As Point) As Boolean
- If _obsticleGrid(argPoint.X, argPoint.Y) = 0 Then
- _spritePosition(0) = _movementGrid(argPoint.X, argPoint.Y)
- Return True
- Else
- Return False
- End If
- End Function
- Public Function AddMob(ByVal argPoint As Point) As Boolean
- If _obsticleGrid(argPoint.X, argPoint.Y) = 0 Then
- _counter += 1
- If _counter <= _spritePosition.GetUpperBound(0) Then
- _spritePosition(_counter) = _movementGrid(argPoint.X, argPoint.Y)
- Return True
- Else
- Return False
- End If
- Else
- Return False
- End If
- End Function
- Public Function getDest(ByVal argPoint As Point, ByRef argDest As globalCordinate) As Boolean
- If Not _DestList(argPoint.X, argPoint.Y) Is Nothing Then
- argDest = _DestList(argPoint.X, argPoint.Y)
- Return True
- Else
- Return False
- End If
- End Function
- Public Function Move(ByVal argDestination As Point, ByVal argSprite As Integer) As Integer ' 0= worked -1=failed 1=battle 2=npc talk 3 = move to new location
- If argSprite >= 0 And argSprite <= _spritePosition.GetUpperBound(0) Then 'proper sprite integer
- If _spritePosition(argSprite).X > -1 And _spritePosition(argSprite).Y > -1 Then 'checks if the sprite is in play or not.
- If argDestination.X >= 0 And argDestination.Y >= 0 And argDestination.X >= 23 And argDestination.Y >= 23 Then ' checks total bounds
- If _obsticleGrid(argDestination.X, argDestination.Y) = 0 Then 'clear spot
- If argSprite = 0 Then
- _obsticleGrid(argDestination.X, argDestination.Y) = 5 'sets new position to player
- Else
- _obsticleGrid(argDestination.X, argDestination.Y) = 4 'sets new position to mob
- End If
- _obsticleGrid(_spritePosition(argSprite).X, _spritePosition(argSprite).Y) = 0 'sets old position as clear
- Return 0
- ElseIf _obsticleGrid(argDestination.X, argDestination.Y) = 1 Then 'obsticle
- Return -1
- ElseIf _obsticleGrid(argDestination.X, argDestination.Y) = 2 Then 'leave the zone
- If argSprite = 0 Then 'PC check
- Return 3
- Else
- Return -1
- End If
- ElseIf _obsticleGrid(argDestination.X, argDestination.Y) = 4 Then 'monster
- If argSprite > 0 Then
- Return 1
- Else
- Return -1
- End If
- ElseIf _obsticleGrid(argDestination.X, argDestination.Y) = 3 Then 'npc
- If argSprite > 0 Then
- Return 2
- Else
- Return -1
- End If
- ElseIf _obsticleGrid(argDestination.X, argDestination.Y) = 5 Then 'player
- Return 1
- End If
- Return -1 'just incase shit goes wrong somehow.
- Else
- Return -1
- End If
- Else
- Return -1
- End If
- Else
- Return -1
- End If
- End Function
- Private Sub AnimatePC()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment