commit no. 5
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class PlayerController : TurnController
|
||||
{
|
||||
public PackedScene _commanderScene = GD.Load<PackedScene>("res://Commander.tscn");
|
||||
public List<Tower> _towers = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public void SetUpTowers(int TOWER_COUNT = 8)
|
||||
{
|
||||
Tower tower = GetNode<Tower>("Tower1");
|
||||
Vector2 towerPositionCorrection = tower._area.GetNode<CollisionShape2D>("Bounds").Shape.GetRect().Size / 2 * (Vector2.Right + Vector2.Up);
|
||||
float spaceBetweenTowers = _grid._sizeInPixels.X / (TOWER_COUNT - 1);
|
||||
tower.Position = _grid.Position - _grid._sizeInPixels / 2 + towerPositionCorrection;
|
||||
|
||||
_towers.Add(tower);
|
||||
for (int i = 1; i < TOWER_COUNT; i++)
|
||||
{
|
||||
Tower newTower = (Tower)tower.Duplicate();
|
||||
newTower.Position += new Vector2(spaceBetweenTowers * i - towerPositionCorrection.X * i / (TOWER_COUNT - 1) * 2, 0);
|
||||
_towers.Add(newTower);
|
||||
AddChild(newTower);
|
||||
}
|
||||
|
||||
Commander newCommander = _commanderScene.Instantiate<Commander>();
|
||||
_towers[3]._commander = newCommander;
|
||||
_towers[3].AddChild(newCommander);
|
||||
}
|
||||
|
||||
public override void StartTurn()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user