Cleanup Grid.gd
This commit is contained in:
parent
5071247b69
commit
25a400f31f
@ -172,6 +172,7 @@ func position_to_coordinates (node_position : Vector2, height : int) -> Vector2:
|
|||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
func _is_in_grid (coordinates : Vector2) -> bool:
|
func _is_in_grid (coordinates : Vector2) -> bool:
|
||||||
if (coordinates.x >= GRID_SIZE.x or
|
if (coordinates.x >= GRID_SIZE.x or
|
||||||
coordinates.y >= GRID_SIZE.y or
|
coordinates.y >= GRID_SIZE.y or
|
||||||
@ -180,6 +181,7 @@ func _is_in_grid (coordinates : Vector2) -> bool:
|
|||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
func get_tile_behind_state (coordinates : Vector2) -> String:
|
func get_tile_behind_state (coordinates : Vector2) -> String:
|
||||||
#checking if tiles are directly behind
|
#checking if tiles are directly behind
|
||||||
#the plus 1 and plus 2 mean that its a height difference of 2 or 3 required respectively
|
#the plus 1 and plus 2 mean that its a height difference of 2 or 3 required respectively
|
||||||
@ -200,7 +202,8 @@ func get_tile_behind_state (coordinates : Vector2) -> String:
|
|||||||
else:
|
else:
|
||||||
return "n" #no
|
return "n" #no
|
||||||
|
|
||||||
func get_around_coordinate(coordinate : Vector2, movement_distance : int):
|
|
||||||
|
func get_around_coordinate (coordinate : Vector2, movement_distance : int):
|
||||||
#found https://godotengine.org/qa/64496/how-to-get-a-random-tile-in-a-radious
|
#found https://godotengine.org/qa/64496/how-to-get-a-random-tile-in-a-radious
|
||||||
|
|
||||||
#disclude the tile being stood on
|
#disclude the tile being stood on
|
||||||
@ -228,7 +231,8 @@ func get_around_coordinate(coordinate : Vector2, movement_distance : int):
|
|||||||
|
|
||||||
return positions
|
return positions
|
||||||
|
|
||||||
func _filter_moveable_spaces(positions_array, water_walk : bool = false, air_walk : bool = false, lava_walk : bool = false):
|
|
||||||
|
func _filter_moveable_spaces (positions_array, water_walk : bool = false, air_walk : bool = false, lava_walk : bool = false):
|
||||||
#this uses happy path to filter out the invalid move spaces
|
#this uses happy path to filter out the invalid move spaces
|
||||||
var new_pos_array = []
|
var new_pos_array = []
|
||||||
for i in positions_array.size():
|
for i in positions_array.size():
|
||||||
@ -252,7 +256,8 @@ func _filter_moveable_spaces(positions_array, water_walk : bool = false, air_wal
|
|||||||
new_pos_array.append(positions_array[i])
|
new_pos_array.append(positions_array[i])
|
||||||
return new_pos_array
|
return new_pos_array
|
||||||
|
|
||||||
func display_selection(coordinate : Vector2, unit : Unit):
|
|
||||||
|
func display_selection (coordinate : Vector2, unit : Unit):
|
||||||
var movement_amount = unit.movement_points
|
var movement_amount = unit.movement_points
|
||||||
print("hi")
|
print("hi")
|
||||||
for i in range (movement_amount, -1, -1):
|
for i in range (movement_amount, -1, -1):
|
||||||
@ -268,16 +273,17 @@ func display_selection(coordinate : Vector2, unit : Unit):
|
|||||||
var area_moveable = _filter_moveable_spaces(area_around, unit.water_walk, unit.air_walk, unit.lava_walk)
|
var area_moveable = _filter_moveable_spaces(area_around, unit.water_walk, unit.air_walk, unit.lava_walk)
|
||||||
$SelectionAreaController.create_selection_from_array(area_moveable, i)
|
$SelectionAreaController.create_selection_from_array(area_moveable, i)
|
||||||
|
|
||||||
func remove_selection():
|
|
||||||
|
func remove_selection ():
|
||||||
$SelectionAreaController.emit_signal("remove_selection")
|
$SelectionAreaController.emit_signal("remove_selection")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#func get_around_coordinate(coordinate : Vector2, movement_distance : int):
|
#func get_around_coordinate(coordinate : Vector2, movement_distance : int):
|
||||||
# #this generates the list of coordinates that a unit can move too
|
# #this generates the list of coordinates that a unit can move too
|
||||||
# #the radius + radius (either side) + 1 (the center)
|
# #the radius + radius (either side) + 1 (the center)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user