Пример #1
0
        private static void Traverse(
            ICollection <TraceCall> calls,
            Dictionary <string, RankingItem> routines,
            ref uint totalCount,
            GetNameDelegate getName)
        {
            foreach (TraceCall call in calls)
            {
                if (routines.ContainsKey(getName(call)))
                {
                    RankingItem item = routines[getName(call)];
                    item.CallCount++;
                }
                else
                {
                    routines[getName(call)] =
                        new RankingItem(getName(call), 1);
                }

                totalCount++;

                if (!call.IsSynthetic)
                {
                    Traverse(call.Calls, routines, ref totalCount, getName);
                }
            }
        }
Пример #2
0
    public void LoadRankingList(string fileName)
    {
        rankinglist = new List <RankingItem>();
        string filePath = Path.Combine(Application.streamingAssetsPath, fileName);

        if (File.Exists(filePath))
        {
            string      dataAsJson = File.ReadAllText(filePath);
            RankingData loadedData = JsonUtility.FromJson <RankingData>(dataAsJson);

            for (int i = 0; i < loadedData.items.Length; i++)
            {
                RankingItem rankingItem = new RankingItem();
                rankingItem.name  = loadedData.items[i].name;
                rankingItem.score = loadedData.items[i].score;
                rankinglist.Add(rankingItem);
            }

            Debug.Log("Data loaded, List contains: " + rankinglist.Count + " entries");

            rankingData = loadedData;
        }
        else
        {
            Debug.LogError("Cannot find file!");
        }
    }
Пример #3
0
    private void AddListItem()
    {
        Sprite[] image =
        {
            Resources.Load("Image/Face_Balance", typeof(Sprite)) as Sprite,
            Resources.Load("Image/Face_Light",   typeof(Sprite)) as Sprite,
            Resources.Load("Image/Face_Health",  typeof(Sprite)) as Sprite,
            Resources.Load("Image/Face_Speed",   typeof(Sprite)) as Sprite
        };

        RankingItem itemTemp;

        for (int i = 0; i < 20; ++i)
        {
            itemTemp = new RankingItem();

            itemTemp.UserName.text   = "1234";
            itemTemp.UserRecord.text = "1234";
            itemTemp.UserPurigon     = image[Random.Range(0, 4)];
            itemTemp.OnItemClick     = new Button.ButtonClickedEvent();
            itemTemp.OnItemClick.AddListener(delegate { ItemClick_Result(i); });


            //리스트에 추가
            this.ItemList.Add(itemTemp);
        }
    }
