void Update() { if (players[playerTurnIndex].Skip) { players[playerTurnIndex].Skip = false; playerTurnIndex++; if (playerTurnIndex == players.Count) { playerTurnIndex = 0; } } if (upgradeTile) { bool check = false; foreach (Transform waypoint in waypoints) { if (waypoint.GetComponent <Waypoint>().OwnByPlayer&& waypoint.GetComponent <Waypoint>().PlayerIndex == playerTurnIndex) { check = true; } } if (!check) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, gameCanvas.transform); message.GetComponent <WarningMessage>().SetWarningText("You have no tiles to upgrade!"); upgradeTile = false; isLookingAtBoard = false; cardPanel.DeselectCard(); } else { isLookingAtBoard = true; cardPanel.gameObject.SetActive(false); lookAtBoardButton.gameObject.SetActive(false); cardPanel.RemoveCard(); } } if (playerSelectionEnabled && !playerIsSelected) { foreach (GameObject hud in selectionHUDS) { if (hud.GetComponent <PlayerHUD>().Selected&& playerSelectionEnabled) { playerIsSelected = true; hud.GetComponent <PlayerHUD>().Selected = false; selectedPlayerIndex = hud.GetComponent <PlayerHUD>().ImgIndex; //If the player cannot pick themselves if (!selectSelf) { if (playerTurnIndex == selectedPlayerIndex) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You cannot select yourself for this card!"); playerIsSelected = false; } } if (playerIsSelected) { //Checking card selection cards if (interactionIndex == (int)NetworkCard.CardIndex.DISCARDCARD || interactionIndex == (int)NetworkCard.CardIndex.STEALCARD || interactionIndex == (int)NetworkCard.CardIndex.SWITCHCARD || interactionIndex == (int)NetworkCard.CardIndex.SKIPTURN) { //Checking if the player already has a skipped turn if (interactionIndex == (int)NetworkCard.CardIndex.SKIPTURN && players[selectedPlayerIndex].Skip) { GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You cannot skip a players turn twice!"); playerIsSelected = false; } //Checking if the player has any cards to begin with else if (cardPanel.GetNumberCards(selectedPlayerIndex) == 0) { //Spawn a warning message GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("Player selected has no cards to pick from!"); playerIsSelected = false; } //Checking if the player has any card to swap (excluding the switch card itself) else if (interactionIndex == (int)NetworkCard.CardIndex.SWITCHCARD && cardPanel.GetNumberCards(playerTurnIndex) == 1) { GameObject message = Instantiate(warningPrefab, playerSelectionCanvas.gameObject.transform); message.GetComponent <WarningMessage>().SetWarningText("You have no cards to switch!"); playerIsSelected = false; } } //Double check because of the condition above if (playerIsSelected) { playerIsSelected = false; TurnOnPlayerSelection(false); DoAction(); } } } } } if (moveInteracting) { MovePlayerAction(selectedPlayerIndex); } else if (movePlayer && players[playerTurnIndex].GetComponent <TutorialPlayer>().WaypointIndex < waypoints.Length && !turnFinished && !IsMiniGameRunning) { //Smooth player moving transition players[playerTurnIndex].transform.position = Vector2.MoveTowards(players[playerTurnIndex].transform.position, waypoints[nextSpace].position, playerMoveSpeed * Time.deltaTime); players[playerTurnIndex].GetComponent <TutorialPlayer>().WalkAnimation(true); //This makes the player move from one waypoint to the next if (players[playerTurnIndex].transform.position == waypoints[nextSpace].position) { players[playerTurnIndex].GetComponent <TutorialPlayer>().WalkAnimation(false); //Once the player has reach the waypoint if (players[playerTurnIndex].GetComponent <TutorialPlayer>().WaypointIndex == nextSpace) { //Check if the waypoint is owned by a player if (waypoints[nextSpace].GetComponent <Waypoint>().OwnByPlayer&& playerTurnIndex != waypoints[nextSpace].GetComponent <Waypoint>().PlayerIndex) { pointSystem.MinusPoints(playerTurnIndex, waypoints[nextSpace].GetComponent <Waypoint>().Points); pointSystem.AddPoints(waypoints[nextSpace].GetComponent <Waypoint>().PlayerIndex, waypoints[nextSpace].GetComponent <Waypoint>().Points); } else { waypoints[nextSpace].GetComponent <Waypoint>().SetPlayer(playerTurnIndex); } playerTurnIndex++; turnFinished = true; } nextSpace++; //Once the player makes one full rotation around the map if (nextSpace == waypoints.Length) { nextSpace = 0; } //Switch players if (playerTurnIndex == players.Count) { currentRound++; playerTurnIndex = 0; StartCoroutine(RoundFinished()); } //Check if the game is finish if (currentRound == (maxTurns + 1)) { //TODO: //Game is finish } } } }