public void nextTurn() { if (currentID > -1 && player [currentID].isWin()) { Debug.Log("winner: " + currentID); CountUI.SetActive(true); countUI.fontSize = 50; countUI.text = "Team: " + teams [currentID] + " Wins"; setWin(); } else { currentID = (currentID + 1) % 4; updateTeam(); if (currentID == myID) { //diceContainer.SetActive (true); myTurn(); } else { //diceContainer.SetActive (false); wait(); } boardScript.resetMoves(); } }
// Update is called once per frame void Update() { if (gameState != state.Pause && gameState != state.Win && gameState != state.Start && gameState != state.Move) { updateTimer(); } //Debug.Log (gameState.ToString()); switch (gameState) { case state.Pause: break; case state.Start: diceTimer -= Time.deltaTime; countUI.text = "" + (int)diceTimer; if (diceTimer < 0) { GameUI.SetActive(true); diceContainer.SetActive(true); CountUI.SetActive(false); nextTurn(); time.text = "" + (int)timer; if (myID == 0) { myTurn(); } else { wait(); } } break; case state.MyTurn: setWin(); //its myturn roll dice if (Input.GetMouseButtonDown(0)) { boardScript.Roll(); /*if (currentID == myID) * boardScript.testRoll (5);*/ //Debug.Log (boardScript.getRollCast ()); diceTimer = 4; currentFaceRotation = face [boardScript.getRollCast()]; diceRoll(); } //currentID = (currentID + 1) % 4; //gameState = state.selectPawn; break; case state.wait: boardScript.Roll(); //Debug.Log (boardScript.getRollCast ()); diceTimer = 3; currentFaceRotation = face [boardScript.getRollCast()]; diceRoll(); //AI Or opponents turn logic here. break; case state.diceroll: if (diceTimer > 1) { diceTimer -= Time.deltaTime; diceObj.transform.Rotate(Vector3.right * 200 * Time.deltaTime); diceObj.transform.Rotate(Vector3.up * 500 * Time.deltaTime); } else if (Vector3.Distance(diceObj.transform.eulerAngles, currentFaceRotation) > 0.01f && diceTimer > 0) { diceTimer -= Time.deltaTime; diceObj.transform.eulerAngles = Vector3.Lerp(diceObj.transform.rotation.eulerAngles, currentFaceRotation, 0.1f); } else { diceObj.transform.eulerAngles = currentFaceRotation; if (boardScript.getRollCast() == 5 || player[currentID].isActive()) // player [currentID].pawnActive [0] || player [currentID].pawnActive [1] || player [currentID].pawnActive [2] || player [currentID].pawnActive [3]) { selectPawn(); } else if (!(player[0].isActive() || player[1].isActive() || player[2].isActive() || player[3].isActive())) //replace with a bool { if (startRolls < 2) { startRolls++; currentID--; changeturn(); } else { startRolls = 0; changeturn(); } } else { changeturn(); } } break; case state.selectPawn: //if it was my turn then after diceroll then select one of pawn to move if possible. if (currentID == myID) { boardScript.UpdateSelection(currentID); if (Input.GetMouseButtonDown(0)) { if (boardScript.updateSelectedPawn(player[currentID])) { move(); } } } else { if (boardScript.AISelect(player [currentID])) { move(); } } break; case state.Move: if (boardScript.canMove()) { boardScript.moveUpdate(currentID); } else { boardScript.killPawns(player, currentID); changeturn(); } break; case state.nextturn: diceTimer -= Time.deltaTime; if (diceTimer < 0) { timer = turnTime; nextTurn(); } break; case state.Win: break; default: break; } }
public void gameStart() { diceTimer = 4; CountUI.SetActive(true); gameState = state.Start; }