Refactoring UI and Tile logic (to allow for Hotseat/LAN/Online multiplayer)
This commit is contained in:
parent
1ed0ec226d
commit
d688eaf9c6
17 changed files with 591 additions and 17 deletions
|
|
@ -24,8 +24,8 @@ 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 is_players_turn() -> bool:
|
||||
return is_blacks_turn == is_black or GameData.debug
|
||||
|
||||
func update_color(_is_black: bool) -> void:
|
||||
is_black = _is_black
|
||||
|
|
@ -37,7 +37,10 @@ func update_color(_is_black: bool) -> void:
|
|||
update_tile_count_display()
|
||||
insect_icon.texture = insect_resource.ui_texture
|
||||
|
||||
if is_black != GameData.is_player_black and not GameData.debug:
|
||||
if GameData.is_hot_seat:
|
||||
return
|
||||
|
||||
if is_black != is_blacks_turn and not GameData.debug:
|
||||
disabled = true
|
||||
return
|
||||
|
||||
|
|
@ -110,8 +113,8 @@ func _ready() -> void:
|
|||
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 turn_num >= 7 and not GameData.bees_placed.has(is_black): #has_bee_been_placed:
|
||||
if is_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):
|
||||
|
|
@ -120,8 +123,7 @@ func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> voi
|
|||
else:
|
||||
#lock
|
||||
should_disable = true
|
||||
|
||||
|
||||
|
||||
refresh_state()
|
||||
|
||||
func _on_insect_tile_deselected(tile: InsectTile) -> void:
|
||||
|
|
@ -138,15 +140,16 @@ func _on_insect_selected(button: InsectButton, _is_black: bool) -> void:
|
|||
disable()
|
||||
|
||||
func hover() -> void:
|
||||
if GameData.is_player_black != is_black and not GameData.debug:
|
||||
return
|
||||
|
||||
#if is_blacks_turn != is_black and not GameData.debug:
|
||||
# return
|
||||
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property(hex, "position", Vector2(0, -16), 0.1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING)
|
||||
|
||||
func unhover() -> void:
|
||||
if GameData.is_player_black != is_black and not GameData.debug:
|
||||
return
|
||||
#if is_blacks_turn != is_black and not GameData.debug:
|
||||
# return
|
||||
|
||||
var tween = get_tree().create_tween()
|
||||
tween.tween_property(hex, "position", Vector2(0, 0), 0.25).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING)
|
||||
|
|
@ -164,10 +167,17 @@ func _on_mouse_exited():
|
|||
unhover()
|
||||
|
||||
func _on_pressed():
|
||||
# We can only press under these conditions
|
||||
# Check if its the currents player turn (is black)
|
||||
# If hotseat: we're done
|
||||
# If multiplayer: Check if GameData.is_player_black is correct, this prevents
|
||||
# the other player from using this button on their game instance
|
||||
|
||||
#GameData.is_hot_seat
|
||||
if is_empty():
|
||||
return
|
||||
|
||||
if GameData.is_player_black != is_black and not GameData.debug:
|
||||
if not is_blacks_turn == is_black and not GameData.debug:
|
||||
return
|
||||
|
||||
if not is_players_turn():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue