Пример #1
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);
            }
        }
Пример #2
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);
            }
        }