void Start() { if (customIsServer) { playerTurnhandler = rightTurnhandlerInScene; otherTurnhandler = leftTurnhandlerInScene; } else { playerTurnhandler = leftTurnhandlerInScene; otherTurnhandler = rightTurnhandlerInScene; } inGameMenuHandler.SetActive(true); ingameCanvas.SetActive(true); matchmakingCanvas.SetActive(false); playerTurnhandler.gameObject.SetActive(true); playerTurnhandler.currentPlanTimeLeft = planTime; otherTurnhandler.gameObject.SetActive(true); playingField.SetActive(true); robotDeselectionCollider.SetActive(true); ball.gameObject.SetActive(true); InititializeGame(); //activate the playeturnhandler only playerTurnhandler.Activate(true); planCountDownCoroutine = StartCoroutine(CountDownPlanningTime()); }
void OnScore() { //tell gametimer and the unpause to stop StopAllCoroutines(); //do waht unpause does at the end currentActiveTurnhandler = null; NewTurn(); PauseGame(); //robots reset their position by themselves }
void ChooseNextCurrentTurnHandler() { if (currentActiveTurnhandler == turnHandler1 && isTH1Done && isTH2Done == false) { currentActiveTurnhandler = turnHandler2; } else if (currentActiveTurnhandler == turnHandler2 && isTH2Done && isTH1Done == false) { currentActiveTurnhandler = turnHandler1; } else if (isTH1Done && isTH2Done) { currentActiveTurnhandler = null; } }
void NewTurn() { roundCount++; if (roundCount % 2 == 0) { currentActiveTurnhandler = turnHandler1; turnHandler1.CurrentPlanTimeLeft = planTime; } else { currentActiveTurnhandler = turnHandler2; turnHandler2.CurrentPlanTimeLeft = planTime; } turnHandler1.CurrentPlanTimeLeft = planTime; isTH1Done = false; turnHandler2.CurrentPlanTimeLeft = planTime; isTH2Done = false; ActivateTurnHandler(true); }
//If we replayed the last turn, we dont want to do the newturn stuff IEnumerator UnpauseGame() { Debug.Log("GAME IS UNPAUSED!"); paused = false; ball.Unpause(); ActivateTurnHandler(false); planTimeText.enabled = false; turnHandler1.UnpauseGame(); turnHandler2.UnpauseGame(); StartCoroutine(gameTimer.CountDownSeconds((int)roundTime)); yield return(new WaitForSeconds(roundTime)); currentActiveTurnhandler = null; NewTurn(); PauseGame(); }