Exemplo n.º 1
0
 public BucketPage(MainCamera camera, KiiGroup group, string  bucketName)
     : base(camera)
 {
     this.group = group;
     this.bucketName = bucketName;
     this.bucket = group.Bucket(bucketName);
 }
Exemplo n.º 2
0
    void OnGUI()
    {
        ScalableGUI gui = new ScalableGUI();

        gui.Label(5, 5, 310, 20, "Push2App scene");
        if (gui.Button(200, 5, 120, 35, "-> Push2User"))
        {
            this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback;
            Application.LoadLevel("push2user");
        }

        this.payload = gui.TextField(0, 45, 320, 50, this.payload);
        if (gui.Button(0, 100, 160, 50, "Create Object"))
        {
            KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME);
            KiiObject obj    = bucket.NewKiiObject();
            obj["payload"] = this.payload;
            obj.Save((KiiObject o, Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("Failed to save object", e);
                    return;
                }
                this.message = "#####creating object is successful!!";
            });
        }
        if (gui.Button(160, 100, 160, 50, "Clear Log"))
        {
            this.message = "";
        }
        if (gui.Button(0, 150, 160, 50, "Register Push"))
        {
            Invoke("registerPush", 0);
        }
        if (gui.Button(160, 150, 160, 50, "Unregister Push"))
        {
            this.kiiPushPlugin.UnregisterPush((Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("#####Unregister push is failed!!", e);
                    return;
                }
                this.message = "#####Unregister push is successful!!";
            });
        }
        gui.Label(5, 210, 310, 270, this.message, 10);
    }
Exemplo n.º 3
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.º 4
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");
            }
        });
    }
Exemplo n.º 5
0
    void ScoreLoop()
    {
        if (count < 27)
        {
            gameTime = Time.timeSinceLevelLoad;
        }
        else
        {
            winText.text = "YOU WIN!!";
            if (user != null && !scoreSent)
            {
                scoreSent = true;
                KiiBucket bucket = Kii.Bucket(appScopeScoreBucket);
                KiiObject score  = bucket.NewKiiObject();
                score["time"]     = gameTime;
                score["username"] = user.Username;
                // score is game completion time, the lower the better
                Debug.Log("Saving score...");
                score.Save((KiiObject obj, Exception e) => {
                    if (e != null)
                    {
                        Debug.LogError(e.ToString());
                    }
                    else
                    {
                        Debug.Log("Score sent: " + gameTime.ToString("n2"));
                    }
                });
            }
        }
        string username = "";

        if (user != null)
        {
            username = user.Username + " ";
        }
        countText.text = username + count.ToString() + "/27 " + gameTime.ToString("n2");
    }
Exemplo n.º 6
0
    //KiiCloud上のデータ保存枠を初期化
    bool kiiDataInitialize()
    {
        //ユーザーバケットを定義
        KiiBucket userBucket =
            KiiUser.CurrentUser.Bucket("myBasicData");
        KiiObject basicDataObj = userBucket.NewKiiObject();

        //保存するデータを定義
        basicDataObj["lv"]    = 1;
        basicDataObj["exp"]   = 0;
        basicDataObj["open2"] = false;
        basicDataObj["open3"] = false;
        basicDataObj["wp"]    = 0;
        //オブジェクトを保存
        try{
            basicDataObj.Save();
        }catch (System.Exception e) {
            Debug.LogError(e);
            return(false);
        }

        return(true);
    }
Exemplo n.º 7
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());
            });
        }
    }
Exemplo n.º 8
0
    public static void RegisterDeath(GameObject deadObject)
    {
        if (Instance == null)
        {
            Debug.Log("Game score not loaded");
            return;
        }

        int
            playerLayer = LayerMask.NameToLayer(Instance.playerLayerName),
            enemyLayer  = LayerMask.NameToLayer(Instance.enemyLayerName);

        Debug.Log("Getting KiiUser");
        user = KiiUser.CurrentUser;

        if (user == null)
        {
            if (deadObject.layer == playerLayer)
            {
                Instance.deaths++;
            }
            else if (deadObject.layer == enemyLayer)
            {
                Instance.kills [deadObject.name] = Instance.kills.ContainsKey(deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            }
            else
            {
                Instance.kills [deadObject.name] = Instance.kills.ContainsKey(deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            }
            return;
        }

        Debug.Log("Creating app bucket");
        appBucket = Kii.Bucket(BUCKET_NAME);

        Debug.Log("Creating death object");
        KiiObject death = appBucket.NewKiiObject();

        death["user"]  = user.Username;
        death ["time"] = Time.time;

        if (deadObject.layer == playerLayer)
        {
            Instance.deaths++;
            death ["type"]  = "Player";
            death ["count"] = Instance.deaths;
            Debug.Log("Dead player counted");
            Debug.Log("Saving death object");
        }
        else if (deadObject.layer == enemyLayer)
        {
            Instance.kills [deadObject.name] = Instance.kills.ContainsKey(deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            death ["type"]  = "Enemy";
            death ["enemy"] = deadObject.name;
            death ["count"] = Instance.kills [deadObject.name];
            Debug.Log("Dead enemy counted");
            Debug.Log("Saving death object...");
        }
        else
        {
            Instance.kills [deadObject.name] = Instance.kills.ContainsKey(deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            death ["type"]  = "Unknown";
            death ["enemy"] = deadObject.name;
            death ["count"] = Instance.kills [deadObject.name];
            Debug.Log("Dead entity counted");
            Debug.Log("Saving death object...");
        }

        death.Save((KiiObject obj, Exception e) => {
            if (e != null)
            {
                Debug.Log("GameScore: Failed to create death object: " + e.ToString());
            }
            else
            {
                Debug.Log("GameScore: Create death object succeeded");
            }
        });
    }
Exemplo n.º 9
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());
            }
        });
    }
Exemplo n.º 10
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;
        */
    }
Exemplo n.º 11
0
 public static void RegisterDamage(string target, float amount, float totalHealth, float gameTime, Vector3 direction)
 {
     Debug.Log("Getting KiiUser");
     user = KiiUser.CurrentUser;
     if(user == null)
         return;
     Debug.Log("Creating app bucket");
     appBucket = Kii.Bucket(BUCKET_NAME);
     Debug.Log("Creating damage object");
     KiiObject damage = appBucket.NewKiiObject();
     damage ["user"] = user.Username;
     damage ["target"] = target;
     damage ["time"] = gameTime;
     damage ["health"] = totalHealth;
     damage ["amount"] = amount;
     damage ["direction"] = direction;
     Debug.Log ("Saving damage object...");
     damage.Save((KiiObject obj, Exception e) => {
         if (e != null){
             Debug.Log ("GameScore: Failed to create damage object: " + e.ToString());
         } else {
             Debug.Log ("GameScore: Create damage object succeeded");
         }
     });
 }
Exemplo n.º 12
0
    public static void RegisterDeath(GameObject deadObject)
    {
        if (Instance == null)
        {
            Debug.Log ("Game score not loaded");
            return;
        }

        int
            playerLayer = LayerMask.NameToLayer (Instance.playerLayerName),
            enemyLayer = LayerMask.NameToLayer (Instance.enemyLayerName);

        Debug.Log("Getting KiiUser");
        user = KiiUser.CurrentUser;

        if(user == null){
            if (deadObject.layer == playerLayer) {
                Instance.deaths++;
            } else if (deadObject.layer == enemyLayer) {
                Instance.kills [deadObject.name] = Instance.kills.ContainsKey (deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            } else {
                Instance.kills [deadObject.name] = Instance.kills.ContainsKey (deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            }
            return;
        }

        Debug.Log("Creating app bucket");
        appBucket = Kii.Bucket(BUCKET_NAME);

        Debug.Log("Creating death object");
        KiiObject death = appBucket.NewKiiObject();
        death["user"] = user.Username;
        death ["time"] = Time.time;

        if (deadObject.layer == playerLayer) {
            Instance.deaths++;
            death ["type"] = "Player";
            death ["count"] = Instance.deaths;
            Debug.Log ("Dead player counted");
            Debug.Log ("Saving death object");
        } else if (deadObject.layer == enemyLayer) {
            Instance.kills [deadObject.name] = Instance.kills.ContainsKey (deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            death ["type"] = "Enemy";
            death ["enemy"] = deadObject.name;
            death ["count"] = Instance.kills [deadObject.name];
            Debug.Log ("Dead enemy counted");
            Debug.Log ("Saving death object...");
        } else {
            Instance.kills [deadObject.name] = Instance.kills.ContainsKey (deadObject.name) ? Instance.kills [deadObject.name] + 1 : 1;
            death ["type"] = "Unknown";
            death ["enemy"] = deadObject.name;
            death ["count"] = Instance.kills [deadObject.name];
            Debug.Log ("Dead entity counted");
            Debug.Log ("Saving death object...");
        }

        death.Save((KiiObject obj, Exception e) => {
            if (e != null){
                Debug.Log ("GameScore: Failed to create death object: " + e.ToString());
            } else {
                Debug.Log ("GameScore: Create death object succeeded");
            }
        });
    }
Exemplo n.º 13
0
    void OnEnable()
    {
        if (applicationController.sessionStarted)
        {
            for (int i = 0; i < 4; i++)
            {
                GameObject instantiatedPrefab;
                instantiatedPrefab = Instantiate(screenshotBox) as GameObject;
                instantiatedPrefab.SetActive(true);
                instantiatedPrefab.transform.SetParent(screensList.transform);
                instantiatedPrefab.transform.localScale = new Vector3(1, 1, 1);
                instantiatedPrefab.GetComponent <Button> ().onClick.AddListener(() => GetButtonIndex(instantiatedPrefab));
                instantiatedPrefab.GetComponent <Button> ().onClick.AddListener(() => OpenScreenshot());
                buttonList.Add(instantiatedPrefab);
            }
            bool      validate  = true;
            KiiBucket appBucket = Kii.Bucket("Games");
            //string gameNameTrim = gameName.GetComponent<InputField> ().text.Replace (" ", String.Empty);

            /*KiiQuery query = new KiiQuery(
             * KiiClause.And(
             * KiiClause.Equals("gameName", gameName.GetComponent<InputField>().text)
             * ,KiiClause.Equals("bucketScreenshotsId", gameNameTrim)
             * )
             * );*/
            //string bucketName = gameNameTrim+"-Screenshots-";
            string    userId = KiiUser.CurrentUser.ID;
            KiiObject obj    = Kii.Bucket("Games").NewKiiObject();
            String    id     = "";
            try {
                obj.Refresh();
                id = obj.GetString("_id");
            } catch (Exception e) {
                Debug.Log("Fallo refresh id game: " + e);
            }

            /*obj["gameName"] = gameName.GetComponent<InputField>().text;
             * obj["gameDescription"] = gameDescription.GetComponent<InputField>().text;
             * obj["gameCategories"] = gameCategories.GetComponent<InputField>().text;
             * obj["gameKeywords"] = gameKeywords.GetComponent<InputField>().text;
             * obj["gameEula"] = gameEula.GetComponent<InputField>().text;
             * obj["gamePlatform"] = gamePlatform.GetComponent<Text> ().text;
             * obj["gameLanguage"] = gameLanguage.GetComponent<Text> ().text;
             * obj["userId"] = userId;
             * obj["bucketScreenshotsId"] = gameNameTrim;*/

            //obj["GameBucket"] = userId;

            //if(ValidatedFields()){

            /*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 (validate)
            {
                // Save the object
                obj.SaveAllFields(true, (KiiObject savedObj, Exception exc) => {
                    if (exc is NetworkException)
                    {
                        if (((NetworkException)exc).InnerException is TimeoutException)
                        {
                            // Network timeout occurred
                            applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Network timeout occurred");
                            navigationController.GoTo("ALERT_VIEW");
                            return;
                        }
                        else
                        {
                            // Network error occurred
                            applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Network error occurred");
                            navigationController.GoTo("ALERT_VIEW");
                            return;
                        }
                    }
                    else if (exc is ConflictException)
                    {
                        // Registration failed because the user already exists
                        applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Registration failed because the game name already exists");
                        navigationController.GoTo("ALERT_VIEW");
                        return;
                    }
                    else if (exc is CloudException)
                    {
                        // Registration failed
                        applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Registration failed");
                        navigationController.GoTo("ALERT_VIEW");
                        return;
                    }
                    else if (exc != null)
                    {
                        // Unexpected exception occurred
                        applicationController.alertView.GetComponent <AlertViewController> ().SetAlert("Unexpected exception occurred");
                        navigationController.GoTo("ALERT_VIEW");
                        return;
                    }
                    ;
                    objUri = obj.Uri;
                    Debug.Log("mi uri es:" + objUri);

                    /*Debug.Log ("SavingImages.");
                     * SaveImage(0, obj);*/
                });
            }

            //});
            //Check whether the id is valid.

            /*for (int i = 1; i < imagePaths.Length; i++){
             * SaveImages(bucketName, i);
             * }
             * Debug.Log ("ImagesSaved: GoTo Edit");*/
            //navigationController.GoTo ("EDIT_VIEW");
            //}
        }
    }
