public void OnTouch() { if (flag == PlayerAndResult.NONE && remainingDebounceTime <= 0 && (Game.player == PlayerAndResult.P1 || Game.player == PlayerAndResult.P2)) { if (Game.player == PlayerAndResult.P1) { sphere.SetActive(true); } if (Game.player == PlayerAndResult.P2) { cube.SetActive(true); } flag = Game.player; remainingDebounceTime = debounceTime; if (Game.mode == Mode.PVC) { Game.player = PlayerAndResult.AI; } else if (Game.player == PlayerAndResult.P1) { Game.player = PlayerAndResult.P2; TextPlayer.text = "P2"; TextPlayer.color = Color.blue; } else { Game.player = PlayerAndResult.P1; TextPlayer.text = "P1"; TextPlayer.color = Color.red; } } }
public void Clear() { sphere.SetActive(false); cube.SetActive(false); flag = PlayerAndResult.NONE; remainingDebounceTime = 0.3f; }
bool Checkresult() { for (int i = 0; i < 3; i++) { if (Grids[i, 0].flag != PlayerAndResult.NONE && Grids[i, 1].flag == Grids[i, 0].flag && Grids[i, 2].flag == Grids[i, 0].flag) { result = Grids[i, 0].flag; return(true); } } for (int i = 0; i < 3; i++) { if (Grids[0, i].flag != PlayerAndResult.NONE && Grids[1, i].flag == Grids[0, i].flag && Grids[2, i].flag == Grids[0, i].flag) { result = Grids[0, i].flag; return(true); } } if (Grids[0, 0].flag != PlayerAndResult.NONE && Grids[1, 1].flag == Grids[0, 0].flag && Grids[2, 2].flag == Grids[0, 0].flag) { result = Grids[0, 0].flag; return(true); } if (Grids[0, 2].flag != PlayerAndResult.NONE && Grids[1, 1].flag == Grids[0, 2].flag && Grids[2, 0].flag == Grids[0, 2].flag) { result = Grids[0, 2].flag; return(true); } if (Full()) { result = PlayerAndResult.TIE; return(true); } return(false); }
public void Restart() { for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { Grids[i, j].Clear(); gameState = State.ONGOING; result = PlayerAndResult.NONE; player = PlayerAndResult.P1; TextPlayer.text = "P1"; TextPlayer.color = Color.red; } } }
void Start() { placeGameBoard = GetComponent <PlaceGameBoard>(); Grids = new ARGrid[3, 3]; gameState = State.PAUSED; resultText.gameObject.SetActive(false); result = PlayerAndResult.NONE; mode = Mode.PVC; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { string name = "grid" + i.ToString() + j.ToString(); Grids[i, j] = gameBoard.transform.Find(name).gameObject.GetComponent <ARGrid>(); } } }
public void AI() { cube.SetActive(true); flag = Game.player; Game.player = PlayerAndResult.P1; }
void Start() { remainingDebounceTime = 0.3f; flag = PlayerAndResult.NONE; }