third commit
This commit is contained in:
@@ -1,30 +1,43 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Main : Node
|
||||
{
|
||||
public bool _isPlayerTurn = true;
|
||||
public Player _player;
|
||||
public bool _isCommanderTurn = true;
|
||||
public Commander _commander;
|
||||
public GridMap _grid;
|
||||
public PackedScene _enemyScene = GD.Load<PackedScene>("res://Enemy.tscn");
|
||||
public List<Enemy> _enemies = new();
|
||||
public Random _rng = new();
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_player = GetNode<Player>("Player");
|
||||
_player.TurnDone += ChangeTurn;
|
||||
_commander = GetNode<Commander>("Commander");
|
||||
_grid = GetNode<GridMap>("GridMap");
|
||||
_commander.GlobalPosition = _grid.GlobalPosition;
|
||||
_commander.TurnDone += ChangeTurn;
|
||||
AddEnemy();
|
||||
_player.StartTurn();
|
||||
_commander.StartTurn();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
if (Input.IsActionJustPressed("escape"))
|
||||
{
|
||||
GetTree().Quit();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeTurn()
|
||||
{
|
||||
_isPlayerTurn = !_isPlayerTurn;
|
||||
if (_isPlayerTurn)
|
||||
_isCommanderTurn = !_isCommanderTurn;
|
||||
if (_isCommanderTurn)
|
||||
{
|
||||
GD.Print("Starting Player turn");
|
||||
_player.StartTurn();
|
||||
GD.Print("Starting Commander turn");
|
||||
_commander.StartTurn();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -33,6 +46,7 @@ public partial class Main : Node
|
||||
{
|
||||
_enemies[i].TakeTurn();
|
||||
}
|
||||
|
||||
AddEnemy();
|
||||
ChangeTurn();
|
||||
}
|
||||
@@ -42,8 +56,9 @@ public partial class Main : Node
|
||||
{
|
||||
Enemy newEnemy = _enemyScene.Instantiate<Enemy>();
|
||||
newEnemy.TurnDone += ChangeTurn;
|
||||
newEnemy.Position = new Vector2(_rng.Next((int)_player.GetViewportRect().Size.X), _player.GetViewportRect().Size.Y - 100);
|
||||
newEnemy._player = _player;
|
||||
newEnemy.PlaceOrMove(_grid._gridMarkers.Last()[_rng.Next(_grid._gridMarkers.Last().Count)]);
|
||||
newEnemy._commander = _commander;
|
||||
newEnemy._grid = _grid;
|
||||
_enemies.Add(newEnemy);
|
||||
AddChild(newEnemy);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user