コード例 #1
0
 //These are used for UI testing purposes ONLY
 public void hitMe()
 {
     modifyHealth(5);
     if (!alive)
     {
         uiMgr.GameEnded(false);
     }
 }
コード例 #2
0
        void Update()
        {
            switch (currentState)
            {
            // Start: set the correct role for players.
            // Only SetRole when we are connected to the Server.
            case GameStatus.Start:
                if (sharingServiceReady)
                {
                    // check if local player is the only player, if so the local player
                    // becomes the Primary Plyaer,
                    // else Secondary.
                    SetRole();
                    currentState = GameStatus.Waiting;
                }
                break;

            case GameStatus.Waiting:
                // if local player is a primary player,
                // then initialize the Anchor, and upload it.
                if (SharingStage.Instance.ClientRole == ClientRole.Primary)
                {
                    InitAnchor();
                }
                // if local player is a secondary player, then keep sending requests for an anchor
                // until recives one.
                else if (SharingStage.Instance.ClientRole == ClientRole.Secondary && !ImportExportAnchorManager.Instance.anchor_ready)
                {
                    CustomMessages.Instance.SendAnchorRequest();
                }

                // TO CHANGE: WAIT FOR EVERYONE TO READY BEFORE PLAYING
                //
                if (ImportExportAnchorManager.Instance.AnchorEstablished)
                {
                    if (SharingStage.Instance.ClientRole == ClientRole.Secondary)
                    {
                        CustomMessages.Instance.PlayerReady();
                        currentState = GameStatus.Playing;
                    }
                    else if (secondPlayerReady)
                    {
                        currentState = GameStatus.Playing;
                    }
                }
                break;

            /* handles play logics :
             *  1. Turn on the orbManager for The Primary Player.
             *  2. Checks if local player is dead, if so, call the proper method WITHIN
             *     the player to model to handle death logic.
             *  3. Constantly (or not) check if the Primary player leaves or not, then change the role accordingly.
             * if Primary player:
             */
            case GameStatus.Playing:

                if (pickup.enabled == false)
                {
                    pickup.enabled = true;
                }

                if (keyword.enabled == false)
                {
                    keyword.enabled = true;
                }

                if (!Player.Instance.alive)
                {
                    currentState = GameStatus.Loses;
                    gameEnded    = true;
                    break;
                }

                if (!RemotePlayerManager.Instance.alive)
                {
                    currentState = GameStatus.End;
                    gameEnded    = true;
                    break;
                }

                break;

            case GameStatus.Loses:
                pickup.enabled  = false;
                keyword.enabled = false;
                uiMgr.GameEnded(false);
                if (gameEnded)
                {
                    Invoke("LoadMainMenu", 5);
                    gameEnded = false;
                }
                break;

            case GameStatus.End:
                pickup.enabled  = false;
                keyword.enabled = false;
                uiMgr.GameEnded(true);
                if (gameEnded)
                {
                    Invoke("LoadMainMenu", 5);
                    gameEnded = false;
                }
                break;
            }
        }