Exemplo n.º 1
0
    //現在のデータを保存
    public static bool saveKiiData()
    {
        KiiQuery allQuery = new KiiQuery();

        try {
            //検索条件を指定
            KiiQueryResult <KiiObject> result =
                KiiUser.CurrentUser.Bucket("myBasicData").Query(allQuery);

            Debug.Log("kii : " + variableManage.currentLv);

            foreach (KiiObject obj in result)
            {
                //データを保存
                obj["lv"]    = variableManage.currentLv;
                obj["exp"]   = variableManage.currentExp;
                obj["open2"] = variableManage.openMachine02;
                obj["open3"] = variableManage.openMachine03;
                obj["wp"]    = variableManage.myWP;
                obj.Save();
            }
        }
        catch (System.Exception e) {
            Debug.Log(e);
            return(false);
        }

        return(true);
    }
Exemplo n.º 2
0
    void GetTop10Highscores()
    {
        if (Kii.AppId == null || KiiUser.CurrentUser == null)
        {
            return;
        }

        //KiiUser user = KiiUser.CurrentUser;
        KiiBucket bucket = Kii.Bucket(PlayerController.appScopeScoreBucket);
        KiiQuery  query  = new KiiQuery();

        query.SortByAsc("time");
        query.Limit = 10;

        bucket.Query(query, (KiiQueryResult <KiiObject> list, Exception e) => {
            if (e != null)
            {
                Debug.LogError("Failed to load high scores " + e.ToString());
                scores = null;
            }
            else
            {
                scores = list;
            }
        });
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Awake()
    {
        KiiBucket bucket = Kii.Bucket(BUCKET_NAME);
        KiiQuery  query  = new KiiQuery();

        query.SortByDesc(SCORE_KEY);
        query.Limit = 10;
        strRanking  = "";
        int number = 1;

        try {
            KiiQueryResult <KiiObject> result = bucket.Query(query);
            Debug.Log(result.ToString());
            foreach (KiiObject obj in result)
            {
                try{
                    strRanking = strRanking + "[" + number.ToString() + "] " + obj.GetString(NAME_KEY) + " : " + obj.GetInt(SCORE_KEY) + "\n";
                    number++;
                }catch (IllegalKiiBaseObjectFormatException ef) {
                    Debug.Log("Format Error : " + ef.ToString());
                }
            }
        } catch (CloudException e) {
            Debug.Log("Failed to fetch high score: " + e.ToString());
        }
    }
Exemplo n.º 4
0
    // Get KiiCloud Bucket's score data.
    // Need already KiiCloud logined.
    public static int getHighScore()
    {
        if (KiiUser.CurrentUser == null)
        {
            return(0);
        }
        if (cachedHighScore > 0)
        {
            return(cachedHighScore);
        }
        KiiBucket bucket = Kii.Bucket(BUCKET_NAME);
        KiiQuery  query  = new KiiQuery(KiiClause.Equals(USER_KEY, KiiUser.CurrentUser.ID));

        query.SortByDesc(SCORE_KEY);
        query.Limit = 1;

        try {
            KiiQueryResult <KiiObject> result = bucket.Query(query);
            foreach (KiiObject obj in result)
            {
                int score = obj.GetInt(SCORE_KEY, 0);
                cachedHighScore = score;
                return(score);
            }
            Debug.Log("High score fetched");
            return(0);
        } catch (CloudException e) {
            Debug.Log("Failed to fetch high score: " + e.ToString());
            return(0);
        }

        /* Async version
         * bucket.Query(query, (KiiQueryResult<KiiObject> list, Exception e) =>{
         *      if (e != null)
         *      {
         *              Debug.Log ("Failed to fetch high score: " + e.ToString());
         *      } else {
         *              Debug.Log ("High score fetched");
         *              foreach (KiiObject obj in list) {
         *                      int score = obj.GetInt (SCORE_KEY, 0);
         *                      cachedHighScore = score;
         *                      getHighScore = score;
         *                      return;
         *              }
         *      }
         * });
         */
    }
Exemplo n.º 5
0
	void GetTop10Highscores(){
		if (Kii.AppId == null || KiiUser.CurrentUser == null) {
			return;
		}
		
		//KiiUser user = KiiUser.CurrentUser;
		KiiBucket bucket = Kii.Bucket (PlayerController.appScopeScoreBucket);
		KiiQuery query = new KiiQuery ();
		query.SortByAsc ("time");
		query.Limit = 10;
		
		bucket.Query(query, (KiiQueryResult<KiiObject> list, Exception e) =>{
			if (e != null)
			{
				Debug.LogError ("Failed to load high scores " + e.ToString());
				scores = null;
			} else {
				scores = list;
			}
		});
	}
Exemplo n.º 6
0
    //保存されているデータを読み込み
    bool loadKiiData()
    {
        KiiQuery allQuery = new KiiQuery();

        try {
            //検索条件を指定
            KiiQueryResult <KiiObject> result =
                KiiUser.CurrentUser.Bucket("myBasicData").Query(allQuery);
            foreach (KiiObject obj in result)
            {
                //データを読み込み
                variableManage.currentLv     = (int)obj["lv"];
                variableManage.currentExp    = (int)obj["exp"];
                variableManage.openMachine02 = (bool)obj["open2"];
                variableManage.openMachine03 = (bool)obj["open3"];
                variableManage.myWP          = (int)obj["wp"];
            }
        }catch (System.Exception e) {
            Debug.Log(e);
            return(false);
        }

        return(true);
    }
Exemplo n.º 7
0
 void Start()
 {
     scores = null;
     GetTop10Highscores();
 }
Exemplo n.º 8
0
	void Start() {
		scores = null;
		GetTop10Highscores();
	}