Saturday, 31 January 2026 01:00:43
This commit is contained in:
@@ -2,22 +2,33 @@ using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
public partial class Board : Sprite2D
|
||||
{
|
||||
public bool _active = false, _moveMade = false, _won = false;
|
||||
public List<Cell> _cells = new();
|
||||
public List<Shield> _shields = new();
|
||||
public Enemy _owner;
|
||||
public Actor _winner = null;
|
||||
public GoalName _winningPattern;
|
||||
public override void _Ready()
|
||||
{
|
||||
_cells = GetChildren().Where(c=>c is Cell).Cast<Cell>().ToList();
|
||||
for (int i = 0; i < _cells.Count; i++)
|
||||
_shields = GetChildren().Where(c=>c is Shield).Cast<Shield>().ToList();
|
||||
int xSize = (int)Texture.GetSize().X;
|
||||
int ySize = (int)Texture.GetSize().Y;
|
||||
for (int i = 0; i < _shields.Count; i++)
|
||||
{
|
||||
_cells[i]._address = i;
|
||||
_shields[i]._address = i;
|
||||
float shieldX = _shields[i].TextureNormal.GetSize().X;
|
||||
float shieldY = _shields[i].TextureNormal.GetSize().Y;
|
||||
|
||||
_shields[i].Scale = new Vector2(shieldX / (xSize/3), shieldY / (ySize/3));
|
||||
int c = i % 3 - 1;
|
||||
int r = (int)(i/3) - 1;
|
||||
|
||||
_shields[i].Position = new Vector2(xSize / 3f * c - shieldX / 2, ySize / 3f * r - shieldY / 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,14 +56,14 @@ public partial class Board : Sprite2D
|
||||
public void ClaimOwnership(Enemy OWNER)
|
||||
{
|
||||
_owner = OWNER;
|
||||
_cells.ForEach(c=>c._owner = OWNER);
|
||||
_cells.ForEach(c=>c._board = this);
|
||||
_shields.ForEach(c=>c._owner = OWNER);
|
||||
_shields.ForEach(c=>c._board = this);
|
||||
}
|
||||
|
||||
public void ClearBoard(){
|
||||
foreach (Cell cell in _cells)
|
||||
foreach (Shield shield in _shields)
|
||||
{
|
||||
cell.Mark();
|
||||
// shield.Mark();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +72,19 @@ public partial class Board : Sprite2D
|
||||
Disable(true);
|
||||
}
|
||||
|
||||
public Cell GetCellByTenant(Enemy TENANT)
|
||||
public Shield GetShieldByTenant(Enemy TENANT)
|
||||
{
|
||||
return _cells.Single(c=>c._tenant == TENANT);
|
||||
return _shields.Single(c=>c._tenant == TENANT);
|
||||
}
|
||||
|
||||
public Cell GetCellByAddress(int ADDRESS)
|
||||
public Shield GetShieldByAddress(int ADDRESS)
|
||||
{
|
||||
return _cells.Single(c=>c._address == ADDRESS);
|
||||
return _shields.Single(c=>c._address == ADDRESS);
|
||||
}
|
||||
|
||||
public List<Cell> GetCellsByOwner(Actor ACTOR)
|
||||
public List<Shield> GetShieldsByOwner(Actor ACTOR)
|
||||
{
|
||||
return _cells.Where(c=>c._marker == ACTOR).ToList();
|
||||
return _shields.Where(c=>c._marker == ACTOR).ToList();
|
||||
}
|
||||
|
||||
//THIS SHOULD BE MOVED INTO ACTION LOGIC
|
||||
@@ -82,17 +93,17 @@ public partial class Board : Sprite2D
|
||||
// for (int i = 0; i < REPEAT; i++)
|
||||
// {
|
||||
// Rotation += DEGREES * ((float)Math.PI / 180);
|
||||
// RenumberCells();
|
||||
// RenumberShields();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void RenumberCells()
|
||||
public void RenumberShields()
|
||||
{
|
||||
_cells = _cells.OrderBy(c => c.Position.Y).ThenBy(c => c.Position.X).ToList();
|
||||
_shields = _shields.OrderBy(c => c.Position.Y).ThenBy(c => c.Position.X).ToList();
|
||||
|
||||
for (int i = 0; i < _cells.Count; i++)
|
||||
for (int i = 0; i < _shields.Count; i++)
|
||||
{
|
||||
_cells[i]._address = i;
|
||||
_shields[i]._address = i;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -108,6 +119,6 @@ public partial class Board : Sprite2D
|
||||
_active = !DISABLED;
|
||||
Visible = !DISABLED;
|
||||
SetProcess(!DISABLED);
|
||||
_cells.ForEach(c=>c.Disable(DISABLED));
|
||||
_shields.ForEach(c=>c.Disable(DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user