2024-03-16 19:56:22 +01:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
|
|
const BEE = preload("res://Tile/Prefabs/Bee.tres")
|
|
|
|
|
|
|
|
|
|
var bees: Array[InsectTile] = []
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready():
|
|
|
|
|
GameEvents.insect_tile_created.connect(_on_insect_tile_created)
|
|
|
|
|
GameEvents.turn_ended.connect(_on_turn_ended)
|
|
|
|
|
|
|
|
|
|
func _on_insect_tile_created(tile: InsectTile, pos: Vector4i) -> void:
|
|
|
|
|
if is_same(BEE, tile.resource):
|
|
|
|
|
bees.push_back(tile)
|
|
|
|
|
|
2024-03-22 01:37:05 +01:00
|
|
|
GameData.bees_placed[tile.is_black] = tile
|
|
|
|
|
|
|
|
|
|
#if tile.is_black == GameData.is_player_black:
|
|
|
|
|
# GameData.has_bee_been_placed = true
|
2024-03-16 19:56:22 +01:00
|
|
|
|
|
|
|
|
func _on_turn_ended(turn_num: int, map: HexGrid) -> void:
|
|
|
|
|
var black_lost: bool = false
|
|
|
|
|
var white_lost: bool = false
|
|
|
|
|
|
|
|
|
|
for b in bees:
|
|
|
|
|
if map.get_empty_neighbours(b.coordinates).size() == 0:
|
|
|
|
|
if b.is_black:
|
|
|
|
|
black_lost = true
|
|
|
|
|
else:
|
|
|
|
|
white_lost = true
|
|
|
|
|
|
|
|
|
|
if black_lost or white_lost:
|
|
|
|
|
GameEvents.game_over.emit(black_lost, white_lost)
|