Пример #4
0
    public IEnumerator SetScene(Scene scene)
    {
        IEnumerable <Score> items = scene.GetScores();

        if (items.Count() == 0 || Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
        {
            yield return(StartCoroutine(server.LoadScores(scene)));

            items = scene.GetScores();
        }
        if (SceneSelectionController.instance.SelectedSceneID == scene.ID)
        {
            this.Clear();
            List <Score> scores = items.ToList();
            foreach (Score score in scores.OrderBy(r => r.Ranking))
            {
                if (score.PlayerId == 0)
                {
                    continue;
                }
                GameObject  obj  = (GameObject)Instantiate(Resources.Load("Prefabs/RankingItem"));
                RankingItem item = obj.GetComponent <RankingItem>();
                User        user = score.GetUser();
                user.Subscribe(item); // If the user changes his/her avatar, the ranking item will be updated...
                item.Avatar.sprite  = user.GetAvatar();
                item.Nick.text      = user.Login;
                item.score          = score;
                item.scene          = scene;
                item.Score.text     = String.Format("Pts. {0} - ({1}x)", score.Points, score.MaxCombo);
                item.FullCombo.text = score.MissCount == 0 ? "Full Combo" : "";
                item.transform.SetParent(RankingList.transform, false);
            }
        }
        yield break;
    }
Пример #5
0
 /// <summary>
 /// 刷新排行榜数据
 /// </summary>
 void RefreshRank()
 {
     if (rankDic.Count == 0)
     {
         curPage--;
     }
     using (var data = rankDic.GetEnumerator())
     {
         while (data.MoveNext())
         {
             if (!infoList.Contains(data.Current.Value))
             {
                 infoList.Add(data.Current.Value);
             }
         }
     }
     for (int i = 0; i < rankItemList.Count; i++)
     {
         if (i >= infoList.Count)
         {
             rankItemList[i].SetActive(false);
         }
         else
         {
             rankItemList[i].SetActive(true);
             RankingItem rankingItem = rankItemList[i].GetComponent <RankingItem>();
             if (rankingItem != null)
             {
                 rankingItem.rankNumLabel.text = (i + 1).ToString();
                 rankingItem.Refresh(infoList[i], rankType);
             }
         }
     }
     if (infoList.Count == 0)//没有玩家的排行榜不显示模型
     {
         GameCenter.previewManager.ClearModel();
     }
     if (infoList.Count != 0 && isChangeTog)
     {
         GameCenter.newRankingMng.CurChooseRankPlayerId = infoList[0].PlayerId;
         GameCenter.previewManager.C2S_ReqGetInfo(infoList[0].PlayerId, rankType == 6 ? 1 : 0);
         isChangeTog = false;
     }
 }
Пример #6
0
    public void SaveRankingData()
    {
        string filePath = Path.Combine(Application.streamingAssetsPath, fileName);

        RankingItem[] rankingItems = new RankingItem[rankingData.items.Length + 1];
        for (int i = 0; i < rankingItems.Length; i++)
        {
            rankingItems[i] = rankinglist[i];
        }

        rankingData.items = rankingItems;

        if (!string.IsNullOrEmpty(fileName))
        {
            string dataAsJson = JsonUtility.ToJson(rankingData);
            File.WriteAllText(filePath, dataAsJson);
            Debug.Log(dataAsJson);
        }
    }
Пример #7
0
    public void AddNewRecord(string name, int score)
    {
        RankingItem newRecord = new RankingItem();

        newRecord.name  = name;
        newRecord.score = score;
        bool isNewrecordAdded = false;

        for (int i = 0; i < rankinglist.Count; i++)
        {
            if (rankinglist[i].score < score && !isNewrecordAdded)
            {
                rankinglist.Insert(i, newRecord);
                isNewrecordAdded = true;
            }
        }

        if (rankinglist.Count > 20)
        {
            rankinglist.RemoveRange(20, 1);
        }
    }
Пример #8
0
        void MyAchievement_Loaded(object sender, RoutedEventArgs e)
        {
            obsRankings              = new ObservableCollection <RankingItem>();
            TextBlock_UserName.Text  = SingletonManager.Get <UserProcesser>().GetUser().Name;
            TextBlock_UserID.Text    = SingletonManager.Get <UserProcesser>().GetUser().ID;
            TextBlock_DoneCount.Text = SingletonManager.Get <PracticalItemProcesser>().GetHasDonePracticalItems().Count.ToString();
            int this_score = (int)SingletonManager.Get <PracticalItemProcesser>().GetHasDonePracticalItems().Count / SingletonManager.Get <PracticalItemProcesser>().GetPracticalItems().Count * 100;

            TextBlock_DonePercent.Text = this_score.ToString();

            int index = 0;

            if (this_score == 100)
            {
                index = 0;
            }
            else if (this_score >= 90)
            {
                index = 1;
            }
            else if (this_score >= 80)
            {
                index = 2;
            }
            else if (this_score >= 70)
            {
                index = 3;
            }
            else if (this_score >= 50)
            {
                index = 4;
            }
            else
            {
                index = 5;
            }

            RankingItem[] items      = new RankingItem[6];
            RankingItem[] fixedItems = new RankingItem[5];
            items[0] = new RankingItem()
            {
                Score     = 100,
                User_Name = "陈昊",
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang3.png",
            };
            items[1] = new RankingItem()
            {
                Score     = 90,
                User_Name = "冯轲",
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang2.png",
            };
            items[2] = new RankingItem()
            {
                Score     = 80,
                User_Name = "邓润如",
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang3.png",
            };
            items[3] = new RankingItem()
            {
                Score     = 70,
                User_Name = "赵旭",
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang2.png",
            };
            items[4] = new RankingItem()
            {
                Score     = 50,
                User_Name = "甘仁",
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang2.png",
            };
            items[5] = new RankingItem()
            {
                Score     = this_score,
                User_Name = SingletonManager.Get <UserProcesser>().GetUser().Name,
                ImgSource = AppDomain.CurrentDomain.BaseDirectory + "Images\\touxiang1.png",
            };
            switch (index)
            {
            case 0:
                obsRankings.Add(items[5]);
                obsRankings.Add(items[0]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[3]);
                break;

            case 1:
                obsRankings.Add(items[0]);
                obsRankings.Add(items[5]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[3]);
                break;

            case 2:
                obsRankings.Add(items[0]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[5]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[3]);
                break;

            case 3:
                obsRankings.Add(items[0]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[5]);
                obsRankings.Add(items[3]);
                break;

            case 4:
                obsRankings.Add(items[0]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[3]);
                obsRankings.Add(items[5]);
                break;

            default:
                obsRankings.Add(items[0]);
                obsRankings.Add(items[1]);
                obsRankings.Add(items[2]);
                obsRankings.Add(items[3]);
                obsRankings.Add(items[4]);
                break;
            }
            ranking1.DataContext = obsRankings[0];
            ranking2.DataContext = obsRankings[1];
            ranking3.DataContext = obsRankings[2];
            ranking4.DataContext = obsRankings[3];
            ranking5.DataContext = obsRankings[4];
        }
Пример #9
0
    private void OnSetDetailRankingItem(RectTransform node, PRank data)
    {
        RankingItem item = node.GetComponentDefault <RankingItem>();

        item.RefreshItem(data);
    }
Пример #10
0
 public void Add(RankingItem item)
 {
     items.Add(item);
 }
Пример #11
0
 public RankingResultEntryViewModel(RankingItem item)
 {
     Item = item;
 }
Пример #12
0
    public void CreateRankList(RankingData[] rawData, int GameId)
    {
        Debug.Log("Create RankList");
        ClearAllList();
        rankingList = rawData;

        //sorting rankingList
        switch (GameId)
        {
        case 0:
            //all
            for (int i = 0; i < rankingList.Length; i++)
            {
                for (int j = i + 1; j < rankingList.Length; j++)
                {
                    if (rankingList[j].scoreAll > rankingList[i].scoreAll)
                    {
                        RankingData tmp = rankingList[i];
                        rankingList[i] = rankingList[j];
                        rankingList[j] = tmp;
                    }
                }
            }
            break;

        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            for (int i = 0; i < rankingList.Length; i++)
            {
                for (int j = i + 1; j < rankingList.Length; j++)
                {
                    if (rankingList[j].score[GameId - 1] > rankingList[i].score[GameId - 1])
                    {
                        RankingData tmp = rankingList[i];
                        rankingList[i] = rankingList[j];
                        rankingList[j] = tmp;
                    }
                }
            }

            break;
        }

        //create gift
        myRanking.gameObject.SetActive(true);
        myRanking.Name.maxVisibleLines = 1;
        int q    = 1;
        int rank = 1;

        foreach (RankingData item in rankingList)
        {
            if (item.userId == UserCommonData.pGlobal.user.user_id)
            {
                myRanking.SetRankItem(item, GameId, rank);
            }
            else
            {
                GameObject obj = (GameObject)GameObject.Instantiate(RankPrefabs);
                obj.transform.parent = this.transform;
                RankingItem rk = obj.GetComponent <RankingItem>();
                rk.SetRankItem(q, RankHeight, item, GameId, rank);
                rk.SendGiftButton.box = list.touchArea;
                //gf.sendDone += postSendGift;
                q++;
            }
            rank++;
        }
        BG.setHeight(RankHeight * q);
        if (q > 0)
        {
            BG.gameObject.SetActive(true);
        }
        list.ListHeight = RankHeight * q;
    }
Пример #13
0
 public void Open(RankingItem item)
 {
     NicoNicoOpener.Open(item.VideoUrl);
 }