public Coordinate FindCharacter(Character character) { for (int i = 0; i < 25; i++) { for (int j = 0; j < 25; j++) { if (GameBoard[i, j].Token == character) { return new Coordinate(i, j); } } } return null; }
public void endTurnCheck() { foreach (Square s in GameBoard) { if (s.onFire) { fireDamage(s); } } attacker = new Warrior("Test"); defender = new SharpShooter("Test2"); }
public void AddCharacter(Character character, int x, int y) { if (character != null) { if (attacker == null || (attacker != null && defender != null)) { FirstX = x; FirstY = y; attacker = character; defender = null; } else if (attacker != null && defender == null) { SecondX = x; SecondY = y; defender = character; } } }
public bool MoveCharacter(Character player, int[] moveTo, int[] currentLocation = null) { totalSquaresMoved = 0; if (currentLocation == null) { for (int i = 0; i < 15; i++) { for (int j = 0; j < 15; j++) { if (grid[i, j].Token == player) { currentLocation = new int[2]; currentLocation[0] = i; currentLocation[1] = j; } } } } int selectedX = moveTo[0]; int selectedY = moveTo[1]; if (grid[selectedX, selectedY].Token != null) { Console.WriteLine("Character at [" + currentLocation[0] + ", " + currentLocation[1] + "] Requested to \nmove to [" + moveTo[0] + ", " + moveTo[1] + "] which was an occupied square \n\n"); return false; } int currentX = currentLocation[0]; int currentY = currentLocation[1]; int xSquaresToMove = moveTo[0] - currentLocation[0]; int ySquaresToMove = moveTo[1] - currentLocation[1]; int xSquaresBeforeDiagonal = xSquaresToMove; int ySquaresBeforeDiagonal = ySquaresToMove; int diagonalSquaresThisTurn = 0; int squaresPerTurn = player.SquaresToMove; int currentlyAllowedSquares = squaresPerTurn; int attemptedSquaresToMove = 0; if (xSquaresBeforeDiagonal > 0) { for (int i = 0; i < xSquaresBeforeDiagonal; i++) { if (ySquaresToMove > 0) { --xSquaresToMove; --ySquaresToMove; ++diagonalSquaresThisTurn; ++totalSquaresMoved; } else if (ySquaresToMove < 0) { --xSquaresToMove; ++ySquaresToMove; ++diagonalSquaresThisTurn; ++totalSquaresMoved; } } } else if (xSquaresBeforeDiagonal < 0) { for (int i = 0; i > xSquaresBeforeDiagonal; i--) { if (ySquaresToMove > 0) { ++xSquaresToMove; --ySquaresToMove; ++diagonalSquaresThisTurn; ++totalSquaresMoved; } else if (ySquaresToMove < 0) { ++xSquaresToMove; ++ySquaresToMove; ++diagonalSquaresThisTurn; ++totalSquaresMoved; } } } for (int i = 1; i < diagonalSquaresThisTurn + 1; i++) { if (i % 2 == 0) { if ((attemptedSquaresToMove + 2) <= squaresPerTurn) { attemptedSquaresToMove += 2; currentlyAllowedSquares -= 2; totalSquaresMoved += 2; } else { int k = (diagonalSquaresThisTurn - i); i = diagonalSquaresThisTurn; xSquaresToMove += k; ySquaresToMove += k; } } else { if ((attemptedSquaresToMove + 1) <= squaresPerTurn) { ++attemptedSquaresToMove; currentlyAllowedSquares -= 1; ++totalSquaresMoved; } else { int k = (diagonalSquaresThisTurn - i); i = diagonalSquaresThisTurn; xSquaresToMove += k; ySquaresToMove += k; } } } if (currentlyAllowedSquares != 0 && xSquaresToMove > 0) { for (int i = xSquaresToMove; i > 0; i--) { if (currentlyAllowedSquares > 0) { --xSquaresToMove; --currentlyAllowedSquares; ++totalSquaresMoved; } else { i = 0; } } } else if (currentlyAllowedSquares != 0 && xSquaresToMove < 0) { for (int i = xSquaresToMove; i < 0; i++) { if (currentlyAllowedSquares > 0) { ++xSquaresToMove; --currentlyAllowedSquares; ++totalSquaresMoved; } else { i = 0; } } } if (currentlyAllowedSquares != 0 && ySquaresToMove > 0) { for (int i = ySquaresToMove; i > 0; i--) { if (currentlyAllowedSquares > 0) { --ySquaresToMove; --currentlyAllowedSquares; ++totalSquaresMoved; } else { i = 0; } } } else if (currentlyAllowedSquares != 0 && ySquaresToMove < 0) { for (int i = ySquaresToMove; i < 0; i++) { if (currentlyAllowedSquares > 0) { ++ySquaresToMove; --currentlyAllowedSquares; ++totalSquaresMoved; } else { i = 0; } } } if (xSquaresToMove == 0 && ySquaresToMove == 0) { grid[selectedX, selectedY].Token = player; grid[currentX, currentY].Token = null; player.SquaresLeft = (squaresPerTurn - totalSquaresMoved); return true; } else { if (player is Zed) { Console.WriteLine(((Zed)player).ZedClass + " at [" + currentLocation[0] + ", " + currentLocation[1] + "] Requested to\nmove to [" + moveTo[0] + ", " + moveTo[1] + "] and was denied due to lack of squares possible per turn"); Console.WriteLine("Squares per turn:" + player.SquaresToMove.ToString()); Console.WriteLine("\n\n"); } else { Console.WriteLine("Character at [" + currentLocation[0] + ", " + currentLocation[1] + "] Requested to\nmove to [" + moveTo[0] + ", " + moveTo[1] + "] and was denied due to lack of squares possible per turn"); Console.WriteLine("Squares per turn:" + player.SquaresToMove.ToString()); Console.WriteLine("\n\n"); } return false; } }
public void MakeUnAimedRangeAttack(Character player) { int totalSquares = player.SquaresToMove; int currentlyAvailableSquares = player.SquaresLeft; if ((totalSquares / 2) > currentlyAvailableSquares) { Console.WriteLine("Player does not have enough squares to perform this action"); } else { currentlyAvailableSquares -= (totalSquares / 2); //Do UnAimed Ranged Attack player.SquaresLeft = currentlyAvailableSquares; } }
public void StartTurn(Character player) { int squares = player.SquaresToMove; }