コード例 #1
0
        /// <summary>
        /// 比赛房结算
        /// </summary>
        /// <param name="data"></param>
        public void ShowTotalRoundEnd(com.morln.game.gd.command.RoundEnd data)
        {
            ResetTweeners();

            if (!TotalRoundEnd)
            {
                return;
            }

            ShowBgCover(true);

            if (MidRoundEnd.gameObject.activeSelf)
            {
                MidRoundEnd.gameObject.SetActive(false);
            }

            if (!TotalRoundEnd.gameObject.activeSelf)
            {
                TotalRoundEnd.gameObject.SetActive(true);
            }

            TotalRoundEnd.Reset();
            TotalRoundEnd.transform.localScale = new Vector3(0, 0, 1);

            _totalTweener = TotalRoundEnd.transform
                            .DOScale(new Vector3(1, 1, 1), ShowAnimationTime)
                            .SetEase(Ease.OutBack, 1.1f)
                            .OnComplete(() => TotalRoundEnd.RaceRefreshContent(data));
        }
コード例 #2
0
        public void RaceRefreshContent(com.morln.game.gd.command.RoundEnd msg)
        {
            if (msg == null)
            {
                return;
            }

            if (!RankContent)
            {
                return;
            }

            var raceResultItem = msg.item;

            if (raceResultItem == null)
            {
                return;
            }

            raceResultItem.Sort((x, y) => x.rank.CompareTo(y.rank));

            var myUser    = _user.Read();
            var userName  = myUser == null ? null : myUser.username;
            var selfIsWin = false;
            var selfScore = 0;
            var users     = new List <UserNameAndNickName>();

            for (var i = 0; i < raceResultItem.Count; i++)
            {
                if (userName == raceResultItem[i].username)
                {
                    selfIsWin = raceResultItem[i].win;
                    var myCurrency = raceResultItem[i].currency;
                    if (myCurrency == null)
                    {
                        return;
                    }

                    //比赛房默认货币类型为分数
                    var currentRoomCurrencyType = CurrencyType.SCORE;
                    for (var j = 0; j < myCurrency.Count; j++)
                    {
                        if (myCurrency[j].type == currentRoomCurrencyType)
                        {
                            selfScore = (int)myCurrency[j].count;
                            break;
                        }
                    }
                }

                var user = new UserNameAndNickName();
                user.NickName = raceResultItem[i].nickname;
                user.Username = raceResultItem[i].username;
                users.Add(user);
            }

            if (selfIsWin)
            {
                // 掉线或者赢了,都播放赢的声音。
                _soundController.PlayEndRoundWinSound();
            }
            else
            {
                _soundController.PlayEndRoundLoseSound();
            }

            int currentOtherRank = 0;

            for (int i = 0; i < users.Count; i++)
            {
                var u = users[i];
                if (u == null)
                {
                    continue;
                }

                var win = false;
                for (var j = 0; j < raceResultItem.Count; j++)
                {
                    if (u.Username == raceResultItem[j].username)
                    {
                        win = raceResultItem[j].win;
                        break;
                    }
                }

                if (u.Username == userName)
                {
                    if (EndImage)
                    {
                        if (!EndImage.gameObject.activeSelf)
                        {
                            EndImage.gameObject.SetActive(true);
                        }

                        EndImage.sprite = win ? WinImg : LoseImg;
                    }

                    if (!_mySelfRank)
                    {
                        _mySelfRank = _rankMySelfFactory.Create();

                        if (_mySelfRank)
                        {
                            _mySelfRank.transform.SetParent(RankContent, false);
                        }
                    }

                    if (_mySelfRank)
                    {
                        if (!_mySelfRank.gameObject.activeSelf)
                        {
                            _mySelfRank.gameObject.SetActive(true);
                        }

                        var room             = _room.Read();
                        var roomCurrencyType = room == null ? CurrencyType.GOLDEN_EGG : room.currency_type;
                        _mySelfRank.transform.SetSiblingIndex(i);
                        _mySelfRank.ApplyData(
                            false,
                            win,
                            u.NickName,
                            u.Vip,
                            0,
                            roomCurrencyType,
                            selfScore,
                            1,
                            GetMyRaceTotalScore(),
                            msg.total_multiple);
                    }
                }
                else
                {
                    if (currentOtherRank >= _otherRanks.Count)
                    {
                        var rank = _rankOtherFactory.Create();
                        if (rank)
                        {
                            rank.transform.SetParent(RankContent, false);
                            _otherRanks.Add(rank);
                        }
                    }

                    if (currentOtherRank < _otherRanks.Count)
                    {
                        var rank = _otherRanks[currentOtherRank];
                        if (!rank.gameObject.activeSelf)
                        {
                            rank.gameObject.SetActive(true);
                        }

                        currentOtherRank++;

                        rank.ApplyData(win, u.Username, u.NickName, u.Vip);
                        rank.transform.SetSiblingIndex(i);
                    }
                }
            }
        }