66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
public partial class Main : Node
|
|
{
|
|
public PlayArea _playArea;
|
|
public PlayerController _playerController;
|
|
public PegController _pegController;
|
|
public TurnController _turnController;
|
|
public Random _rng = new();
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
Globals._mouse = GetNode<MouseHandler>("MouseHandler");
|
|
_playArea = GetNode<PlayArea>("PlayArea");
|
|
_playerController = GetNode<PlayerController>("PlayerController");
|
|
_pegController = GetNode<PegController>("PegController");
|
|
|
|
_playerController._pegController = _pegController;
|
|
_pegController._playerController = _playerController;
|
|
|
|
_playerController._playArea = _playArea;
|
|
_pegController._playArea = _playArea;
|
|
_playerController._map = _playArea._map;
|
|
_pegController._map = _playArea._map;
|
|
|
|
_playerController.TurnDone += ChangeTurn;
|
|
_playerController.Death += EndGame;
|
|
_pegController.TurnDone += ChangeTurn;
|
|
|
|
_pegController.Initiate();
|
|
_playerController.SetUpTowers();
|
|
ChangeTurn();
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
base._Process(delta);
|
|
if (Input.IsActionJustPressed("escape"))
|
|
{
|
|
EndGame(_playerController);
|
|
}
|
|
if (Input.IsActionJustPressed("changeTurn"))
|
|
{
|
|
if(_turnController == _playerController)
|
|
{
|
|
_playerController.EndTurn();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeTurn()
|
|
{
|
|
_turnController = _turnController == _playerController ? _pegController : _playerController;
|
|
_turnController.StartTurn();
|
|
}
|
|
|
|
public void EndGame(PlayerController PLAYER)
|
|
{
|
|
GetTree().Quit();
|
|
}
|
|
|
|
}
|