public static void curveBall(bool curveLeft, ballDir d) { if (curveLeft) { if ((int)d == 0) { d = (ballDir)6; } else { d = (ballDir)(d - 1); } } else { if ((int)d == 5) { d = (ballDir)0; } else { d = (ballDir)(d + 1); } } }
public static void moveBall(Hex ballLocationStart, ballDir direction) { Hex curhex = ballLocationStart; switch (direction) { case ballDir.upLeft: for (int j = 0; j < 3; j++) { if (curhex.upLeftN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.upLeftN.piece != null && !(curhex.upLeftN.piece is Ball)) { // Program.game.action = "placeball"; Program.game.actionHex = curhex.upLeftN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.upLeftN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; // break; } else if (curhex.upLeftN.piece != null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else { curhex = curhex.upLeftN; } } break; case ballDir.up: for (int j = 0; j < 4; j++) { if (curhex.upN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.upN.piece != null && !(curhex.upN.piece is Ball)) { Program.game.action = "placeball"; Program.game.actionHex = curhex.upN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.upN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; break; } else if (curhex.upN.piece != null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else { curhex = curhex.upN; } } break; case ballDir.upRight: for (int j = 0; j < 4; j++) { if (curhex.upRightN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.upRightN.piece != null && !(curhex.upRightN.piece is Ball)) { Program.game.action = "placeball"; Program.game.actionHex = curhex.upRightN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.upRightN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; break; } else if (curhex.upRightN.piece != null) { Program.game.ballFlying = false; break; } else { curhex = curhex.upRightN; } } break; case ballDir.downRight: for (int j = 0; j < 4; j++) { if (curhex.downRightN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.downRightN.piece != null && !(curhex.downRightN.piece is Ball)) { Program.game.action = "placeball"; Program.game.actionHex = curhex.downRightN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.downRightN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; break; } else if (curhex.downRightN.piece != null) { Program.game.ballFlying = false; break; } else { curhex = curhex.downRightN; } } break; case ballDir.down: for (int j = 0; j < 4; j++) { if (curhex.downN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.downN.piece != null && !(curhex.downN.piece is Ball)) { Program.game.action = "placeball"; Program.game.actionHex = curhex.downN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.downN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; break; } else if (curhex.downN.piece != null) { Program.game.ballFlying = false; break; } else { curhex = curhex.downN; } } break; case ballDir.downLeft: for (int j = 0; j < 4; j++) { if (curhex.downLeftN == null) { Program.game.cyborgThrow = Team.Neutral; Program.game.ballFlying = false; break; } else if (curhex.downLeftN.piece != null && !(curhex.downLeftN.piece is Ball)) { Program.game.action = "placeball"; Program.game.actionHex = curhex.downLeftN; Program.game.ballPlaceTeam = Program.game.actionHex.piece.team; Program.game.abilityHexes = curhex.downLeftN.GetNeighbors(); Program.game.movementHexes = new List <Hex>(); ballLocationStart.piece = null; Program.game.ballFlying = false; Program.game.cyborgThrow = Team.Neutral; break; } else if (curhex.downLeftN.piece != null) { Program.game.ballFlying = false; break; } else { curhex = curhex.downLeftN; } } break; default: break; } if (Program.game.action != "placeball") { curhex.piece = ballLocationStart.piece; ballLocationStart.piece = null; } }
public List <Hex> getMoveAreaInterceptor(int dist, ballDir direction) { List <Hex> moveArea = new List <Hex>(); for (int i = 0; i < 6; i++) { Hex curhex = this; if (i == 0)//upleft { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.upLeftN == null) { break; } else if (curhex.upLeftN.piece is Ball) { curhex = curhex.upLeftN; moveArea.Add(curhex); break; } else if (curhex.upLeftN.piece != null) { break; } else { curhex = curhex.upLeftN; moveArea.Add(curhex); } } } if (i == 1)//up { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.upN == null) { break; } else if (curhex.upN.piece is Ball) { curhex = curhex.upN; moveArea.Add(curhex); break; } else if (curhex.upN.piece != null) { break; } else { curhex = curhex.upN; moveArea.Add(curhex); } } } if (i == 2)//upright { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.upRightN == null) { break; } else if (curhex.upRightN.piece is Ball) { curhex = curhex.upRightN; moveArea.Add(curhex); break; } else if (curhex.upRightN.piece != null) { break; } else { curhex = curhex.upRightN; moveArea.Add(curhex); } } } if (i == 3)//downright { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.downRightN == null) { break; } else if (curhex.downRightN.piece is Ball) { curhex = curhex.downRightN; moveArea.Add(curhex); break; } else if (curhex.downRightN.piece != null) { break; } else { curhex = curhex.downRightN; moveArea.Add(curhex); } } } if (i == 4)//down { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.downN == null) { break; } else if (curhex.downN.piece is Ball) { curhex = curhex.downN; moveArea.Add(curhex); break; } else if (curhex.downN.piece != null) { break; } else { curhex = curhex.downN; moveArea.Add(curhex); } } } if (i == 5)//downleft { int tempDist = dist; if ((int)direction == i) { tempDist++; } for (int j = 0; j < tempDist; j++) { if (curhex.downLeftN == null) { break; } else if (curhex.downLeftN.piece is Ball) { curhex = curhex.downLeftN; moveArea.Add(curhex); break; } else if (curhex.downLeftN.piece != null) { break; } else { curhex = curhex.downLeftN; moveArea.Add(curhex); } } } } return(moveArea); }