Working prototype
This commit is contained in:
parent
3de181134d
commit
1ed0ec226d
24 changed files with 682 additions and 31 deletions
34
Tile/Tile.gd
34
Tile/Tile.gd
|
|
@ -3,6 +3,7 @@ class_name InsectTile
|
|||
|
||||
var map_reference: HexGrid
|
||||
|
||||
var is_blacks_turn: bool = false
|
||||
|
||||
var coordinates: Vector4i
|
||||
var layer: int = 0
|
||||
|
|
@ -36,6 +37,10 @@ var tween: Tween
|
|||
var tweening: bool = false
|
||||
|
||||
var selected_for_action: bool = false
|
||||
var can_be_selected: bool = false
|
||||
|
||||
func is_players_turn() -> bool:
|
||||
return is_blacks_turn == GameData.is_player_black or GameData.debug
|
||||
|
||||
func _ready() -> void:
|
||||
if is_black:
|
||||
|
|
@ -54,7 +59,17 @@ func _ready() -> void:
|
|||
GameEvents.insect_tile_deselected.connect(_on_insect_tile_deselected)
|
||||
GameEvents.insect_tile_moved.connect(_on_insect_tile_moved)
|
||||
GameEvents.insect_tiles_selected_for_action.connect(_on_tiles_selected_for_action)
|
||||
|
||||
|
||||
GameEvents.turn_started.connect(_on_turn_started)
|
||||
|
||||
func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> void:
|
||||
is_blacks_turn = _is_blacks_turn
|
||||
|
||||
can_be_selected = GameData.has_bee_been_placed
|
||||
print(GameData.has_bee_been_placed)
|
||||
if turn_num >= 7 and not GameData.has_bee_been_placed:
|
||||
can_be_selected = true
|
||||
|
||||
func _on_tiles_selected_for_action(source_pos: Vector4i, targets: Array[InsectTile]) -> void:
|
||||
if self in targets:
|
||||
selected_for_action = true
|
||||
|
|
@ -92,12 +107,21 @@ func _on_insect_selected(button: InsectButton, is_black: bool) -> void:
|
|||
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("place_tile"):
|
||||
if not can_be_selected:
|
||||
return
|
||||
|
||||
if deactivated:
|
||||
return
|
||||
|
||||
if not hovered:
|
||||
return
|
||||
|
||||
if not GameData.is_player_black == is_black:
|
||||
return
|
||||
|
||||
if not is_players_turn():
|
||||
return
|
||||
|
||||
# Move up the insect stack.... or just do not react while we have something on top of us?
|
||||
|
||||
if GameData.allow_selecting_in_stack:
|
||||
|
|
@ -114,8 +138,8 @@ func _process(delta):
|
|||
GameEvents.insect_tile_selected.emit(self)
|
||||
|
||||
func hover() -> void:
|
||||
#if GameData.is_player_black != is_black:
|
||||
#return
|
||||
if GameData.is_player_black != is_black:
|
||||
return
|
||||
|
||||
if tween != null:
|
||||
tween.kill()
|
||||
|
|
@ -131,8 +155,8 @@ func tween_hover_shader(color: Color) -> void:
|
|||
mat.next_pass.set_shader_parameter("emission_color", color)
|
||||
|
||||
func unhover() -> void:
|
||||
#if GameData.is_player_black != is_black:
|
||||
#return
|
||||
if GameData.is_player_black != is_black:
|
||||
return
|
||||
|
||||
if tween != null:
|
||||
tween.kill()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue