Ejemplo n.º 1
0
        //private IEnumerator HoldToStart

        void Update()
        {
            { // Joining Logic
                for (int i = 0; i < ReInput.players.playerCount; i++)
                {
                    var player = ReInput.players.GetPlayer(i);
                    if (HasPlayerJoined(i))
                    {
                        continue;
                    }
                    if (player.GetButtonDown(RewiredConsts.Action.UISubmit))
                    {
                        PlayerJoin(i);
                    }
                }

                /*
                 * foreach (var slot in playerSlots)
                 * {
                 * if (!slot.Occupied) continue;
                 * var player = ReInput.players.GetPlayer(slot.RewiredPlayerId);
                 * if (player.GetButtonDown(RewiredConsts.Action.UICancel))
                 * {
                 *  PlayerLeave(slot.RewiredPlayerId);
                 * }
                 * }*/
                if (AllPlayersReady)
                {
                    StartTimerUI.gameObject.SetActive(true);
                    var k = MaxPressTime / holdToStartTime;
                    StartTimerUI.fillAmount = Mathf.Clamp01(k);
                    if (!startedGame && k > 1)
                    {
                        // Start Game
                        startedGame = true;
                        JoinedPlayersContainer.SetPlayingPlayers(
                            playerSlots
                            .Where(p => p.State == SlotState.Ready)
                            .Select(p => new JoinedPlayerData(p.Player, p.CurrentCharacter.Character))
                            .ToList()
                            );
                        UnityEngine.SceneManagement.SceneManager.LoadScene(SceneAfterCharacterSelectionName);
                    }
                }
                else
                {
                    StartTimerUI.gameObject.SetActive(false);
                }
            }
        }
Ejemplo n.º 2
0
    void Awake()
    {
        if (_instance == null)
        {
            DontDestroyOnLoad(gameObject);
            _instance = this;
        }
        else if (_instance != this)
        {
            Destroy(gameObject);
        }

        GetDefaultPlayers();
    }