Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Turn-Based-System with one "Turn Over"-Button

Discussion in 'Multiplayer' started by Eruheran4, May 22, 2013.

  1. Eruheran4

    Eruheran4

    Joined:
    Jan 6, 2013
    Posts:
    19
    Hey everyone!

    I'm interested in Turn-Based-System. Now what I have:

    On Start() i have a loop for each player in the PlayerList till the boolean MatchIsFinished = true.
    Code (csharp):
    1. currentPlayer.PlayerTurnIsComplete = false;
    2. currentPlayer.PlayerTurn = true;
    On clicking a button in the OnGUI() booleans are switching.
    Code (csharp):
    1. currentPlayer.PlayerTurnIsComplete = true;
    2. currentPlayer.PlayerTurn = false;
    When PlayerTurn = false the button should be gray out or something like that, just not enabled. But now each Player has this button and wenn Player1 has finished his turn, I can't tell the OnGUI-Button that he should be disabled for Player1 but enabled for Player2.
    What i tried so far:
    Code (csharp):
    1. void OnGUI() { //NEXTPLAYER!!!!
    2.     if(currentPlayer.PlayerTurn  !currentPlayer.PlayerTurnIsComplete) {
    3.         if(GUI.Button(new Rect(10, 10, 150, 100), "Next Turn")) {
    4.             currentPlayer.PlayerTurnIsComplete = true;
    5.             currentPlayer.PlayerTurn = false;
    6.         }
    7.     }
    8. }
    Sorry for my not accomplished english. :S
    So far thanks for all the help.

    Edit: Also i have 3 public Players with all their variables: CurrentPlayer, MyPlayer, Otherplayer; and a List stored with all Players and with all their variables.
     
    Last edited: May 22, 2013