Ejemplo n.º 1
0
 public void ShowInformation()
 {
     if (isLocalPlayer)
     {
         GameObject canvas = GameObject.Find("Canvas");
         if (MyLobbyManager.s_Singleton.isInGame)
         {
             Animator anim = canvas.GetComponent <Animator>();
             anim.SetTrigger("LobbyToGame");
         }
         ArenaInfo local = GameObject.Find("Main User").GetComponent <ArenaInfo>();
         ArenaInfo opp   = GameObject.Find("Enemy").GetComponent <ArenaInfo>();
         for (int i = 0; i < MyLobbyManager.s_Singleton.lobbySlots.Length; ++i)
         {
             MyLobbyPlayer cur = MyLobbyManager.s_Singleton.lobbySlots[i] as MyLobbyPlayer;
             if (cur.isLocalPlayer)
             {
                 local.rank.text     = cur.rank;
                 local.rating.text   = cur.rating;
                 local.nickname.text = MyLobbyManager.s_Singleton.localNick = cur.nickname;
             }
             else
             {
                 FishVSContainer fishVSContainer = FindObjectOfType <FishVSContainer>();
                 fishVSContainer.instantiateFish(cur.fishName);
                 opp.rank.text     = cur.rank;
                 opp.rating.text   = cur.rating;
                 opp.nickname.text = MyLobbyManager.s_Singleton.oppNick = cur.nickname;
             }
         }
     }
 }
Ejemplo n.º 2
0
        IEnumerator showResult()
        {
            if (NetworkServer.active)
            {
                StartCoroutine(uploadMatchData());
            }
            GameObject canvas = GameObject.Find("Canvas");
            Animator   anim   = canvas.GetComponent <Animator>();

            anim.SetTrigger("GameToResult");
            ResultInfo resultInfo     = GameObject.Find("Result").GetComponent <ResultInfo>();
            int        mainTotalScore = 0;
            int        oppTotalScore  = 0;

            for (int i = 0; i < s_Singleton.lobbySlots.Length; ++i)
            {
                MyLobbyPlayer cur = s_Singleton.lobbySlots[i] as MyLobbyPlayer;
                if (cur.isLocalPlayer)
                {
                    resultInfo.main[0].text = cur.round1Score.ToString();
                    resultInfo.main[1].text = cur.round2Score.ToString();
                    resultInfo.main[2].text = cur.round3Score.ToString();
                    mainTotalScore          = cur.totalScore;
                }
                else
                {
                    resultInfo.opp[0].text = cur.round1Score.ToString();
                    resultInfo.opp[1].text = cur.round2Score.ToString();
                    resultInfo.opp[2].text = cur.round3Score.ToString();
                    oppTotalScore          = cur.totalScore;
                }
            }
            int mainTotalCount = 0;
            int oppTotalCount  = 0;

            //Time to wait Game to Result show total score
            yield return(new WaitForSecondsRealtime(4.5f));

            while (mainTotalCount < mainTotalScore || oppTotalCount < oppTotalScore)
            {
                yield return(null);

                if (mainTotalCount < mainTotalScore)
                {
                    ++mainTotalCount;
                }
                if (oppTotalCount < oppTotalScore)
                {
                    ++oppTotalCount;
                }
                resultInfo.main[3].text = mainTotalCount.ToString();
                resultInfo.opp[3].text  = oppTotalCount.ToString();
            }
            yield return(new WaitForSecondsRealtime(1.0f));

            if (mainTotalScore > oppTotalScore)
            {
                resultInfo.resultAnim.SetTrigger("Win");
            }
            else if (mainTotalScore == oppTotalScore)
            {
                resultInfo.resultAnim.SetTrigger("Draw");
            }
            else
            {
                resultInfo.resultAnim.SetTrigger("Lose");
            }
            //Time to animate above animation
            yield return(new WaitForSecondsRealtime(4.0f));

            //Announce to server that this client have done result animation
            for (int i = 0; i < lobbySlots.Length; ++i)
            {
                if (lobbySlots[i].isLocalPlayer)
                {
                    (lobbySlots[i] as MyLobbyPlayer).CmdDoneLoadResultScene();
                }
            }
            MainPlayer.instance.updatePlayerData();
            //Wait to out game at the same time
            bool wait = false;

            while (!wait)
            {
                yield return(null);

                wait = (lobbySlots[0] as MyLobbyPlayer).loadResultScene && (lobbySlots[1] as MyLobbyPlayer).loadResultScene;
            }
            //should be call on both or client won't return to arena scene
            s_Singleton.backDelegate();
            //Client dont auto back to arena scene after the game
            if (!NetworkServer.active)
            {
                SceneManager.LoadSceneAsync("Arena");
            }
        }