Implemented Pillbug/Mosquito actions. Implemented pre-game settings. TODO: Game settings + bug testing
This commit is contained in:
parent
397082f966
commit
2343638749
15 changed files with 477 additions and 70 deletions
|
|
@ -2,7 +2,22 @@ extends ActionBehaviour
|
|||
class_name ActionBehaviourMosquito
|
||||
|
||||
func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void:
|
||||
pass
|
||||
# if target only has move, just do move as
|
||||
#source_tile.temporary_action_behaviour = action_tile.resource.action_behaviour
|
||||
#source_tile.temporary_movement_behaviour = action_tile.resource.movement_behaviour
|
||||
|
||||
source_tile.temporary_resource = action_tile.resource
|
||||
|
||||
GameEvents.insect_tile_selected.emit(source_tile)
|
||||
|
||||
#if action_tile.resource.action_behaviour == null:
|
||||
# map.do_move_as(source_tile, action_tile)
|
||||
#else:
|
||||
# Copy and offer MOVE and Action (basically pillbug)
|
||||
# Starting to think it would be easier to temporarily change action_behaviour resource
|
||||
|
||||
|
||||
# pass
|
||||
|
||||
# GameEvents.insect_tiles_selected_for_action
|
||||
func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
|
||||
|
|
@ -10,7 +25,6 @@ func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
|
|||
# so we can't use our action unless we're on layer 0
|
||||
# TODO: Update movement selection
|
||||
if source_pos.w > 0:
|
||||
map.debug_label(Vector3(source_pos.x, source_pos.y, source_pos.z), "TODO: Implement Beetle Movement")
|
||||
return []
|
||||
|
||||
var neighbours = map.get_neighbours(source_pos)
|
||||
|
|
@ -20,7 +34,10 @@ func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
|
|||
var tile = map.get_tile(neighbour)
|
||||
if tile != null:
|
||||
# TODO: Find better way to see what tile we have...
|
||||
if not tile.resource.movement_behaviour is MovementBehaviourMosquito:
|
||||
if tile.resource.movement_behaviour is MovementBehaviourMosquito:
|
||||
continue
|
||||
|
||||
if tile.resource.movement_behaviour.get_available_spaces(source_pos, map).size() > 0:
|
||||
possible_action_targets.push_back(tile)
|
||||
|
||||
#GameEvents.insect_tiles_selected_for_action.emit(source_pos, possible_action_targets)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,52 @@
|
|||
extends ActionBehaviour
|
||||
class_name ActionBehaviourPillbug
|
||||
|
||||
func can_move_through(cellA: Vector4i, cellB: Vector4i, map: HexGrid) -> bool:
|
||||
cellA.w = 1
|
||||
cellB.w = 1
|
||||
|
||||
return map.get_same_neighbours(cellA, cellB).size() < 2
|
||||
|
||||
func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void:
|
||||
pass
|
||||
# get action tile
|
||||
# place hex outline for action tile around source_tile
|
||||
var tiles: Array[Vector4i] = map.get_empty_neighbours(source_tile.coordinates)
|
||||
var possible_tiles: Array[Vector4i] = []
|
||||
|
||||
for tile in tiles:
|
||||
if can_move_through(source_tile.coordinates, tile, map):
|
||||
possible_tiles.push_back(tile)
|
||||
|
||||
map.create_move_tiles(action_tile, possible_tiles)
|
||||
|
||||
func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
|
||||
var neighbours = map.get_neighbours(source_pos)
|
||||
var possible_action_targets: Array[InsectTile] = []
|
||||
|
||||
var tiles: Array[Vector4i] = map.get_empty_neighbours(source_pos)
|
||||
var possible_tiles: Array[Vector4i] = []
|
||||
|
||||
if tiles.is_empty():
|
||||
# no empty spaces left to move to
|
||||
print("no spaces left")
|
||||
return []
|
||||
|
||||
for tile in tiles:
|
||||
if can_move_through(source_pos, tile, map):
|
||||
possible_tiles.push_back(tile)
|
||||
|
||||
if possible_tiles.size() == 0:
|
||||
print("no possible tiles?")
|
||||
# no possible spaces to move TO
|
||||
return []
|
||||
|
||||
for neighbour in neighbours:
|
||||
var tile = map.get_tile(neighbour)
|
||||
if tile != null:
|
||||
if not tile.is_in_stack() and tile.can_move():
|
||||
possible_action_targets.push_back(tile)
|
||||
if can_move_through(source_pos, neighbour, map):
|
||||
# this tile can be picked up
|
||||
possible_action_targets.push_back(tile)
|
||||
|
||||
#GameEvents.insect_tiles_selected_for_action.emit(source_pos, possible_action_targets)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue