public void SetPlayerData(PartyGameEndGamePlayerData playerData)
        {
            DataEntityHandle handle = Service.Get <CPDataEntityCollection>().FindEntity <SessionIdData, long>(playerData.PlayerId);

            if (Service.Get <CPDataEntityCollection>().TryGetComponent <DisplayNameData>(handle, out var component))
            {
                PlayerNameText.text = component.DisplayName;
            }
            PlayerIcon.SelectSprite(playerData.PlayerNum);
            SelectedBG.GetComponent <Image>().enabled = playerData.IsLocalPlayer;
            TrophyIcon.SetActive(playerData.Placement == 0);
            TrophyAnimator.enabled = playerData.IsLocalPlayer && playerData.Placement == 0;
            if (playerData.HasScore)
            {
                ScoreText.text = playerData.Score.ToString();
            }
            if (FirstPlaceEffects != null)
            {
                FirstPlaceEffects.SetActive(playerData.IsLocalPlayer && playerData.Placement == 0);
            }
            if (playerData.Placement == -1)
            {
                if (playerData.HasScore)
                {
                    ScoreText.gameObject.SetActive(value: false);
                    ScoreBG.color = fadeColor;
                }
                PlayerIcon.GetComponent <Image>().color = fadeColor;
            }
        }
예제 #2
0
        protected override void endGame(Dictionary <long, int> playerSessionIdToPlacement)
        {
            if (playerSessionIdToPlacement.Count == 0)
            {
                PartyGameUtils.LogBalkBi(partyGameDefinition.name);
                return;
            }
            foreach (FishBucketPlayerData value in playerData.Values)
            {
                if (playerSessionIdToPlacement.ContainsKey(value.PlayerId))
                {
                    value.Placement = playerSessionIdToPlacement[value.PlayerId];
                }
            }
            List <PartyGameEndGamePlayerData> list = new List <PartyGameEndGamePlayerData>();
            bool flag = false;

            foreach (FishBucketPlayerData value2 in playerData.Values)
            {
                PartyGameEndGamePlayerData item = new PartyGameEndGamePlayerData(value2.PlayerId, value2.Placement, value2.PlayerNum, value2.IsLocalPlayer, value2.Score, hasScore: true);
                if (list.Count == 0 || value2.Placement == -1)
                {
                    list.Add(item);
                    continue;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    if (value2.Placement <= list[i].Placement || list[i].Placement == -1)
                    {
                        list.Insert(i, item);
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    list.Add(item);
                }
                flag = false;
            }
            loadEndGameScreen(list.ToArray());
            if (base.players[0].UserSessionId == localPlayerSessionId)
            {
                PartyGameUtils.StopBiTimer(base.sessionId);
                PartyGameUtils.LogGameEndBi(partyGameDefinition.name, playerSessionIdToPlacement.Count);
            }
        }
        public void SetPlayerResults(PartyGameEndGamePlayerData[] orderedPlayerData, PartyGameDefinition definition, long gameSessionId)
        {
            localPlayerData    = default(PartyGameEndGamePlayerData);
            this.gameSessionId = gameSessionId;
            for (int i = 0; i < orderedPlayerData.Length; i++)
            {
                if (orderedPlayerData[i].IsLocalPlayer)
                {
                    localPlayerData = orderedPlayerData[i];
                    break;
                }
            }
            string token = WinTitleToken;

            switch ((localPlayerData.Placement == -1) ? PlayerPlacementType.LOSS : getLocalPlayerPlacementType(orderedPlayerData))
            {
            case PlayerPlacementType.WIN:
                if (!string.IsNullOrEmpty(WinSFXTrigger))
                {
                    EventManager.Instance.PostEvent(WinSFXTrigger, EventAction.PlaySound);
                }
                break;

            case PlayerPlacementType.LOSS:
                if (!string.IsNullOrEmpty(LossSFXTrigger))
                {
                    EventManager.Instance.PostEvent(LossSFXTrigger, EventAction.PlaySound);
                }
                token = LoseTitleToken;
                break;

            case PlayerPlacementType.TIE:
                if (!string.IsNullOrEmpty(TieSFXTrigger))
                {
                    EventManager.Instance.PostEvent(TieSFXTrigger, EventAction.PlaySound);
                }
                token = TieTitleToken;
                break;
            }
            TitleText.text = localizer.GetTokenTranslation(token);
            Reward reward = null;

            for (int i = 0; i < definition.Rewards.Count; i++)
            {
                if (definition.Rewards[i].Placement == (PartyGameEndPlacement)localPlayerData.Placement)
                {
                    reward = definition.Rewards[i].Reward.ToReward();
                }
            }
            if (reward != null)
            {
                RewardsPanel.SetActive(value: true);
                if (reward.TryGetValue <CoinReward>(out var rewardable) && !rewardable.IsEmpty())
                {
                    CoinsText.text = rewardable.Coins.ToString();
                }
                else
                {
                    CoinsPanel.SetActive(value: false);
                    Seperator.SetActive(value: false);
                }
                if (reward.TryGetValue <MascotXPReward>(out var rewardable2))
                {
                    using (Dictionary <string, int> .ValueCollection.Enumerator enumerator = rewardable2.XP.Values.GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            int current = enumerator.Current;
                            XpText.text = current.ToString();
                        }
                    }
                }
                else
                {
                    XpPanel.SetActive(value: false);
                    Seperator.SetActive(value: false);
                }
                ClaimButtonText.text = localizer.GetTokenTranslation("Rewards.RewardPopupScreen.ClaimButton");
            }