Fixed move penalty
This commit is contained in:
parent
e7baa34859
commit
b42b1ae39f
3 changed files with 37 additions and 9 deletions
|
|
@ -42,6 +42,19 @@ func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
|
|||
|
||||
for neighbour in neighbours:
|
||||
var tile = map.get_tile(neighbour)
|
||||
if tile == null:
|
||||
continue
|
||||
|
||||
print(tile.move_round_penalty)
|
||||
if not tile.can_move():
|
||||
continue
|
||||
|
||||
|
||||
if not map.can_hive_exist_without_tile(tile):
|
||||
continue
|
||||
|
||||
|
||||
|
||||
if tile != null:
|
||||
if not tile.is_in_stack() and tile.can_move():
|
||||
if can_move_through(source_pos, neighbour, map):
|
||||
|
|
|
|||
|
|
@ -315,6 +315,9 @@ func _on_insect_tile_move_started(tile: InsectTile) -> void:
|
|||
do_move(tile)
|
||||
|
||||
func do_action(tile: InsectTile) -> void:
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
# get possible targets, pass the resource action callable with binds of source and target tile
|
||||
var targets = tile.get_action_behaviour().get_targets(tile.coordinates, self)
|
||||
|
||||
|
|
@ -331,13 +334,13 @@ func do_action(tile: InsectTile) -> void:
|
|||
pass
|
||||
|
||||
func do_move_as(source: InsectTile, copy: InsectTile) -> void:
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
if not can_hive_exist_without_tile(source):
|
||||
print("Cant to do move as. Cant exist without hive")
|
||||
return
|
||||
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var spaces = copy.get_movement_behaviour().get_available_spaces(source.coordinates, self)
|
||||
|
||||
if spaces.is_empty():
|
||||
|
|
@ -390,6 +393,9 @@ func do_move_as(source: InsectTile, copy: InsectTile) -> void:
|
|||
placements[space] = outline
|
||||
|
||||
func create_move_tiles(tile: InsectTile, coords: Array[Vector4i]) -> void:
|
||||
for child in placement_visualizer.get_children():
|
||||
child.queue_free()
|
||||
|
||||
for space in coords:
|
||||
var layer: int = 0
|
||||
var temp_tile: InsectTile = null
|
||||
|
|
@ -516,6 +522,8 @@ func move_insect_tile(tile_coords: Vector4i, target: Vector4i) -> void:
|
|||
|
||||
tile.coordinates = target
|
||||
|
||||
#tile.move_round_penalty = 2
|
||||
|
||||
used_cells[tile.coordinates] = tile
|
||||
|
||||
if tile.coordinates.w > 0:
|
||||
|
|
|
|||
19
Tile/Tile.gd
19
Tile/Tile.gd
|
|
@ -103,6 +103,7 @@ func _ready() -> void:
|
|||
GameEvents.insect_action_cancelled.connect(_on_action_cancelled)
|
||||
|
||||
GameEvents.turn_started.connect(_on_turn_started)
|
||||
GameEvents.turn_ended.connect(_on_turn_ended)
|
||||
|
||||
func _on_action_cancelled() -> void:
|
||||
selected_for_action = false
|
||||
|
|
@ -124,18 +125,22 @@ func _on_selection_failed(tile: InsectTile) -> void:
|
|||
|
||||
# Show selection failed mat
|
||||
|
||||
func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> void:
|
||||
is_blacks_turn = _is_blacks_turn
|
||||
|
||||
move_round_penalty -= 1
|
||||
func _on_turn_ended(turn_num: int, map: HexGrid) -> void:
|
||||
move_round_penalty = move_round_penalty - 1
|
||||
if move_round_penalty < 0:
|
||||
move_round_penalty = 0
|
||||
|
||||
func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> void:
|
||||
is_blacks_turn = _is_blacks_turn
|
||||
|
||||
can_be_selected = GameData.bees_placed.has(is_black)
|
||||
#print(GameData.has_bee_been_placed)
|
||||
if turn_num >= 7 and not GameData.bees_placed.has(is_black):
|
||||
can_be_selected = false
|
||||
|
||||
if not can_move():
|
||||
can_be_selected = false
|
||||
|
||||
if can_be_selected:
|
||||
tween_normal()
|
||||
else:
|
||||
|
|
@ -172,7 +177,7 @@ func _on_insect_tile_moved(tile: InsectTile, to: Vector4i) -> void:
|
|||
action_callback = Callable()
|
||||
|
||||
if tile == self:
|
||||
move_round_penalty == 2
|
||||
move_round_penalty = 1
|
||||
|
||||
func _on_insect_tile_deselected(tile: InsectTile) -> void:
|
||||
selected = false
|
||||
|
|
@ -212,7 +217,6 @@ func _on_insect_placement_cancelled() -> void:
|
|||
else:
|
||||
tween_disabled()
|
||||
|
||||
|
||||
func _on_insect_selected(button: InsectButton, is_black: bool) -> void:
|
||||
deactivated = true
|
||||
|
||||
|
|
@ -229,6 +233,9 @@ func _input_event(camera, event, position, normal, shape_idx):
|
|||
if not can_be_selected:
|
||||
return
|
||||
|
||||
if not can_move():
|
||||
return
|
||||
|
||||
#if not hovered:
|
||||
#return
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue