Пример #1
0
        public void unlockLevel(string levelName)
        {
            LevelData level = currentUser.getLevelById(levelName);

            if (level != null)
            {
                level.isDirty = level.updateLocked(false) || level.isDirty;
            }
            else
            {
                level         = new LevelData(levelName);
                level.locked  = false;
                level.world   = levelsList.getLevelByName(levelName).world;
                level.isDirty = true;

                currentUser.addLevel(level);
            }

            //Cuidamos de no sobreescribir algun valor previo
            currentUser.isDirty = currentUser.isDirty || level.isDirty;

            if (currentUser.isDirty)
            {
                saveLocalData(false);

                //mandamos un usuario solo con este nivel
                KuberaUser user = new KuberaUser(currentUserId);
                user.addLevel(level);

                syncManager.updateData(user);
            }
        }
Пример #2
0
        public void savePassedLevel(string levelName, int stars, int points)
        {
            KuberaUser currUser = currentUser;
            LevelData  level    = currUser.getLevelById(levelName);


            if (level != null)
            {
                KuberaAnalytics.GetInstance().registerFirstWinAttempts(levelName, level.attempts);
                level.updateOnlyIncrementalValues(stars, points);
                level.updatePassed(true);
                level.attempts++;
                level.isDirty = true;
            }
            else
            {
                level          = new LevelData(levelName);
                level.points   = points;
                level.stars    = stars;
                level.passed   = true;
                level.world    = levelsList.getLevelByName(levelName).world;
                level.attempts = 1;
                level.isDirty  = true;

                currUser.addLevel(level);

                KuberaAnalytics.GetInstance().registerFirstWinStars(levelName, stars);
                KuberaAnalytics.GetInstance().registerFirstWinAttempts(levelName, level.attempts);
            }

            KuberaAnalytics.GetInstance().registerLevelAttempts(levelName, level.attempts);

            //El maximo avance
            currUser.isDirty = currUser.upgradeMaxLevelReached(int.Parse(level._id)) || currUser.isDirty;

            //Es sucio porque ya estaba sucio o por un cambio aqui
            currUser.isDirty = currUser.isDirty || level.isDirty;

            if (currUser.isDirty)
            {
                saveLocalData(false);

                //Mandamos un usuario solo con este nivel
                KuberaUser user = new KuberaUser(currentUserId);
                user.addLevel(level);

                syncManager.updateData(user);
            }
        }
Пример #3
0
        public KuberaUser clone()
        {
            KuberaUser result = new KuberaUser(this._id);

            result.isDirty           = this.isDirty;
            result.version           = this.version;
            result.remoteDataVersion = this.remoteDataVersion;
            result.facebookId        = this.facebookId;
            result.maxLevelReached   = this.maxLevelReached;

            foreach (LevelData level in this.levels)
            {
                result.addLevel(level.clone());
            }

            return(result);
        }
Пример #4
0
        public void incrementLevelAttemp(string levelName)
        {
            KuberaUser currUser = currentUser;
            LevelData  level    = currUser.getLevelById(levelName);


            if (level != null)
            {
                level.attempts++;
                level.isDirty = true;
            }
            else
            {
                level          = new LevelData(levelName);
                level.points   = 0;
                level.stars    = 0;
                level.passed   = false;
                level.world    = levelsList.getLevelByName(levelName).world;
                level.attempts = 1;
                level.isDirty  = true;

                currUser.addLevel(level);
            }

            KuberaAnalytics.GetInstance().registerLevelAttempts(levelName, level.attempts);

            currUser.isDirty = true;


            if (currUser.isDirty)
            {
                saveLocalData(false);

                //Mandamos un usuario solo con este nivel
                KuberaUser user = new KuberaUser(currentUserId);
                user.addLevel(level);

                syncManager.updateData(user);
            }
        }