示例#1
0
    void Update()
    {
        if (State == GameModeState.PreGame)
        {
            //If the pregame time runs out start the gamemode
            if (RemainingTime <= 0f)
            {
                State = GameModeState.Gameplay;

                PrepareForStart();
                StartGameMode();

                if (EnablePickUps)
                {
                    Pm.Enable();
                }
            }

            //Designed for Local play. Checks if a player wants to join or drop out during pregame
            if (PhotonNetwork.offlineMode)
            {
                for (var i = 0; i < TribotInput.InputCount; i++)
                {
                    if (TribotInput.GetButtonDown(TribotInput.InputButtons.Start, i))
                    {
                        if (!Players.Any(x => !x.Ai && x.InputIndex == i))
                        {
                            var player = Players.First(x => x.Ai);
                            player.Ai         = false;
                            player.InputIndex = i;
                            player.CreatePlayer(PField.GetSpawnLocation(player.Index));
                        }
                    }

                    if (TribotInput.GetButtonDown(TribotInput.InputButtons.Back, i))
                    {
                        if (Players.Any(x => !x.Ai && x.InputIndex == i))
                        {
                            var player = Players.First(x => !x.Ai && x.InputIndex == i);
                            player.Ai = true;
                            player.CreatePlayer(PField.GetSpawnLocation(player.Index));
                        }
                    }
                }
            }
        }

        if (State == GameModeState.Gameplay)
        {
            ExtendedUpdate();
        }
    }