Esempio n. 1
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");
            }
        });
    }
Esempio n. 2
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 = "";
    }