Exemplo n.º 14
0
    private void register()
    {
        user       = null;
        OnCallback = true;
        KiiUser built_user = KiiUser.BuilderWithName(username).Build();

        built_user.Register(password, (KiiUser user2, Exception e) => {
            if (e == null)
            {
                                #if UNITY_IPHONE
                bool development = true;                      // choose development/production for iOS
                string USER      = username;
                string PASS      = password;
                KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.IOS;
                plugin = GameObject.Find("KiiPush").GetComponent <KiiPushPlugin>();
                plugin.RegisterPush((string pushToken, Exception e0) => {
                    Debug.Log("Token :" + pushToken);
                    if (e0 == null)
                    {
                        KiiUser.LogIn(USER, PASS, (KiiUser kiiuser, Exception e1) => {
                            if (e1 == null)
                            {
                                KiiUser.PushInstallation(development).Install(pushToken, deviceType, (Exception e2) => {
                                    Debug.Log("Push registration completed");
                                    KiiUser user3          = KiiUser.CurrentUser;
                                    KiiBucket bucket       = Kii.Bucket("FlappyDogHighScore");
                                    KiiPushSubscription ps = user3.PushSubscription;
                                    ps.Subscribe(bucket, (KiiSubscribable target, Exception e3) => {
                                        if (e3 != null)
                                        {
                                            // check fail cause
                                            Debug.Log("Subscription Failed");
                                            Debug.Log(e3.ToString());
                                        }
                                    });
                                });
                            }
                            else
                            {
                                Debug.Log("e1 error: " + e1.ToString());
                            };
                        });
                    }
                    else
                    {
                        Debug.Log("e0 error: " + e0.ToString());
                    };
                });
                                #endif

                user = user2;
                Debug.Log("Register completed");
            }
            else
            {
                user       = null;
                OnCallback = false;
                Debug.Log("Register failed : " + e.ToString());
            }
        });
    }
Exemplo n.º 15
0
 public BucketPage(MainCamera camera, KiiBucket bucket) : base(camera)
 {
     this.bucket = bucket;
 }
Exemplo n.º 16
0
 public BucketPage(MainCamera camera, KiiGroup group, string bucketName) : base(camera)
 {
     this.group      = group;
     this.bucketName = bucketName;
     this.bucket     = group.Bucket(bucketName);
 }
Exemplo n.º 17
0
    void registerPush()
    {
                #if UNITY_IPHONE
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.IOS;
                #elif UNITY_ANDROID
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.ANDROID;
                #else
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.ANDROID;
                #endif

        if (this.kiiPushPlugin == null)
        {
            Debug.Log("#####failed to find KiiPushPlugin");
            return;
        }
        this.kiiPushPlugin.RegisterPush((string pushToken, Exception e0) => {
            if (e0 != null)
            {
                Debug.Log("#####failed to RegisterPush");
                this.message = "#####failed to RegisterPush : " + pushToken;
                return;
            }

            Debug.Log("#####RegistrationId=" + pushToken);
            this.message = "Token : " + pushToken + "\n";
            Debug.Log("#####Install");
            KiiUser.PushInstallation(true).Install(pushToken, deviceType, (Exception e3) => {
                if (e3 != null)
                {
                    Debug.Log("#####failed to Install");
                    this.ShowException("Failed to install PushNotification -- pushToken=" + pushToken, e3);
                    return;
                }
                KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME);
                Debug.Log("#####Subscribe");
                String userId = KiiUser.CurrentUser.GetString("userID");
                Debug.Log("#####https://api-jp.kii.com/api/apps/f39c2d34/users/" + userId + "/buckets/app_bucket/objects");
                KiiUser.CurrentUser.PushSubscription.Subscribe(bucket, (KiiSubscribable subscribable, Exception e6) => {
                    Debug.Log("#####callback Subscribe");
                    if (e6 != null)
                    {
                        if (e6 is ConflictException)
                        {
                            this.message += "Bucket is already subscribed" + "\n";
                            this.message += "Push is ready";
                            Debug.Log("#####all setup success!!!!!!");
                            return;
                        }
                        Debug.Log("#####failed to Subscribe");
                        this.ShowException("Failed to subscribe bucket", e6);
                        return;
                    }
                    else
                    {
                        this.message += "Push is ready";
                        Debug.Log("#####all setup success!!!!!!");
                    }
                });
            });
        });
    }
Exemplo n.º 18
0
    void registerPush()
    {
        #if UNITY_IPHONE
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.IOS;
        #elif UNITY_ANDROID
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.ANDROID;
        #else
        KiiPushInstallation.DeviceType deviceType = KiiPushInstallation.DeviceType.ANDROID;
        #endif

        if (this.kiiPushPlugin == null)
        {
            Debug.Log("#####failed to find KiiPushPlugin");
            return;
        }
        this.kiiPushPlugin.RegisterPush((string pushToken, Exception e0) => {
            if (e0 != null)
            {
                Debug.Log("#####failed to RegisterPush");
                this.message = "#####failed to RegisterPush : " + pushToken;
                return;
            }

            Debug.Log("#####RegistrationId=" + pushToken);
            this.message = "Token : " + pushToken + "\n";
            Debug.Log("#####Install");
            KiiUser.PushInstallation(true).Install(pushToken, deviceType, (Exception e3) => {
                if (e3 != null)
                {
                    Debug.Log("#####failed to Install");
                    this.ShowException("Failed to install PushNotification -- pushToken=" + pushToken, e3);
                    return;
                }
                KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME);
                // bucket.Acl(BucketAction.CREATE_OBJECTS_IN_BUCKET).Subject(KiiAnyAuthenticatedUser.Get()).Save(ACLOperation.GRANT, (KiiACLEntry<KiiBucket, BucketAction> entry, Exception e5)=>{
                //     if (e5 != null)
                //     {
                //         Debug.Log ("#####Failed to grant acl to the bucket");
                //         this.ShowException("Failed to grant acl to the bucket", e5);
                //         return;
                //     }
                Debug.Log("#####Subscribe");
                KiiUser.CurrentUser.PushSubscription.Subscribe(bucket, (KiiSubscribable subscribable, Exception e6) => {
                    Debug.Log("#####callback Subscribe");
                    if (e6 != null)
                    {
                        if (e6 is ConflictException)
                        {
                            this.message += "Bucket is already subscribed" + "\n";
                            this.message += "Push is ready";
                            Debug.Log("#####all setup success!!!!!!");
                            return;
                        }
                        Debug.Log("#####failed to Subscribe");
                        this.ShowException("Failed to subscribe bucket", e6);
                        return;
                    }
                    else
                    {
                        this.message += "Push is ready";
                        Debug.Log("#####all setup success!!!!!!");
                    }
                });
                // });
            });
        });
    }
