35 lines
956 B
GDScript3
35 lines
956 B
GDScript3
|
|
extends Node3D
|
||
|
|
|
||
|
|
var is_blacks_turn: bool = false
|
||
|
|
|
||
|
|
var current_turn: int = 1
|
||
|
|
|
||
|
|
@onready var map: HexGrid = $HexGrid
|
||
|
|
|
||
|
|
# Called when the node enters the scene tree for the first time.
|
||
|
|
func _ready():
|
||
|
|
GameEvents.insect_tile_finished_moving.connect(_on_insect_tile_finished_moving)
|
||
|
|
GameEvents.insect_tile_created.connect(_on_insect_tile_created)
|
||
|
|
|
||
|
|
GameEvents.game_started.emit()
|
||
|
|
|
||
|
|
func advance_turn():
|
||
|
|
GameEvents.turn_ended.emit(current_turn, map)
|
||
|
|
is_blacks_turn = !is_blacks_turn
|
||
|
|
current_turn = current_turn + 1
|
||
|
|
print(current_turn)
|
||
|
|
GameEvents.turn_started.emit(current_turn, map, is_blacks_turn)
|
||
|
|
|
||
|
|
func _on_insect_tile_finished_moving(tile: InsectTile, target: Vector4i) -> void:
|
||
|
|
print("moved")
|
||
|
|
print(multiplayer.is_server())
|
||
|
|
advance_turn()
|
||
|
|
|
||
|
|
func _on_insect_tile_created(tile: InsectTile, pos: Vector4i) -> void:
|
||
|
|
print("created")
|
||
|
|
advance_turn()
|
||
|
|
|
||
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
|
func _process(delta):
|
||
|
|
pass
|