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
+44 -5
View File
@@ -6,7 +6,6 @@ public class Rook : Character
{
private static readonly Vector2[,] moves =
{
{
//up
new Vector2(0, 1),
@@ -55,13 +54,53 @@ public class Rook : Character
new Vector2(-8.5f, 0)
}
};
public override bool[,] GetValidMoves(Cell[,] cells, Game game)
{
bool[,] result = new bool[8, 8];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 8; j++)
{
Vector3 testPosition = transform.position + (Vector3)moves[i, j];
Cell testCell = game.GetCellOnPosition(testPosition);
if(testCell != null)
{
if (testCell.connected == 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);
result[x, y] = true;
}
else
{
if (testCell.connected.team != game.currentTeam)
{
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);
result[x, y] = true;
}
j = 8;
}
}
}
}
return result;
}
}
}