Exemplo n.º 19
0
    void OnGUI()
    {
        ScalableGUI gui = new ScalableGUI();

        gui.Label(5, 5, 310, 20, "Push2App scene");
        if (gui.Button(200, 5, 120, 35, "-> Push2User"))
        {
            this.kiiPushPlugin.OnPushMessageReceived -= this.receivedCallback;
            Application.LoadLevel("push2user");
        }

        this.payload = gui.TextField(0, 45, 320, 50, this.payload);
        if (gui.Button(0, 100, 160, 50, "Create Object"))
        {
            KiiBucket bucket = KiiUser.CurrentUser.Bucket(BUCKET_NAME);
            KiiObject obj    = bucket.NewKiiObject();
            obj ["payload"] = this.payload;
            obj.Save((KiiObject o, Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("Failed to save object", e);
                    return;
                }
                this.message = "#####creating object is successful!!";
            });
        }
        if (gui.Button(160, 100, 160, 50, "Clear Log"))
        {
            this.message = "--- Logs will show here ---";
        }
        if (gui.Button(0, 150, 160, 50, "Register Push"))
        {
            Invoke("registerPush", 0);
        }
        if (gui.Button(160, 150, 160, 50, "Unregister Push"))
        {
            this.kiiPushPlugin.UnregisterPush((Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("#####Unregister push is failed!!", e);
                    return;
                }
                this.message = "#####Unregister push is successful!!";
            });
        }
        if (gui.Button(0, 200, 160, 50, "Subscribe bucket"))
        {
            KiiUser             user         = KiiUser.CurrentUser;
            KiiBucket           bucket       = user.Bucket(BUCKET_NAME);
            KiiPushSubscription subscription = user.PushSubscription;
            subscription.Subscribe(bucket, (KiiSubscribable target, Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("#####Subscribe is failed!!", e);
                    return;
                }
                this.message = "#####Subscribe is successful!!";
            });
        }
        if (gui.Button(160, 200, 160, 50, "Unsubscribe bucket"))
        {
            KiiUser             user         = KiiUser.CurrentUser;
            KiiBucket           bucket       = user.Bucket(BUCKET_NAME);
            KiiPushSubscription subscription = user.PushSubscription;
            subscription.Unsubscribe(bucket, (KiiSubscribable target, Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("#####Unsubscribe is failed!!", e);
                    return;
                }
                this.message = "#####Unsubscribe is successful!!";
            });
        }
        if (gui.Button(0, 250, 160, 50, "Check subscription"))
        {
            KiiUser             user         = KiiUser.CurrentUser;
            KiiBucket           bucket       = user.Bucket(BUCKET_NAME);
            KiiPushSubscription subscription = user.PushSubscription;
            subscription.IsSubscribed(bucket, (KiiSubscribable target, bool isSubscribed, Exception e) => {
                if (e != null)
                {
                    Debug.Log("#####" + e.Message);
                    Debug.Log("#####" + e.StackTrace);
                    this.ShowException("#####Check subscription is failed!!", e);
                    return;
                }
                this.message = "#####Subscription status : " + isSubscribed;
            });
        }
        gui.TextArea(5, 310, 310, 170, this.message, 10);
    }