Пример #1
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());
        }
    }
Пример #2
0
    private int previousScore = 0; // The score in the previous frame.

    #endregion Fields

    #region Methods

    public static void LoadHighScore()
    {
        if (KiiUser.CurrentUser == null) {
            return;
        }

        KiiUser user = KiiUser.CurrentUser;
        KiiBucket bucket = user.Bucket ("scores");
        KiiQuery query = new KiiQuery ();
        query.SortByDesc ("score");
        query.Limit = 1;

        bucket.Query(query, (KiiQueryResult<KiiObject> list, Exception e) =>{
            if (e != null)
            {
                Debug.LogError ("Failed to load high score " + e.ToString());
            } else {
                foreach (KiiObject obj in list) {
                    highscore = obj.GetInt ("score", 0);
                    Debug.Log ("High score loaded: " + highscore.ToString());
                    return;
                }
            }
        });
    }
Пример #3
0
    public static void LoadHighScore()
    {
        if (KiiUser.CurrentUser == null)
        {
            return;
        }

        KiiUser   user   = KiiUser.CurrentUser;
        KiiBucket bucket = user.Bucket("scores");
        KiiQuery  query  = new KiiQuery();

        query.SortByDesc("score");
        query.Limit = 1;

        bucket.Query(query, (KiiQueryResult <KiiObject> list, Exception e) => {
            if (e != null)
            {
                Debug.LogError("Failed to load high score " + e.ToString());
            }
            else
            {
                foreach (KiiObject obj in list)
                {
                    highscore = obj.GetInt("score", 0);
                    Debug.Log("High score loaded: " + highscore.ToString());
                    return;
                }
            }
        });
    }
Пример #4
0
    private void ShowLogo()
    {
        Debug.Log("##### ShowLogo");
        // Get the latest asset bundle.
        KiiQuery query = new KiiQuery();

        query.SortByDesc("_modified");
        query.Limit = 1;

        Kii.Bucket("AssetBundles").Query(query, (KiiQueryResult <KiiObject> result, Exception e) => {
            if (e != null)
            {
                Debug.Log("##### Failed to query. " + e.ToString());
                return;
            }
            if (result.Count == 0)
            {
                Debug.Log("##### Cannot find asset bundle.");
                return;
            }
            string platform = null;
            #if UNITY_IPHONE
            platform = "iOS";
            #elif UNITY_ANDROID
            platform = "Android";
            #elif UNITY_WEBPLAYER
            platform = "WebPlayer";
            #endif
            string assetUrl = result[0].GetString(platform);
            Debug.Log("##### asset url=" + assetUrl);
            StartCoroutine(DownloadLogo(assetUrl));
        });
    }
Пример #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;
            }
        });
    }
    private void ShowLogo()
    {
        Debug.Log("##### ShowLogo");
        // Get the latest asset bundle.
        KiiQuery query = new KiiQuery();
        query.SortByDesc("_modified");
        query.Limit = 1;

        Kii.Bucket("AssetBundles").Query(query, (KiiQueryResult<KiiObject> result, Exception e) => {
            if (e != null)
            {
                Debug.Log("##### Failed to query. " + e.ToString());
                return;
            }
            if (result.Count == 0)
            {
                Debug.Log("##### Cannot find asset bundle.");
                return;
            }
            string platform = null;
            #if UNITY_IPHONE
            platform = "iOS";
            #elif UNITY_ANDROID
            platform = "Android";
            #elif UNITY_WEBPLAYER
            platform = "WebPlayer";
            #endif
            string assetUrl = result[0].GetString(platform);
            Debug.Log("##### asset url=" + assetUrl);
            StartCoroutine(DownloadLogo(assetUrl));
        });
    }
Пример #7
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);
    }
Пример #8
0
    public void ShowUserRank()
    {
        string clearTimeKind = "";

        switch (userDataManager.level) {

        case userDataManager.LEVEL.EASY:

            clearTimeKind = "easyClearTime";
            _resultTitleText.text = "Easy";
            break;

        case userDataManager.LEVEL.NORMAL:

            clearTimeKind = "normalClearTime";
            _resultTitleText.text = "Normal";
            break;

        case userDataManager.LEVEL.HARD:

            clearTimeKind = "hardClearTime";
            _resultTitleText.text = "Hard";
            break;
        }

        KiiQuery allQuery = new KiiQuery ();

        allQuery.SortByAsc (clearTimeKind); //按指定字段降序排列。
        allQuery.Limit = 10;

        string userName = "";
        int time = 0;

        Kii.Bucket ("ApplicationData").Query (allQuery, (KiiQueryResult<KiiObject> result, Exception ex) => {

            if (ex != null){
                Debug.Log ("Connect error:: " + ex);
                return;
            }

            foreach (KiiObject obj in result){

                if ((int)obj[clearTimeKind] > 0){

                    userName = obj["userName"].ToString();
                    time = (int)obj[clearTimeKind];

                    SetScollView (userName, time);
                }
            }
        });
    }
Пример #9
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;
         *              }
         *      }
         * });
         */
    }
Пример #10
0
    public void Cancel()
    {
        Debug.Log("Cancel");
        bool      validate  = true;
        KiiObject obj       = KiiObject.CreateByUri(objUri);
        KiiBucket appBucket = Kii.Bucket("Games");
        String    id        = "";

        try {
            obj.Refresh();
            id = obj.GetString("_id");
        } catch (Exception e) {
            Debug.Log("Fallo refresh id game: " + e);
        }
        KiiQuery query = new KiiQuery(
            KiiClause.And(
                KiiClause.Equals("gameName", gameName.GetComponent <InputField>().text)
                , KiiClause.NotEquals("_id", id)
                )
            );

        appBucket.Count(query, (KiiBucket b, KiiQuery q, int count, Exception e) => {
            if (e != null)
            {
                validate = false;
                applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Unexpected exception occurred");
                navigationController.GoTo("ALERT_VIEW");
                return;
            }
            if (count > 0)
            {
                validate = false;
                applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Game name already exist");
                navigationController.GoTo("ALERT_VIEW");
                return;
            }
            if (ValidatedFields() && validate)
            {
                navigationController.Back();
            }
            else
            {
                applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Invalid inputs.");
                navigationController.GoTo("ALERT_VIEW");
            }
        });
    }
Пример #11
0
    void PerformCountWithQuery()
    {
        message       = "Counting with query...";
        ButtonEnabled = false;

        KiiClause clause = KiiClause.GreaterThan("score", 50);
        KiiQuery  query  = new KiiQuery(clause);

        bucket.Count(query, (KiiBucket b, KiiQuery q, int count, Exception e) => {
            if (e != null)
            {
                message = "Execution failed : " + e.ToString();
                return;
            }
            message = string.Format("Number of objects when 'score' > 50 : {1}", clause.ToString(), count);
        });
    }
Пример #12
0
    public static int getHighScore()
    {
        if (KiiUser.CurrentUser == null) {
            return 0;
        }
        if (cachedHighScore > 0) {
            return cachedHighScore;
        }

        KiiUser user = KiiUser.CurrentUser;
        KiiBucket bucket = user.Bucket (BUCKET_NAME);
        KiiQuery query = new KiiQuery ();
        query.SortByDesc (SCORE_KEY);
        query.Limit = 10;

        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;
                }
            }
        });
        */
    }
Пример #13
0
    public void ShowUserRank()
    {
        switch (userDataManager.level) {

        case userDataManager.LEVEL.EASY:

            _levelText.text = "Easy";
            break;

        case userDataManager.LEVEL.NORMAL:

            _levelText.text = "Normal";
            break;

        case userDataManager.LEVEL.HARD:

            _levelText.text = "Hard";
            break;
        }

        KiiQuery allQuery = new KiiQuery ();

        allQuery.SortByDesc ("percentage"); //按指定字段降序排列。
        allQuery.Limit = 10;

        Kii.Bucket ("ApplicationData").Query (allQuery, (KiiQueryResult<KiiObject> result, Exception ex) => {

            if (ex != null){
                Debug.Log ("Connect error:: " + ex);
                return;
            }

            foreach (KiiObject obj in result){

                int iconIndex = (int)obj ["iconIndex"];
                string userName = (string)obj["userName"];
                int percentage = (int)obj["percentage"];
                string percentageStr = percentage + "%";

                SetScollView (iconIndex, userName, percentageStr);
            }
        });
    }
Пример #14
0
    void PerformQuery()
    {
        message       = "Query...";
        ButtonEnabled = false;

        KiiQuery query = new KiiQuery();

        bucket.Query(query, (KiiQueryResult <KiiObject> list, Exception e) =>
        {
            ButtonEnabled = true;
            if (e != null)
            {
                message = "Failed to query " + e.ToString();
                return;
            }
            objectList = list;
            message    = "Query succeeded";
        });
    }
