Working prototype
This commit is contained in:
parent
3de181134d
commit
1ed0ec226d
24 changed files with 682 additions and 31 deletions
|
|
@ -20,6 +20,13 @@ var selected: bool = false
|
|||
var hovered: bool = false
|
||||
var deactivated: bool = false
|
||||
|
||||
var is_blacks_turn: bool = false
|
||||
|
||||
var should_disable: bool = false
|
||||
|
||||
func is_players_turn() -> bool:
|
||||
return is_blacks_turn == GameData.is_player_black or GameData.debug
|
||||
|
||||
func update_color(_is_black: bool) -> void:
|
||||
is_black = _is_black
|
||||
if is_black:
|
||||
|
|
@ -73,7 +80,10 @@ func _on_insect_placed(resource: TileResource, _is_black: bool, pos: Vector4i) -
|
|||
func refresh_state() -> void:
|
||||
selected = false
|
||||
|
||||
if not is_empty():
|
||||
if should_disable:
|
||||
disable()
|
||||
|
||||
if not is_empty() and not should_disable:
|
||||
enable()
|
||||
|
||||
if hovered and not is_empty():
|
||||
|
|
@ -95,6 +105,25 @@ func _ready() -> void:
|
|||
GameEvents.insect_tile_moved.connect(_on_insect_tile_moved)
|
||||
GameEvents.insect_tile_deselected.connect(_on_insect_tile_deselected)
|
||||
|
||||
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
|
||||
should_disable = false
|
||||
if turn_num >= 7 and not GameData.has_bee_been_placed:
|
||||
if GameData.is_player_black == is_blacks_turn:
|
||||
# if not bee has been placed for this player
|
||||
# lock all buttons except the bee
|
||||
if is_same(BEE, insect_resource):
|
||||
# don't lock
|
||||
should_disable = false
|
||||
else:
|
||||
#lock
|
||||
should_disable = true
|
||||
|
||||
|
||||
refresh_state()
|
||||
|
||||
func _on_insect_tile_deselected(tile: InsectTile) -> void:
|
||||
refresh_state()
|
||||
|
||||
|
|
@ -141,6 +170,9 @@ func _on_pressed():
|
|||
if GameData.is_player_black != is_black and not GameData.debug:
|
||||
return
|
||||
|
||||
if not is_players_turn():
|
||||
return
|
||||
|
||||
selected = true
|
||||
|
||||
GameEvents.insect_selected.emit(self, is_black)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue