Пример #1
0
    private IEnumerator GameEndCorout()
    {
        yield return(new WaitForSeconds(endAnim.length + 1));

        onlineManager.Disconnect();
        Destroy(onlineManager.gameObject);

        SceneTransi.ToExecute exe = LoadLobby;
        SceneTransi.Instance.Transi(true, exe);
    }
Пример #2
0
    //Loop
    void FixedUpdate()
    {
        foreach (Message m in messages)
        {
            #region Join/Left Room
            if (m.Type == "PlayerJoined")
            {
                if (!teamAttributed)
                {
                    team           = (e_teams)m.GetInt(0);
                    teamAttributed = true;
                }
                if (m.GetInt(0) == 2)
                {
                    if (currentStatus == e_status.Default)
                    {
                        GetComponent <SelectionInputs>().StartSelection(team);
                        currentStatus = e_status.InSelection;
                    }
                }
            }

            else if (m.Type == "PlayerLeft")
            {
                if (currentStatus == e_status.InSelection)
                {
                    DisconnectMe();
                }
                else if (currentStatus == e_status.InGame)
                {
                    gameplayManager.GameEnd();
                    currentStatus = e_status.GameEnded;
                }
            }

            else if (m.Type == "FullRoom")
            {
                ListRoomsJoin(roomInfos.ToArray());
            }
            #endregion

            #region Initialization Checks
            else if (m.Type == "TeamValidated")
            {
                for (int i = 0; i < 6; i++)
                {
                    heroes[i] = m.GetInt((uint)i);
                }

                SceneTransi.ToExecute exe = LoadGameplay;
                SceneTransi.Instance.Transi(true, exe);
            }

            else if (m.Type == "SceneLoaded")
            {
                gameplayManager = FindObjectOfType <GameplayManager>();

                gameplayManager.Init(this, team, heroes);
                gameplayManager.OnEnnemyTurn += EnnemyTurn;

                SceneTransi.Instance.Transi(false, null);

                Destroy(GetComponent <SelectionInputs>());
                currentStatus = e_status.InGame;
            }

            else if (m.Type == "PlacementValidated")
            {
                gameplayManager.BoardManager.PlacementValidated();
            }

            else if (m.Type == "GameStart")
            {
                gameplayManager.GameStart();
            }
            #endregion

            #region In Game
            else if (m.Type == "MoveHeroPiece")
            {
                int index = -1;
                index = m.GetInt(0);
                Vector2Int desti   = new Vector2Int(m.GetInt(1), m.GetInt(2));
                bool       useMove = m.GetBoolean(3);

                gameplayManager.BoardManager.MoveHeroPiece(index, desti, useMove);
            }

            else if (m.Type == "ModifyStatHeroPiece")
            {
                int index = -1;
                index = m.GetInt(0);
                e_stats key      = (e_stats)m.GetInt(1);
                int     value    = m.GetInt(2);
                int     duration = m.GetInt(3);
                int     tick     = m.GetInt(4);

                gameplayManager.BoardManager.ModifyStatHeroPiece(index, key, value, duration, tick);
            }

            else if (m.Type == "YourTurn")
            {
                gameplayManager.YourTurn();
            }

            else if (m.Type == "Eliminated")
            {
                gameplayManager.Eliminated((e_teams)m.GetInt(0));

                if (m.GetInt(1) <= 1)
                {
                    gameplayManager.GameEnd();
                    currentStatus = e_status.GameEnded;
                }
            }
            #endregion
        }

        messages.Clear();
    }