28 lines
618 B
GDScript
28 lines
618 B
GDScript
extends Node
|
|
|
|
# TurnManager - Manages turn-based gameplay flow
|
|
|
|
signal turn_changed(player_id)
|
|
signal turn_ended()
|
|
|
|
var current_turn_index: int = 0
|
|
var turn_based_mode: bool = false
|
|
|
|
func next_turn(players: Array):
|
|
if turn_based_mode and players.size() > 0:
|
|
current_turn_index = (current_turn_index + 1) % players.size()
|
|
var next_player_id = players[current_turn_index]
|
|
emit_signal("turn_changed", next_player_id)
|
|
return next_player_id
|
|
return -1
|
|
|
|
func end_current_turn():
|
|
emit_signal("turn_ended")
|
|
|
|
func reset_turn():
|
|
current_turn_index = -1
|
|
|
|
func reset():
|
|
current_turn_index = 0
|
|
turn_based_mode = false
|