Recode finished version 1

This commit is contained in:
firefighter198
2021-10-05 15:45:27 +02:00
parent af90d64644
commit cb3e7563a6
11 changed files with 9338 additions and 7758 deletions
+55 -1
View File
@@ -4,8 +4,62 @@ using UnityEngine;
public class King : Character
{
public static readonly Vector2[] moves =
{
//up
new Vector2(0, 1),
//down
new Vector2(0, -1),
//right
new Vector2(1, 0),
//left
new Vector2(-1, 0),
//up, right
new Vector2(1, 1),
//up, left
new Vector2(-1, 1),
//down, right
new Vector2(1, -1),
//down, left
new Vector2(-1, -1)
};
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
{
return null;
bool[,] result = new bool[8, 8];
foreach (Vector2 move in moves)
{
Vector3 testPosition = transform.position + (Vector3)move;
Cell testCell = game.GetCellOnPosition(testPosition + Vector3.back);
if (testCell != null)
{
int x, y;
string nameX = testCell.gameObject.name.Substring(5, 1);
string nameY = testCell.gameObject.name.Substring(7, 1);
x = int.Parse(nameX);
y = int.Parse(nameY);
if (testCell.connected == null)
{
result[x, y] = true;
}
else
{
Character testCharacter = testCell.connected;
if (testCharacter.team != game.currentTeam)
{
result[x, y] = true;
}
}
}
}
return result;
}
}