Exemplo n.º 1
0
 public static void Reset()
 {
     selfRankObject = null;
     higherRanks.Clear();
     lowerRanks.Clear();
     pageRanks.Clear();
 }
Exemplo n.º 2
0
    public static void Setup_10_Before_And_10_After(/**string jsonString**/ LevelScroesObject scoresObj)
    {
        Reset();
        LevelScroes = scoresObj;        //LevelScroesObject.CreateFromJSON(jsonString);

        Total = LevelScroes.data.total;

        bool isFoundSelf = false;
        int  selfRank    = 0;

        for (int i = 0; i < LevelScroes.data.rankingScores.Count; i++)
        {
            //print(LevelScroes.data.rankingScores[i].historyID);
            // 临时解决服务器rank少1
            //LevelScroes.data.rankingScores[i].rank += 1;

            if (isFoundSelf == false)
            {
                if (LevelScroes.data.rankingScores[i].uid == SelfPlayerData.Uuid)
                {
                    selfRankObject = LevelScroes.data.rankingScores[i];
                    isFoundSelf    = true;
                    selfRank       = selfRankObject.rank;
                }
                else
                {
                    higherRanks.Add(LevelScroes.data.rankingScores[i]);
                }
            }
            else
            {
                lowerRanks.Add(LevelScroes.data.rankingScores[i]);
            }
        }
        PageNo = selfRank / 10;
        for (int i = 0; i < LevelScroes.data.rankingScores.Count; i++)
        {
            if ((LevelScroes.data.rankingScores[i].rank - 1) / 10 == PageNo)
            {
                pageRanks.Add(LevelScroes.data.rankingScores[i]);
            }
        }
    }
Exemplo n.º 3
0
    public PlayerInfoPanel Setup(RankObject rankObject, bool setScoreZero = false)
    {
        if (string.IsNullOrEmpty(rankObject.user.avatar))
        {
            rankObject.user.avatar = "NoAvatar";
        }


        string avatarUrl = "";

        rankObjectDebug = rankObject;
        isSelf          = rankObject.uid == SelfPlayerData.Uuid;
        var sprite = Resources.Load <Sprite> ("UI/_Avatars/" + rankObject.user.avatar);

        if (isSelf && string.IsNullOrEmpty(SelfPlayerData.Uuid) == false)
        {
            SelfPlayerLevelData.Instance.changeNameEvent.AddListener(ChangeMyNameOrAvatar);
            ChangeMyNameOrAvatar();
            //var sprite = Resources.Load<Sprite>("UI/_Avatars/" + SelfPlayerData.AvatarUrl);
            //if (sprite == null)
            //{
            //	LogManager.LogWarning("没有图片 Resources/UI/_Avatars/" , SelfPlayerData.AvatarUrl);
            //	SelfPlayerData.AvatarUrl = "NoAvatar";
            //	sprite = Resources.Load<Sprite>("UI/_Avatars/" + SelfPlayerData.AvatarUrl);
            //}
            transform.Find("Image_gear").GetComponent <Image> ().color = new Color32(255, 221, 142, 255);
            //image_avatar.sprite = sprite;
            avatarUrl = SelfPlayerData.AvatarUrl;
            //AsyncImageDownload.GetInstance().SetAsyncImage(SelfPlayerData.AvatarUrl, image_avatar, sprite);
            image_base.sprite = sp_player;
        }
        else
        {
            SelfPlayerLevelData.Instance.changeNameEvent.RemoveListener(ChangeMyNameOrAvatar);
            text_name.text = rankObject.user.nickname;

            //if (sprite == null)
            //{
            //	LogManager.LogWarning("没有图片 Resources/UI/_Avatars/" , rankObject.user.avatar);
            //	sprite = Resources.Load<Sprite>("UI/_Avatars/NoAvatar");
            //}
            transform.Find("Image_gear").GetComponent <Image> ().color = new Color32(255, 255, 255, 255);
            //image_avatar.sprite = sprite;
            avatarUrl = rankObject.user.avatar;
            //AsyncImageDownload.GetInstance().SetAsyncImage(rankObject.user.avatar, image_avatar, sprite);
            image_base.sprite = sp_default;
        }

        //if (avatarUrl.IndexOf("http:") != -1)
        //{
        //	AsyncImageDownload.GetInstance().SetAsyncImage(avatarUrl, image_avatar);
        //}
        //else if(avatarUrl.IndexOf("Avatar") != -1)
        //{
        SetAvatar(image_avatar, rankObject.uid);
        userCountry.sprite = GetCountryByIndex(rankObject.user.country);
        //}

        text_rank.text = rankObject.rank.ToString();
        int grade = SetLevel.setLevel(rankObject.accuracy);

        LogManager.Log("玩家获得的级别序号:", grade);
        _score = rankObject.score;
        image_accuracy.sprite = sp_ranks[grade];


        text_score.text = setScoreZero ? "0" : _score.ToString();

        gameObject.SetActive(true);
        if (but_Video != null)
        {
            if (rankObjectDebug.rank != 1 || StaticData.LevelID % 4 == 0)
            {
                but_Video.gameObject.SetActive(false);
                but_Voice.transform.localPosition = new Vector2(but_Voice.transform.localPosition.x, 0);
            }
            else
            {
                but_Video.gameObject.SetActive(true);
                but_Voice.transform.localPosition = new Vector2(but_Voice.transform.localPosition.x, -48);
            }
        }
        return(this);
    }