Пример #15
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;
			}
		});
	}
Пример #16
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());
		}
	}
Пример #17
0
    void OnEnable()
    {
        if (applicationController.sessionStarted)
        {
            KiiBucket appBucket = Kii.Bucket("Games");
            KiiQuery  query     = new KiiQuery(KiiClause.Equals("_owner", KiiUser.CurrentUser.ID));

            appBucket.Query(query, (KiiQueryResult <KiiObject> result, Exception e) => {
                if (e != null)
                {
                    Debug.Log(e);
                    applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Unexpected exception occurred");
                    navigationController.GoTo("ALERT_VIEW");
                    return;
                }
                foreach (KiiObject obj in result)
                {
                    GameObject gameBoxI;
                    gameBoxI = Instantiate(gameBox);
                    gameBoxI.SetActive(true);
                    gameBoxI.transform.SetParent(container.transform);
                    gameBoxI.transform.localScale = new Vector3(1, 1, 1);
                    gameBoxI.GetComponentsInChildren <Text> () [0].text = obj.GetString("gameName");
                    gameBoxI.GetComponentInChildren <Button>().onClick.AddListener(() => editViewController.GetComponent <EditViewController>().SetUri(obj.Uri));
                    gameBoxI.GetComponentInChildren <Button>().onClick.AddListener(() => navigationController.GoTo("EDIT_VIEW"));
                    //gameBox.GetComponentInChildren<RawImage>().texture = obj["icon"];
                }
                GameObject addGameBut;
                addGameBut = Instantiate(addGameButton);
                addGameBut.SetActive(true);
                addGameBut.transform.SetParent(container.transform);
                addGameBut.transform.localScale = new Vector3(1, 1, 1);
                addGameBut.GetComponentInChildren <Button>().onClick.AddListener(() => NewGame());
            });
        }
    }
Пример #18
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);
    }
Пример #19
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;
	}
