public void MakeMove(GameManager.Move move) { string data = JsonUtility.ToJson(move); socket.Emit("make move", new JSONObject(data)); Debug.Log("emit make move"); }
void UpdateMove(int p, GameManager.Move m) { if (p == 1) { p1Move = m; } else if (p == 2) { p2Move = m; } }
public void DisableOption(GameManager.Move m) { switch (m) { case GameManager.Move.STRIKE: strikeButton.SetActive(false); break; case GameManager.Move.HEAVY: heavyButton.SetActive(false); break; case GameManager.Move.CRIPPLE: crippleButton.SetActive(false); break; case GameManager.Move.BLOCK: blockButton.SetActive(false); break; case GameManager.Move.GRAB: grabButton.SetActive(false); break; case GameManager.Move.SHOVE: shoveButton.SetActive(false); break; case GameManager.Move.COUNTER: counterButton.SetActive(false); break; case GameManager.Move.LEAP: leapButton.SetActive(false); break; } }
private int[,] removeTokens(int[,] gs, Vector2 newPos, GameManager.Move move, int color) { int[,] copyGs = gs; int otherCol = (color == 1) ? 2 : 1; if (move == GameManager.Move.up) { //FORWARD ATTACK if (newPos.y - 1 > 0 && copyGs[(int)newPos.x, (int)newPos.y - 1] % 10 == otherCol) { while (newPos.y - 1 > 0 && copyGs[(int)newPos.x, (int)newPos.y - 1] % 10 == otherCol) { copyGs[(int)newPos.x, (int)newPos.y - 1] -= otherCol; newPos.y--; } } //BACKWARD ATTACK else if (newPos.y + 2 < 6 && copyGs[(int)newPos.x, (int)newPos.y + 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x, newPos.y + 1), GameManager.Move.down, color); } } else if (move == GameManager.Move.down) { //FORWARD ATTACK if (newPos.y + 1 < 6 && copyGs[(int)newPos.x, (int)newPos.y + 1] % 10 == otherCol) { while (newPos.y + 1 < 6 && copyGs[(int)newPos.x, (int)newPos.y + 1] % 10 == otherCol) { copyGs[(int)newPos.x, (int)newPos.y + 1] -= otherCol; newPos.y++; } } //BACKWARD ATTACK else if (newPos.y - 2 > 0 && copyGs[(int)newPos.x, (int)newPos.y - 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x, newPos.y - 2), GameManager.Move.up, color); } } else if (move == GameManager.Move.left) { //FORWARD ATTACK if (newPos.x - 1 > 0 && copyGs[(int)newPos.x - 1, (int)newPos.y] % 10 == otherCol) { while (newPos.x - 1 > 0 && copyGs[(int)newPos.x - 1, (int)newPos.y] % 10 == otherCol) { copyGs[(int)newPos.x - 1, (int)newPos.y] -= otherCol; newPos.x--; } } //BACKWARD ATTACK else if (newPos.x + 2 < 10 && copyGs[(int)newPos.x + 2, (int)newPos.y] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x + 1, newPos.y), GameManager.Move.right, color); } } else if (move == GameManager.Move.right) { //FORWARD ATTACK if (newPos.x + 1 < 10 && copyGs[(int)newPos.x + 1, (int)newPos.y] % 10 == otherCol) { while (newPos.x + 1 < 10 && copyGs[(int)newPos.x + 1, (int)newPos.y] % 10 == otherCol) { copyGs[(int)newPos.x + 1, (int)newPos.y] -= otherCol; newPos.x++; } } //BACKWARD ATTACK else if (newPos.x - 2 > 0 && copyGs[(int)newPos.x - 2, (int)newPos.y] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x - 1, newPos.y), GameManager.Move.left, color); } } else if (move == GameManager.Move.upLeft) { //FORWARD ATTACK if (newPos.x - 1 > 0 && newPos.y - 1 > 0 && copyGs[(int)newPos.x - 1, (int)newPos.y - 1] % 10 == otherCol) { while (newPos.x - 1 > 0 && newPos.y - 1 > 0 && copyGs[(int)newPos.x - 1, (int)newPos.y - 1] % 10 == otherCol) { copyGs[(int)newPos.x - 1, (int)newPos.y - 1] -= otherCol; newPos.x--; newPos.y--; } } //BACKWARD ATTACK else if (newPos.x + 2 < 10 && newPos.y + 2 < 6 && copyGs[(int)newPos.x + 2, (int)newPos.y + 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x + 1, newPos.y + 1), GameManager.Move.downRight, color); } } else if (move == GameManager.Move.upRight) { //FORWARD ATTACK if (newPos.x + 1 < 10 && newPos.y - 1 > 0 && copyGs[(int)newPos.x + 1, (int)newPos.y - 1] % 10 == otherCol) { while (newPos.x + 1 < 10 && newPos.y - 1 > 0 && copyGs[(int)newPos.x + 1, (int)newPos.y - 1] % 10 == otherCol) { copyGs[(int)newPos.x + 1, (int)newPos.y - 1] -= otherCol; newPos.x++; newPos.y--; } } //BACKWARD ATTACK else if (newPos.x - 2 > 0 && newPos.y + 2 < 6 && copyGs[(int)newPos.x - 2, (int)newPos.y + 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x - 1, newPos.y + 1), GameManager.Move.downLeft, color); } } else if (move == GameManager.Move.downLeft) { //FORWARD ATTACK if (newPos.x - 1 > 0 && newPos.y + 1 < 6 && copyGs[(int)newPos.x - 1, (int)newPos.y + 1] % 10 == otherCol) { while (newPos.x - 1 > 0 && newPos.y + 1 < 6 && copyGs[(int)newPos.x - 1, (int)newPos.y + 1] % 10 == otherCol) { copyGs[(int)newPos.x - 1, (int)newPos.y + 1] -= otherCol; newPos.x--; newPos.y++; } } //BACKWARD ATTACK else if (newPos.x + 2 < 10 && newPos.y - 2 > 0 && copyGs[(int)newPos.x + 2, (int)newPos.y - 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x + 1, newPos.y - 1), GameManager.Move.upRight, color); } } else if (move == GameManager.Move.downRight) { //FORWARD ATTACK if (newPos.x + 1 < 10 && newPos.y + 1 < 6 && copyGs[(int)newPos.x + 1, (int)newPos.y + 1] % 10 == otherCol) { while (newPos.x + 1 < 10 && newPos.y + 1 < 6 && copyGs[(int)newPos.x + 1, (int)newPos.y + 1] % 10 == otherCol) { copyGs[(int)newPos.x + 1, (int)newPos.y + 1] -= otherCol; newPos.x++; newPos.y++; } } //BACKWARD ATTACK else if (newPos.x - 2 > 0 && newPos.y - 2 > 0 && copyGs[(int)newPos.x - 2, (int)newPos.y - 2] % 10 == otherCol) { removeTokens(copyGs, new Vector2(newPos.x - 1, newPos.y - 1), GameManager.Move.upLeft, color); } } return(copyGs); }
private ValidState simulateMove(int[,] gs, Vector2 start, GameManager.Move move, int color) { int[,] copyGs = new int[10, 6]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 6; j++) { copyGs[i, j] = gs[i, j]; } } Vector2 end = new Vector2(start.x, start.y); if (move == GameManager.Move.up) { if (end.y - 1 > 0 && copyGs[(int)end.x, (int)end.y - 1] % 10 == 0) { end.y -= 1; } } else if (move == GameManager.Move.down) { if (end.y + 1 < 6 && copyGs[(int)end.x, (int)end.y + 1] % 10 == 0) { end.y += 1; } } else if (move == GameManager.Move.left) { if (end.x - 1 > 0 && copyGs[(int)end.x - 1, (int)end.y] % 10 == 0) { end.x -= 1; } } else if (move == GameManager.Move.right) { if (end.x + 1 < 10 && copyGs[(int)end.x + 1, (int)end.y] % 10 == 0) { end.x += 1; } } else if (move == GameManager.Move.upLeft) { if (end.x - 1 > 0 && end.y - 1 > 0 && copyGs[(int)end.x - 1, (int)end.y - 1] % 10 == 0 && copyGs[(int)start.x, (int)start.y] >= 20) { end.x -= 1; end.y -= 1; } } else if (move == GameManager.Move.upRight) { if (end.x + 1 < 10 && end.y - 1 > 0 && copyGs[(int)end.x + 1, (int)end.y - 1] % 10 == 0 && copyGs[(int)start.x, (int)start.y] >= 20) { end.x += 1; end.y -= 1; } } else if (move == GameManager.Move.downLeft) { if (end.x - 1 > 0 && end.y + 1 < 6 && copyGs[(int)end.x - 1, (int)end.y + 1] % 10 == 0 && copyGs[(int)start.x, (int)start.y] >= 20) { end.x -= 1; end.y += 1; } } else if (move == GameManager.Move.downRight) { if (end.x + 1 < 10 && end.y + 1 < 6 && copyGs[(int)end.x + 1, (int)end.y + 1] % 10 == 0 && copyGs[(int)start.x, (int)start.y] >= 20) { end.x += 1; end.y += 1; } } if (end == start) { return(new ValidState(false, null)); } else { copyGs[(int)start.x, (int)start.y] -= color; copyGs[(int)end.x, (int)end.y] += color; copyGs[0, 0] = (int)start.x; copyGs[0, 1] = (int)start.y; copyGs[0, 2] = (int)end.x; copyGs[0, 3] = (int)end.y; return(new ValidState(true, removeTokens(copyGs, end, move, color))); } }
public void Weaken() { GameManager.Move r = available[Random.Range(0, available.Count)]; DisableOption(r); available.Remove(r); }