Exemplo n.º 4
0
    public void SetupRankPanel()
    {
        // 拿比我好的人的信息
        higherRanks = OtherPlayerLevelData.Get_Higher_RankObjects(1);
        // 拿比我差的人的信息
        lowerRanks = OtherPlayerLevelData.Get_Lower_RankObjects(2);
        // 拿我自己信息
        myInfo = SelfPlayerLevelData.CurInfo;

        if (myInfo == null || gameObject == null)
        {
            return;
        }

        StartCoroutine(_CorActiveButton());
        obj_waitIcon.SetActive(false);
        // 临时
        var myRank = new RankObject();

        myRank.uid           = SelfPlayerData.Uuid;
        myRank.user          = new UserObject();
        myRank.user.avatar   = SelfPlayerLevelData.CurInfo.avatar;
        myRank.user.nickname = SelfPlayerLevelData.CurInfo.nickName;
        myRank.rank          = OtherPlayerLevelData.SelfRankObject.rank;
        myRank.score         = OtherPlayerLevelData.SelfRankObject.score;
        myRank.accuracy      = OtherPlayerLevelData.SelfRankObject.accuracy;


        if (SelfPlayerLevelData.TempRankIncrement > 0)
        {
            //LogManager.LogWarning("上升了");
            int index     = 0;
            var selfPanel = playerInfoPanels[index];


            selfPanel.Setup(myRank, true)
            .PlayMoveUp(enterDelay, addScoreTime);
            obj_newRecord.SetActive(SelfPlayerLevelData.ScoreIncrement > 0);
            obj_newRecord.transform.SetParent(selfPanel.transform, false);

            index++;
            foreach (var item in lowerRanks)
            {
                if (index < playerInfoPanels.Length)
                {
                    playerInfoPanels[index++].Setup(item)
                    .PlayMoveDown(enterDelay, addScoreTime);
                }
            }

            text_rankUpValue.text = SelfPlayerLevelData.TempRankIncrement.ToString();
            obj_rankUp.transform.SetParent(selfPanel.transform, false);
            obj_rankUp.transform.SetSiblingIndex(0);
            StartCoroutine(_CorShowRankUpAnim());
        }
        else
        {
            //LogManager.LogWarning("排名未变化");
            obj_rankUp.SetActive(false);
            int index = 0;
            foreach (var item in higherRanks)
            {
                playerInfoPanels[index++].Setup(item);
            }

            // 自己
            var selfPanel = playerInfoPanels[index++];
            selfPanel.Setup(myRank, true)
            .PlayMoveIn(enterDelay, addScoreTime);
            obj_newRecord.SetActive(SelfPlayerLevelData.ScoreIncrement > 0);
            obj_newRecord.transform.SetParent(selfPanel.transform, false);

            foreach (var item in lowerRanks)
            {
                if (index < playerInfoPanels.Length)
                {
                    playerInfoPanels[index++].Setup(item);
                }
            }
        }
    }