Пример #20
0
    //Genera las filas de la lista de partidas disponibles TUYAS. Las columnas estan ya diseñadas.
    void llenarPartidasTuyas()
    {
        string[] creatorstring = new string[20];
        string[] numberofplayersstring = new string[20];
        string[] puzzlesizestring = new string[20];
        string[] powerupsstring = new string[20];
        string[] goTopicURLstring = new string[20];
        int x = 0;
        //Busca en Kii las partidas TUYAS
        KiiQuery allQuery = new KiiQuery();
        KiiUser.CurrentUser.Bucket(mystats.idplayer + "sGames").Query(allQuery, (KiiQueryResult<KiiObject> result, Exception e) =>
        {
            float exis = -(200f * 0.0016f);
            float eye = -(200f * 0.0016f) + calculaHuecos;
            GameObject userObject = Instantiate(UserMatches, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
            UserWorld[0] = userObject;
            userObject.transform.parent = scroll.transform;
            userObject.SetActive(true);
            if (e != null)
            {
                // handle error
                return;
            }
            foreach (KiiObject obj in result)
            {
                numberofplayersstring[x] = (string)obj[key8];
                creatorstring[x] = (string)obj[key9];
                puzzlesizestring[x] = (string)obj[key10];
                powerupsstring[x] = (string)obj[key11];
                goTopicURLstring[x] = (string)obj[key12];
                lista[x] = obj;
                int p = x + 1;
                Debug.Log("Este es el Uri de la partida " + p + ": " + obj.Uri.ToString());
                x++;
            }
            Debug.Log("Partidas disponibles encontradas TUYAS: " + x);
            tulista = new GameObject[x];
            calculaHuecos = x;
            for (int y = 0; y < x; y++)
            {

                eye = eye - (100f * 0.0016f);
                GameObject childObject = Instantiate(match, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                childObject.transform.parent = scroll.transform;
                tulista[y] = childObject;
                if (y == x - 1)
                {
                    calculaHuecos = eye;
                }

            }
            for (int i = 0; i < x; i++)
            {
                GameObject creator = tulista[i].transform.FindChild("Creator").gameObject;
                GameObject numberofplayers = tulista[i].transform.FindChild("NumberOfPlayers").gameObject;
                GameObject puzzlesize = tulista[i].transform.FindChild("PuzzleSize").gameObject;
                GameObject powerups = tulista[i].transform.FindChild("PowerUps").gameObject;
                GameObject unirse = tulista[i].transform.FindChild("SafeCheck").gameObject;
                GameObject nocheck = tulista[i].transform.FindChild("Check").gameObject;
                nocheck.SetActive(false);
                GameObject idJsonPArtidas = tulista[i].transform.FindChild("jsonID").gameObject;
                GameObject goTopicURL = tulista[i].transform.FindChild("topicURL").gameObject;
                UILabel creatorlabel = creator.GetComponent<UILabel>();
                UILabel numberofplayerslabel = numberofplayers.GetComponent<UILabel>();
                UILabel puzzlesizelabel = puzzlesize.GetComponent<UILabel>();
                UILabel powerupslabel = powerups.GetComponent<UILabel>();
                UILabel idjonLabel = idJsonPArtidas.GetComponent<UILabel>();
                UILabel topicURLlabel = goTopicURL.GetComponent<UILabel>();
                creatorlabel.text = "" + creatorstring[i] + "";
                numberofplayerslabel.text = "" + numberofplayersstring[i] + "";
                puzzlesizelabel.text = "" + puzzlesizestring[i] + "";
                powerupslabel.text = "" + powerupsstring[i] + "";
                idjonLabel.text = "" + lista[i].Uri.ToString() + "";
                topicURLlabel.text = "" + lista[i][key12] + "";
            }
            /*
            Debug.Log ("Partidas disponibles TUYAS encontradas: " + savedGames.take1.Count);
            float exis = -(200f*0.0016f);
            float eye = -(100f*0.0016f);
            tulista = new GameObject[savedGames.take1.Count];
            calculaHuecos = savedGames.take1.Count;
            for (int x = 0; x < savedGames.take1.Count+1; x++) {
                eye = eye -(100f*0.0016f);
                if (x == 0) {
                    GameObject userObject = Instantiate(UserMatches, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                    UserWorld[0] = userObject;
                    userObject.transform.parent = scroll.transform;
                    userObject.SetActive (true);
                } else {
                    GameObject childObject = Instantiate(match, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                    childObject.transform.parent = scroll.transform;
                    tulista[x-1] = childObject;
                    if(x == savedGames.take1.Count){
                        calculaHuecos = eye;
                    }
                }
            }
            for (int i = 0; i < savedGames.take1.Count; i++) {
                GameObject creator = tulista[i].transform.FindChild ("Creator").gameObject;
                GameObject numberofplayers = tulista[i].transform.FindChild ("NumberOfPlayers").gameObject;
                GameObject puzzlesize = tulista[i].transform.FindChild ("PuzzleSize").gameObject;
                GameObject powerups = tulista[i].transform.FindChild ("PowerUps").gameObject;
                GameObject unirse = tulista[i].transform.FindChild ("SafeCheck").gameObject;
                GameObject nocheck = tulista[i].transform.FindChild("Check").gameObject;
                GameObject idJsonPArtidas = tulista[i].transform.FindChild ("jsonID").gameObject;
                nocheck.SetActive(false);
                UILabel creatorlabel = creator.GetComponent<UILabel>();
                UILabel numberofplayerslabel = numberofplayers.GetComponent<UILabel>();
                UILabel puzzlesizelabel = puzzlesize.GetComponent<UILabel>();
                UILabel powerupslabel = powerups.GetComponent<UILabel>();
                UILabel idjonLabel = idJsonPArtidas.GetComponent<UILabel>();
                jsonObj = savedGames.take1 [i].GetJsonDoc();
                string creatorstring = getinfo.sacarinfo ("Host", jsonObj);
                string numberofplayersstring = "2";
                string puzzlesizestring = "16";
                string powerupsstring = "no";
                string jsonId = savedGames.take1[i].GetDocId();
                creatorlabel.text = "" + creatorstring + "";
                Debug.Log (creatorstring);
                numberofplayerslabel.text = "" + numberofplayersstring + "";
                puzzlesizelabel.text = "" + puzzlesizestring + "";
                powerupslabel.text = "" + powerupsstring + "";
                idjonLabel.text = "" +jsonId+"";
            }
            */
        });
    }
Пример #21
0
    void llenarPartidas()
    {
        string[] creatorstring = new string[20];
        string[] numberofplayersstring = new string[20];
        string[] puzzlesizestring = new string[20];
        string[] powerupsstring = new string[20];
        string[] goTopicURLstring = new string[20];
        int x = 0;
        //Genera las filas de la lista de partidas disponibles
        // Las columnas estan ya diseñadas.
        KiiQuery query = new KiiQuery(
                  KiiClause.And(
                        KiiClause.Equals(key4, "false"),
                        KiiClause.NotEquals(key9, mystats.idplayer)
                      )
                  );

        // Alternatively, you can also do:
        // Kii.Bucket("myBuckets").Query(null, (...));
        Kii.Bucket("Global").Query(query, (KiiQueryResult<KiiObject> result, Exception e) =>
        {
            float exis = -(200f * 0.0016f);
            float eye = -(200f * 0.0016f) + calculaHuecos;
            GameObject worldObject = Instantiate(WorldMatches, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
            world[0] = worldObject;
            worldObject.transform.parent = scroll.transform;
            worldObject.SetActive(true);
            if (e != null)
            {
                // handle error
                return;
            }
            foreach (KiiObject obj in result)
            {
                numberofplayersstring[x] = (string)obj[key8];
                creatorstring[x] = (string)obj[key9];
                puzzlesizestring[x] = (string)obj[key10];
                powerupsstring[x] = (string)obj[key11];
                goTopicURLstring[x] = (string)obj[key12];
                lista[x] = obj;
                int p = x + 1;
                Debug.Log("Este es el Uri de la partida "+ p +": " + obj.Uri.ToString());
                x++;
            }
            Debug.Log("Partidas disponibles encontradas: " + x);
            listaOld = new GameObject[x];
            for (int y = 0; y < x; y++)
            {

                eye = eye - (100f * 0.0016f);
                GameObject childObject = Instantiate(match, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                childObject.transform.parent = scroll.transform;
                listaOld[y] = childObject;
                if (y == x - 1)
                {
                    calculaHuecos = eye;
                }

            }
            for (int i = 0; i < x; i++)
            {
                GameObject creator = listaOld[i].transform.FindChild("Creator").gameObject;
                GameObject numberofplayers = listaOld[i].transform.FindChild("NumberOfPlayers").gameObject;
                GameObject puzzlesize = listaOld[i].transform.FindChild("PuzzleSize").gameObject;
                GameObject powerups = listaOld[i].transform.FindChild("PowerUps").gameObject;
                GameObject unirse = listaOld[i].transform.FindChild("Check").gameObject;
                GameObject nocheck = listaOld[i].transform.FindChild("SafeCheck").gameObject;
                nocheck.SetActive(false);
                GameObject idJsonPArtidas = listaOld[i].transform.FindChild("jsonID").gameObject;
                GameObject goTopicURL = listaOld[i].transform.FindChild("topicURL").gameObject;
                UILabel creatorlabel = creator.GetComponent<UILabel>();
                UILabel numberofplayerslabel = numberofplayers.GetComponent<UILabel>();
                UILabel puzzlesizelabel = puzzlesize.GetComponent<UILabel>();
                UILabel powerupslabel = powerups.GetComponent<UILabel>();
                UILabel idjonLabel = idJsonPArtidas.GetComponent<UILabel>();
                UILabel topicURLlabel = goTopicURL.GetComponent<UILabel>();
                creatorlabel.text = "" + creatorstring[i] + "";
                numberofplayerslabel.text = "" + numberofplayersstring[i] + "";
                puzzlesizelabel.text = "" + puzzlesizestring[i] + "";
                powerupslabel.text = "" + powerupsstring[i] + "";
                idjonLabel.text = "" + lista[i].Uri.ToString() + "";
                topicURLlabel.text = "" + lista[i][key12] + "";
            }
        });
        /*if (callBack.take1.Count < 2)
        {
            notfound.SetActive(true);
        }
        else
        {
            float exis = -(200f * 0.0016f);
            float eye = -(200f * 0.0016f) + calculaHuecos;
            lista = new GameObject[callBack.take1.Count];
            for (int x = 0; x < callBack.take1.Count + 1; x++)
            {
                if (x == 0)
                {
                    GameObject worldObject = Instantiate(WorldMatches, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                    world[0] = worldObject;
                    worldObject.transform.parent = scroll.transform;
                    worldObject.SetActive(true);
                }
                else
                {
                    eye = eye - (100f * 0.0016f);
                    GameObject childObject = Instantiate(match, new Vector3(exis, eye, 0f), Quaternion.identity) as GameObject;
                    childObject.transform.parent = scroll.transform;
                    lista[x - 1] = childObject;
                    if (x == callBack.take1.Count - 1)
                    {
                        calculaHuecos = eye;
                    }
                }
            }
            for (int i = 0; i < callBack.take1.Count; i++)
            {
                GameObject creator = lista[i].transform.FindChild("Creator").gameObject;
                GameObject numberofplayers = lista[i].transform.FindChild("NumberOfPlayers").gameObject;
                GameObject puzzlesize = lista[i].transform.FindChild("PuzzleSize").gameObject;
                GameObject powerups = lista[i].transform.FindChild("PowerUps").gameObject;
                GameObject unirse = lista[i].transform.FindChild("Check").gameObject;
                GameObject idJsonPArtidas = lista[i].transform.FindChild("jsonID").gameObject;
                UILabel creatorlabel = creator.GetComponent<UILabel>();
                UILabel numberofplayerslabel = numberofplayers.GetComponent<UILabel>();
                UILabel puzzlesizelabel = puzzlesize.GetComponent<UILabel>();
                UILabel powerupslabel = powerups.GetComponent<UILabel>();
                UILabel idjonLabel = idJsonPArtidas.GetComponent<UILabel>();
                jsonObj = callBack.take1[i].GetJsonDoc();
                string creatorstring = getinfo.sacarinfo(key9, jsonObj);
                string numberofplayersstring = getinfo.sacarinfo(key8, jsonObj);
                string puzzlesizestring = getinfo.sacarinfo(key10, jsonObj);
                string powerupsstring = getinfo.sacarinfo(key11, jsonObj);
                string jsonId = callBack.take1[i].GetDocId();
                creatorlabel.text = "" + creatorstring + "";
                Debug.Log(creatorstring);
                numberofplayerslabel.text = "" + numberofplayersstring + "";
                puzzlesizelabel.text = "" + puzzlesizestring + "";
                powerupslabel.text = "" + powerupsstring + "";
                idjonLabel.text = "" + jsonId + "";
            }
        }
        searching.text = "";
        }*/
        searching.text = "";
    }
Пример #22
0
    public void joinmatch()
    {
        searching.text = "Joining match...";
        /*
        UIButton linea = UIButton.current;
        GameObject lin = linea.gameObject;
        GameObject padre = lin.transform.parent.gameObject;
        GameObject enemyhijo = padre.transform.FindChild("Creator").gameObject;
        GameObject idhijo = padre.transform.FindChild("jsonID").gameObject;
        UILabel enemyLabel = enemyhijo.GetComponent<UILabel>();
        UILabel idLabel = idhijo.GetComponent<UILabel>();
        string enemyString = enemyLabel.text;
        string idString = idLabel.text;
        mystats.idplayer2 = enemyString;
        mystats.idjson = idString;
        */
        // Prepare the target bucket to be queried
        KiiBucket bucket = KiiUser.CurrentUser.Bucket(mystats.idplayer + "SaveGames");

        // Define query conditions
        KiiQuery query = new KiiQuery(
          KiiClause.Equals(gamekey2, mystats.yourIdJson)
        );

        // Query the bucket
        bucket.Query(query, (KiiQueryResult<KiiObject> result, Exception e) =>
        {
            if (e != null)
            {
                Debug.LogError("Error: " + e.ToString());
                // handle error
                return;
            }
            foreach (KiiObject obj in result)
            {
                Debug.Log("ARCHIVO SAVEGAME ENCONTRADO.");
                /*
                Dictionary<string, object> jsonDoc = new Dictionary<string, object>();
                jsonObj = savedGames.take1[0].GetJsonDoc();
                */
                mystats.idjson = (string) obj[gamekey1];
                mystats.yourIdJson = (string) obj[gamekey2];
                mystats.oponente = (string) obj[gamekey54];
                for (int x = 1; x < 17; x++)
                {
                    string temp = "casilla" + x;
                    mystats.puzzles.pieces[x - 1] = bool.Parse((string) obj["casilla"+x]);
                }
                for (int y = 1; y < 5; y++)
                {
                    for (int z = 0; z < 2; z++)
                    {
                        if (z == 0)
                        {
                            mystats.puzzles.drawer[y - 1, z] = float.Parse((string) obj["cajon" + y]);
                        }
                        if (z == 1)
                        {
                            mystats.puzzles.drawer[y - 1, z] = float.Parse((string) obj["rotcajon"+y]);
                        }
                    }
                }
                mystats.puzzles.cpiece[0] = float.Parse((string) obj[gamekey23]);
                mystats.puzzles.npiece[0] = float.Parse((string) obj[gamekey24]);
                mystats.puzzles.cpiece[1] = float.Parse((string) obj[gamekey45]);
                mystats.puzzles.npiece[1] = float.Parse((string) obj[gamekey46]);
                for (int t = 1; t < 17; t++)
                {
                    mystats.puzzles.deck[t - 1] = int.Parse((string) obj["deck"+t]);
                }
                mystats.jugador = (string) obj[gamekey47];
                mystats.puzzles.t = int.Parse((string) obj[gamekey48]);
                mystats.puzzles.r = int.Parse((string) obj[gamekey49]);
                mystats.puzzles.maxDeckValue = int.Parse((string) obj[gamekey50]);
                mystats.puzzles.puzzleID = int.Parse((string) obj[gamekey51]);
                mystats.puzzles.myprogress = int.Parse((string) obj[gamekey52]);
                mystats.puzzles.myoppprogress = int.Parse((string) obj[gamekey53]);
                mystats.aQuienLeTOCA = (string)obj[gamekey56];
                mystats.alreadyBegun = true;
                StartCoroutine(join());
            }
        });
    }
Пример #23
0
    public void buscar()
    {
        //Busca una partida vacia
        // Prepare the target bucket to be queried
        KiiBucket bucket = Kii.Bucket("Global");

        // Define query conditions
        KiiQuery query = new KiiQuery(
            KiiClause.Equals("Full","True")
        );

        // Fine-tune your query results
        query.Limit = 1;

        // Query the bucket
        bucket.Query(query, (KiiQueryResult<KiiObject> result, Exception e) =>
        {
            if (e != null)
            {
                Debug.LogError("Query Object failed: " + e.ToString());
                // handle error
                return;
            }
            foreach (KiiObject obj in result)
            {
                obj.GetUri(objectUri);
                Debug.Log("Uri del objeto: " + objectUri);
                string turno = (string)obj[key2];
                string turnoplayer = (string)obj[key3];
                string idjugador1 = (string)obj[key9];

                //Updating match information.
                KiiObject obj2 = KiiObject.CreateByUri(new Uri(objectUri));
                obj2.Refresh((KiiObject obj3, Exception e2) =>
                {
                    if (e2 != null)
                    {
                        Debug.LogError("Retreving Object failed: " + e2.ToString());
                        // handle error
                        return;
                    }
                    //Update following information
                    value1 = round.ToString();
                    value2 = turno;
                    value3 = turnoplayer;
                    value4 = full;
                    value5 = mystats.idplayer;
                    value9 = idjugador1;

                    obj3[key1] = value1;
                    obj3[key2] = value2;
                    obj3[key3] = value3;
                    obj3[key4] = value4;
                    obj3[key5] = value5;
                    obj3[key6] = value6;
                    obj3[key7] = value7;
                    obj3[key8] = value8;
                    obj3[key9] = value9;
                    obj3[key10] = value10;
                    obj3[key11] = value11;
                    obj3.SaveAllFields(false, (KiiObject updatedObj, Exception e3) =>
                    {
                        if (e3 != null)
                        {
                            Debug.LogError("Update Object failed: " + e3.ToString());
                            // handle error
                        }
                        else
                        {
                            //TENEMOS QUE SEGUIR AQUI: IMPLEMENTAR KII TOPICS
                            mystats.idplayer2 = key9;
                            Debug.Log("Match information upadted successfully.");
                        }
                    });
                });
            }
        });
        /*
        storageService = sp.BuildStorageService();
        storageService.FindDocumentByKeyValue(dbName, collectionName, key4, validador, callBack);
        nomatch = 0;
        check = true;
        */
    }
Пример #24
0
    void PerformCountWithQuery()
    {
        message = "Counting with query...";
        ButtonEnabled = false;

        KiiClause clause = KiiClause.GreaterThan("score", 50);
        KiiQuery query = new KiiQuery(clause);
        bucket.Count(query, (KiiBucket b, KiiQuery q, int count, Exception e) => {
            if (e != null)
            {
                message = "Execution failed : " + e.ToString();
                return;
            }
            message = string.Format("Number of objects when 'score' > 50 : {1}", clause.ToString(), count);
        });
    }
Пример #25
0
 // Use this for initialization
 void Start()
 {
     RecalcPlayerPrestige();
     System.DateTime queryStart = System.DateTime.UtcNow;
     KiiClause recentClause = KiiClause.GreaterThan("expires",
                                                    queryStart.Ticks);
     KiiClause mineClause = KiiClause.Equals("owner", Login.User.Username);
     KiiQuery recentQuery = new KiiQuery(KiiClause.And(recentClause,
                                                       mineClause));
     KiiQueryResult<KiiObject> result
             = Kii.Bucket("worlds").Query(recentQuery);
     if (result.Count == 0) {
         Debug.Log("Creating new world.");
         World = GenerateNewLevel();
     } else {
         KiiObject latest = result[0];
         World = latest;
         Debug.Log("Successfully loaded world.");
         PopulateWorld(latest.GetJsonArray("objects"));
         Village.RecalculateAll();
     }
     FindObjectOfType<AlienMgr>().ClearAliens();
 }
Пример #26
0
    public void Travel(bool goHome)
    {
        RecalcPlayerPrestige();
        System.DateTime queryStart = System.DateTime.UtcNow;
        KiiClause recentClause = KiiClause.GreaterThan("expires",
                                                       queryStart.Ticks);
        KiiQuery worldsQuery;
        if (goHome) {
            KiiClause mineClause = KiiClause.Equals("owner",
                                                    Login.User.Username);
            worldsQuery = new KiiQuery(KiiClause.And(recentClause,
                                                     mineClause));
        } else {
            KiiClause notMineClause = KiiClause.NotEquals("owner",
                                                          Login.User.Username);
            worldsQuery = new KiiQuery(KiiClause.And(recentClause,
                                                     notMineClause));
        }

        KiiQueryResult<KiiObject> result
            = Kii.Bucket("worlds").Query(worldsQuery);

        targ.Deselect();
        if (goHome && result.Count == 0) {
            Debug.LogError("Could not find home! Making a new one.");
            ClearSpawnedObjects();
            World = GenerateNewLevel();
        } else if (!goHome && result.Count < MIN_WORLDS) {
            Debug.Log("Traveling to new anonymous world.");
            ClearSpawnedObjects();
            World = GenerateNewLevel(true);
        } else {
            ClearSpawnedObjects();
            int i = Mathf.FloorToInt(Random.value * result.Count);
            KiiObject latest = result[i];
            World = latest;
            Debug.Log("Successfully travelled " + (goHome ? "home." : "away."));
            PopulateWorld(latest.GetJsonArray("objects"));
            Village.RecalculateAll();
        }
        player.FindStartPos();
        FindObjectOfType<AlienMgr>().ClearAliens();

        AudioSource audio = GetComponent<AudioSource>();
        audio.clip = travelSound;
        audio.Play();
    }
Пример #27
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;
	}
Пример #28
0
    void RecalcPlayerPrestige()
    {
        Prestige = BASE_PRESTIGE;

        System.DateTime queryStart = System.DateTime.UtcNow.AddDays(-1);
        KiiClause recentClause = KiiClause.GreaterThan("expires",
                                                       queryStart.Ticks);
        KiiClause mineClause = KiiClause.Equals("owner",
                                                Login.User.Username);
        KiiQuery worldsQuery = new KiiQuery(KiiClause.And(recentClause,
                                                 mineClause));

        KiiQueryResult<KiiObject> result
                = Kii.Bucket("worlds").Query(worldsQuery);
        foreach (KiiObject k in result) {
            if (k.Has("worldPrestige")) {
                Prestige += k.GetInt("worldPrestige");
            }
        }
    }
Пример #29
0
    void PerformQuery()
    {
        message = "Query...";
        ButtonEnabled = false;

        KiiQuery query = new KiiQuery();
        bucket.Query(query, (KiiQueryResult<KiiObject> list, Exception e) =>
        {
            ButtonEnabled = true;
            if (e != null)
            {
                message = "Failed to query " + e.ToString();
                return;
            }
            objectList = list;
            message = "Query succeeded";
        });
    }