Beispiel #1
0
        public void AddToScoreBoard()         // IS LAUNCHED AFTER SELECT TEAM OR NO TEAM FOR ADD OBJECT IN SCOREBOARD
        {
            foreach (MPPlayer entry in playerListEntries)
            {
                Destroy(entry.ObjForScorepanel);                 // DESTROY ALL OBJECT IN SCOREBOARD FOR REFRESH
            }

            playerListEntries.Clear();                                                     // DESTROY ALL PLAYERS IN LIST FOR REFRESH

            foreach (Player p in PhotonNetwork.PlayerList.ToArray())                       // CREATE NEW LIST PLAYERS AND NEW OBJECT IN SCOREBOARD
            {
                GameObject entry = Instantiate(PlayerListEntryPrefab);                     // CREATE NEW OBJECT
                if (IsTeam)                                                                // IF TEAM GAME
                {
                    UIGlobal.instance.ScoreBoardPanelTeam.SetActive(true);                 // ACTIVE TEAM SCOREBOARD PANEL
                    if ((string)p.CustomProperties[ScoreBoard.PLAYER_TEAM] == "red")       // IF TEAM OF PLAYER IN "PhotonNetwork.PlayerList" IS "RED"
                    {
                        entry.transform.SetParent(InsideScoreTeamRed.transform);           // ADJUST PARENT OF OBJECT IN CORRECTLY TEAM
                    }
                    else if ((string)p.CustomProperties[ScoreBoard.PLAYER_TEAM] == "blue") // IF TEAM OF PLAYER IN "PhotonNetwork.PlayerList" IS "BLUE"
                    {
                        entry.transform.SetParent(InsideScoreTeamBlue.transform);          // ADJUST PARENT OF OBJECT IN CORRECTLY TEAM
                    }
                }
                else                                                       // IF NO TEAM GAME
                {
                    UIGlobal.instance.ScoreBoardPanelSolo.SetActive(true); // ACTIVE SOLO SCOREBOARD PANEL
                    entry.transform.SetParent(InsideScoreSolo.transform);  // ADJUST PARENT OF OBJECT IN SCOREBOARD
                }

                entry.transform.localScale = Vector3.one;                                                                                                                                    // RESIZE SCALE
                entry.GetComponent <InitPlayerEntry>().Initialize(p.ActorNumber, p.NickName);                                                                                                //ADD IN OBJECT ACTOR ID AND PSEUDO OF PLAYER
                entry.GetComponent <InitPlayerEntry>().PlayerNameText.text  = string.Format(p.IsLocal ? "<color=#000000>{0}</color>" : "{0}", p.NickName);                                   //ADD IN OBJECT TEXT THE PSEUDO OF PLAYER AND CHANGE COLOR IF IS LOCAL PLAYER
                entry.GetComponent <InitPlayerEntry>().PlayerRankText.text  = string.Format("{0}", p.CustomProperties[ScoreBoard.PLAYER_RANK]);                                              //ADD IN OBJECT TEXT THE LEVEL OF PLAYER
                entry.GetComponent <InitPlayerEntry>().PlayerDeathText.text = string.Format(p.IsLocal ? "<color=#000000>{0}</color>" : "{0}", p.CustomProperties[ScoreBoard.PLAYER_DEATHS]); //ADD IN OBJECT TEXT THE DEATHS OF PLAYER AND CHANGE COLOR IF IS LOCAL PLAYER
                entry.GetComponent <InitPlayerEntry>().PlayerKillText.text  = string.Format(p.IsLocal ? "<color=#000000>{0}</color>" : "{0}", p.CustomProperties[ScoreBoard.PLAYER_KILLS]);  //ADD IN OBJECT TEXT THE KILLS OF PLAYER AND CHANGE COLOR IF IS LOCAL PLAYER
                entry.GetComponent <InitPlayerEntry>().ImageRank.sprite     = entry.GetComponent <InitPlayerEntry>().imgRank[(int)p.CustomProperties[ScoreBoard.PLAYER_RANK]];               // ADJUST IMAGE RANK IN OBJECT IN FUCNTION OF LEVEL
                entry.GetComponent <Image>().sprite = p.IsLocal ? entry.GetComponent <InitPlayerEntry>().imgBg[0] : entry.GetComponent <InitPlayerEntry>().imgBg[1];                         // ADJUST BACKGROUND IF IS LOCAL PLAYER

                MPPlayer ply = new MPPlayer();                                                                                                                                               // ADD PLAYER TO LIST
                ply.pseudo           = p.NickName;                                                                                                                                           // ADD PSEUDO
                ply.ObjForScorepanel = entry;                                                                                                                                                // ADD OBJECT
                ply.level            = (int)p.CustomProperties[ScoreBoard.PLAYER_RANK];                                                                                                      // ADD LEVEL
                ply.Kills            = (int)p.CustomProperties[ScoreBoard.PLAYER_KILLS];                                                                                                     // ADD KILLS
                ply.Deaths           = (int)p.CustomProperties[ScoreBoard.PLAYER_DEATHS];                                                                                                    // ADD DEATHS
                ply.team             = (string)p.CustomProperties[ScoreBoard.PLAYER_TEAM];                                                                                                   // ADD TEAM IF TEAM
                ply.ActorID          = p.ActorNumber;                                                                                                                                        // ADD ACTOR ID

                playerListEntries.Add(ply);                                                                                                                                                  // ADD TO LIST
                AddCountingPlayer();                                                                                                                                                         // ADJUST COUNT TOTAL PLAYER
            }
        }
Beispiel #2
0
        public override void OnPlayerLeftRoom(Player otherPlayer)         // IS LAUNCHED AUTOMATICALLY WHEN PLAYER LEFT ROOM.
        {
            MPPlayer temp = null;

            foreach (MPPlayer entry in playerListEntries.ToArray())           // CHECK IN LIST PLAYER
            {
                if (entry.ActorID == otherPlayer.ActorNumber)                 // IF ACTOR ID IS EQUAL AT ACTOR ID OF PLAYER WHO QUIT THE ROOM
                {
                    temp = entry;
                    Destroy(entry.ObjForScorepanel);                     // SO DELETE GAMEOBJECT IN SCOREBOARD AT PLAYER WHO QUIT THE ROOM
                }
            }

            if (temp != null)
            {
                playerListEntries.Remove(temp);                // AND REMOVE IN LIST PLAYER
            }

            AddCountingPlayer(); //REFRESH COUNT TOTAL PLAYERS
        }