Esempio n. 1
0
    //指定したレコードのランクを取得
    public void fetchRank(string name, int gameModeId, Save_ranking_item save_Ranking_Item, CallbackInt callback)
    {
        currentRank = 0;
        RankingRecord myRecord = null;
        // データスコアの「HighScore」から検索
        NCMBQuery <NCMBObject> query = new NCMBQuery <NCMBObject>(rankingClassName);

        query.WhereEqualTo("name", name);
        query.WhereEqualTo("gameModeId", gameModeId);
        query.WhereEqualTo("type", (int)save_Ranking_Item);
        query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
        {
            if (e == null && objList.Count > 0)
            {                                                                      //検索成功したら
                string _name    = System.Convert.ToString(objList[0]["name"]);     // 名前を取得
                float _distance = System.Convert.ToSingle(objList[0]["distance"]); // スコアを取得
                float _timeSpan = System.Convert.ToSingle(objList[0]["timeSpan"]);
                myRecord        = new RankingRecord(0, _name, _distance, _timeSpan, save_Ranking_Item);

                var query2 = new NCMBQuery <NCMBObject>(rankingClassName);
                query2.WhereEqualTo("gameModeId", gameModeId);
                query2.WhereEqualTo("type", (int)save_Ranking_Item);
                switch (save_Ranking_Item)
                {
                case Save_ranking_item.SAVE_RANKING_HIGH:
                    query2.WhereGreaterThanOrEqualTo("distance", myRecord.distance);
                    break;

                case Save_ranking_item.SAVE_RANKING_LOW:
                    query2.WhereLessThanOrEqualTo("distance", myRecord.distance);
                    break;

                default:
                    break;
                }

                query2.CountAsync((int count, NCMBException e2) =>
                {
                    if (e2 != null)
                    {
                        //件数取得失敗
                        callback(currentRank);
                    }
                    else
                    {
                        //件数取得成功
                        currentRank = count + 1; // 自分よりスコアが上の人がn人いたら自分はn+1位
                    }
                    callback(currentRank);
                });
            }
            else
            {
                callback(currentRank);
            }

            return;
        });
    }
Esempio n. 2
0
 protected TrainingBase(Route route, Action uiUpdate, Func <Task <Tuple <double, double, double?> > > currentLocationDelegate)
 {
     Route         = route;
     UiUpdate      = uiUpdate;
     GetLocation   = currentLocationDelegate;
     Points        = new List <Point>();
     CurrentTry    = new RankingRecord();
     RoutesService = new RoutesService();
 }
Esempio n. 3
0
    /// <summary>
    /// レコードの読み込み
    /// </summary>
    private void LoadRecord()
    {
        RankingRecord record = default;
        GameObject    obj    = default;

        obj = Instantiate(rankingRecordObject, this.transform);
        obj.transform.localPosition = recordPosition;

        record = obj.GetComponent <RankingRecord>();
        record.SetLeaderBoard(leaderBoardObject, selfLeaderBoard);
        record.rankPosition = selfLeaderBoard.entries[0].Position;
    }
Esempio n. 4
0
    //指定したレコードの前後のレコード取得
    public void getRankingNeighbors(string name, int gameModeId, Save_ranking_item save_Ranking_Item, CallbackRecordsList callback)
    {
        fetchRank(name, gameModeId, save_Ranking_Item, (int currentRank) =>
        {
            int numSkip = currentRank - 3;
            if (numSkip < 0)
            {
                numSkip = 0;
            }

            List <RankingRecord> rankingRecords = new List <RankingRecord>();
            NCMBQuery <NCMBObject> query        = new NCMBQuery <NCMBObject>(rankingClassName);
            query.WhereEqualTo("gameModeId", gameModeId);
            query.WhereEqualTo("type", (int)save_Ranking_Item);
            query.Skip  = numSkip;
            query.Limit = 5;
            switch (save_Ranking_Item)
            {
            case Save_ranking_item.SAVE_RANKING_HIGH:
                query.OrderByDescending("distance");
                query.AddAscendingOrder("timeSpan");
                break;

            case Save_ranking_item.SAVE_RANKING_LOW:
                query.OrderByAscending("distance");
                query.AddAscendingOrder("timeSpan");
                break;

            default:
                break;
            }
            query.FindAsync((List <NCMBObject> objList, NCMBException e) =>
            {
                if (e == null)
                { //検索成功したら
                    for (int i = 0; i < objList.Count; i++)
                    {
                        string _name                = System.Convert.ToString(objList[i]["name"]);     // 名前を取得
                        float _distance             = System.Convert.ToSingle(objList[i]["distance"]); // スコアを取得
                        float _timeSpan             = System.Convert.ToSingle(objList[i]["timeSpan"]);
                        RankingRecord rankingRecord = new RankingRecord(numSkip + i + 1, _name, _distance, _timeSpan, save_Ranking_Item);
                        rankingRecords.Add(rankingRecord);
                    }
                    callback(rankingRecords);
                }
                else
                {
                    callback(rankingRecords);
                }
            });
        });
        return;
    }
Esempio n. 5
0
        public void Start()
        {
            IsStarted  = true;
            CurrentTry = new RankingRecord(true, Route.Id);
            Route.Ranking.Add(CurrentTry);


            Timer          = new Timer(1000);
            Timer.Elapsed += _timer_Elapsed;

            ProcessUserLocation();
            Timer.Start();
        }
Esempio n. 6
0
    /// <summary>
    /// 子のロード
    /// </summary>
    public void LoadChild()
    {
        // レコード表示用オブジェクトの生成
        for (int i = 0; i < leaderBoard.entries.Count; i++)
        {
            RankingRecord record = default;
            GameObject    obj    = default;

            obj    = Instantiate(rankingRecord, this.transform);
            record = obj.GetComponent <RankingRecord>();
            record.SetLeaderBoard(leaderBoardObject, leaderBoard);

            record.rankPosition = i;

            obj.transform.localPosition = new Vector3(startPos.x, i * -HeightInterval + startPos.y);
        }
        // スワイプ移動の制限
        swipe.moveLimitRect = new Rect(0, 0, 0, HeightInterval * leaderBoard.entries.Count - SwipeMoveAdjustment);
    }
Esempio n. 7
0
        public async Task <bool> CreateRankingRecordAsync(RankingRecord currentTry, Guid routeId)
        {
            var json    = JsonConvert.SerializeObject(currentTry);
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            var uri     = $"{_routesUri}/{routeId}/ranking-record";

            try
            {
                var response = await Client.PostAsync(uri, content);

                return(true);
            }
            catch (Exception)
            {
                var dataToSend = new DataToSend(json, uri);
                _userLocalRepository.CreateDataToSend(dataToSend);

                return(false);
            }
        }
Esempio n. 8
0
        public void ProcessCurrentTry(Route route, RankingRecord currentTry)
        {
            var lastTry = route.Ranking.SingleOrDefault(rr => rr.IsMine);

            if (lastTry == null)
            {
                return;
            }
            if (currentTry.FinalResult < lastTry.FinalResult)
            {
                currentTry.IsMine       = true;
                currentTry.IsCurrentTry = false;
                currentTry.User         = lastTry.User;

                route.Ranking.Remove(lastTry);
            }
            else
            {
                route.Ranking.Remove(currentTry);
            }
        }
Esempio n. 9
0
        public List <RankingRecord> GetRankingByShow(string show, string full)
        {
            var ranking    = new List <RankingRecord>();
            var votaciones = Repository.GetVotacionesByShow(show);

            foreach (var votacion in votaciones)
            {
                var CiudadObtenida = ranking.Find(f => f.Ciudad.Nombre == votacion.Ciudad.Nombre);
                if (CiudadObtenida != null)
                {
                    var index = ranking.FindIndex(c => c.Ciudad.Nombre == votacion.Ciudad.Nombre);
                    ranking[index] = new RankingRecord {
                        Ciudad = CiudadObtenida.Ciudad, VotesCount = CiudadObtenida.VotesCount + 1
                    };
                }
                else
                {
                    var record = new RankingRecord {
                        Ciudad = votacion.Ciudad, VotesCount = 1
                    };
                    ranking.Add(record);
                }
            }
            foreach (var registro in ranking)
            {
                registro.VotesCount = registro.VotesCount * 100 / votaciones.Count;
            }
            var rankingOrdenado = ranking.OrderByDescending(f => f.VotesCount).ToList();

            if (full == "full")
            {
                return(rankingOrdenado);
            }
            else
            {
                return(rankingOrdenado.Take(100).ToList());
            }
        }