Inheritance: MonoBehaviour
Exemplo n.º 1
0
    void Start()
    {
        achieves = GameObject.Find ("Follow Camera").GetComponent<Achievements> ();

        if (GetComponent<AudioSource> ()) {
            audio2 = GetComponent<AudioSource> ();
            environmentSFX = audio2.clip;
        } else {
            Debug.LogWarning (gameObject.name + " lacks audio");
        }
    }
 /// <summary>
 /// Разблокирует ачивку, если ещё не разблокирована и сообщит о событии.
 /// </summary>
 /// <param name="achiev">Ачивка из перечисления</param>
 public void UnlockAchievement(Achievements achiev)
 {
     try
     {
         if (!registeredAchievements[achiev].register)
         {
             registeredAchievements[achiev].register = true;
             achievementUnlockedAction(this, registeredAchievements[achiev]);
         }
     }
     catch(KeyNotFoundException e)
     {
         Debug.LogError(e.Message);
     }
 }
        public static String AchievementName(Achievements a)
        {
            switch (a)
            {
                case Achievements.Victory:
                    return "Victory!";

                case Achievements.WhyWontYouDie:
                    return "Why Won't You Die?!";

                case Achievements.TheseAreCheaper:
                    return "These Are Cheaper";

                case Achievements.StayAWhile:
                    return "Stay A While";

                case Achievements.MissingThePoint:
                    return "Missing The Point";

                case Achievements.Luddite:
                    return "Luddite";

                case Achievements.GenevaConvention:
                    return "Geneva Convention";

                case Achievements.Miser:
                    return "Miser";

                case Achievements.AttackItsWeakPoint:
                    return "Attack Its Weak Point";

                default:
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 4
0
 public void AddPoints(int amount)
 {
     _score             = _score + amount < _MAXSCORE ? _score + amount : _MAXSCORE;
     Achievements.SCORE = _score;
     Achievements.AchievementCheck();
 }
Exemplo n.º 5
0
        internal Data Create(Row _Row)
        {
            Data _Data;

            switch (this.Index)
            {
            case 1:
                _Data = new Buildings(_Row, this);
                break;

            case 3:
                _Data = new Resource(_Row, this);
                break;

            case 4:
                _Data = new Characters(_Row, this);
                break;

            case 8:
                _Data = new Obstacles(_Row, this);
                break;

            case 11:
                _Data = new Experience_Levels(_Row, this);
                break;

            case 12:
                _Data = new Traps(_Row, this);
                break;

            case 14:
                _Data = new Globals(_Row, this);
                break;

            case 17:
                _Data = new Npcs(_Row, this);
                break;

            case 18:
                _Data = new Decos(_Row, this);
                break;

            case 21:
                _Data = new Missions(_Row, this);
                break;

            case 23:
                _Data = new Achievements(_Row, this);
                break;

            case 26:
                _Data = new Spells(_Row, this);
                break;

            case 28:
                _Data = new Heroes(_Row, this);
                break;

            case 29:
                _Data = new Leagues(_Row, this);
                break;

            case 37:
                _Data = new Variables(_Row, this);
                break;

            case 39:
                _Data = new Village_Objects(_Row, this);
                break;

            /*case 2:
             *  _Data = new Locales(_Row, this);
             *  break;
             * case 3:
             *  _Data = new Resources(_Row, this);
             *  break;
             * case 4:
             *  _Data = new Characters(_Row, this);
             *  break;
             * // case 5: Animation
             * case 6:
             *  _Data = new Projectiles(_Row, this);
             *  break;
             * case 7:
             *  _Data = new Building_Classes(_Row, this);
             *  break;
             * case 8:
             *  _Data = new Obstacles(_Row, this);
             *  break;
             * case 9:
             *  _Data = new Effects(_Row, this);
             *  break;
             * // case 10: Particle Emitters
             * case 11:
             *  _Data = new Experience_Levels(_Row, this);
             *  break;
             * case 12:
             *  _Data = new Traps(_Row, this);
             *  break;
             * case 13:
             *  _Data = new Alliance_Badges(_Row, this);
             *  break;
             * case 14:
             *  _Data = new Globals(_Row, this);
             *  break;
             * // case 15: TownHall Levels
             * case 16:
             *  _Data = new Alliance_Portal(_Row, this);
             *  break;
             * case 17:
             *  _Data = new Npcs(_Row, this);
             *  break;
             * case 18:
             *  _Data = new Decos(_Row, this);
             *  break;
             * // case 19: Resource Packs
             * case 20:
             *  _Data = new Shields(_Row, this);
             *  break;
             * // case 22: Billing Packages
             *
             * // case 24: Credits
             * // case 25: Faq
             * case 26:
             *  _Data = new Spells(_Row, this);
             *  break;
             * // case 27: Hints
             * case 28:
             *  _Data = new Heroes(_Row, this);
             *  break;
             * case 29:
             *  _Data = new Leagues(_Row, this);
             *  break;
             *
             * case 37:
             *  _Data = new Variables(_Row, this);
             *  break;
             */
            default:
            {
                _Data = new Data(_Row, this);
                break;
            }
            }

            return(_Data);
        }
Exemplo n.º 6
0
        public override void Init()
        {
            base.Init();

            try {
                SteamClient.Init(851150);

                LaunchedFromSteam           = true;
                SaveManager.EnableCloudSave = true;

                var lang = SteamApps.GameLanguage.ToLower();
                var ui   = SteamUtils.SteamUILanguage;

                Log.Info($"Starting from steam! <3 ({lang}, ui: {ui})");

                if (lang == "english" && ui != lang)
                {
                    lang = ui;
                    Log.Info("Preffering ui language over default");
                }

                switch (lang)
                {
                case "english": {
                    Locale.PrefferedClientLanguage = "en";
                    break;
                }

                case "russian": {
                    Locale.PrefferedClientLanguage = "ru";
                    break;
                }

                case "german": {
                    Locale.PrefferedClientLanguage = "de";
                    break;
                }

                case "italian": {
                    Locale.PrefferedClientLanguage = "it";
                    break;
                }

                case "polish": {
                    Locale.PrefferedClientLanguage = "pl";
                    break;
                }

                case "french": {
                    Locale.PrefferedClientLanguage = "fr";
                    break;
                }
                }

                Run.SubmitScore += (score, board) => {
                    if (Assets.DataModified)
                    {
                        return;
                    }

                    try {
                        new Thread(() => {
                            try {
                                Log.Info($"Submitting score {score} to board {board}");

                                var br = SteamUserStats
                                         .FindOrCreateLeaderboardAsync(board, LeaderboardSort.Descending, LeaderboardDisplay.Numeric)
                                         .GetAwaiter().GetResult();

                                br?.SubmitScoreAsync(score).GetAwaiter().GetResult();

                                Log.Info($"Done submitting the score {score}");
                            } catch (Exception e) {
                                Log.Error(e);
                            }
                        }).Start();
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                InGameState.SetupLeaderboard += (stats, boardId, type, offset, end) => {
                    try {
                        new Thread(() => {
                            try {
                                var i     = 0;
                                var count = 0;
                                var name  = SteamClient.Name;

                                var board = SteamUserStats
                                            .FindOrCreateLeaderboardAsync(boardId, LeaderboardSort.Descending, LeaderboardDisplay.Numeric)
                                            .GetAwaiter().GetResult().Value;

                                LeaderboardEntry[] scores;

                                if (type == "global")
                                {
                                    scores = board.GetScoresAsync(10, Math.Max(1, offset)).GetAwaiter().GetResult();
                                }
                                else if (type == "friends")
                                {
                                    scores = board.GetScoresFromFriendsAsync().GetAwaiter().GetResult();
                                    i      = Math.Max(0, offset);
                                }
                                else
                                {
                                    scores = board.GetScoresAroundUserAsync(-5 + offset, 5 + offset).GetAwaiter().GetResult();
                                }

                                if (scores != null)
                                {
                                    for (; i < scores.Length && count < 10; i++)
                                    {
                                        var score = scores[i];

                                        var n = score.User.Name;
                                        n     = n.Substring(0, Math.Min(n.Length, 18));

                                        stats.Add($"#{score.GlobalRank} {n}", score.Score.ToString(), score.User.Name == name);

                                        count++;
                                    }
                                }
                                else
                                {
                                    stats.Add(Locale.Get("no_scores_yet"), ":(");
                                }

                                end();
                            } catch (Exception e) {
                                Log.Error(e);
                            }
                        }).Start();
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                Achievements.PostLoadCallback += () => {
                    try {
                        foreach (var achievement in Achievements.Defined)
                        {
                            if (achievement.Value.Unlocked)
                            {
                                new Achievement(achievement.Key).Trigger();
                            }
                        }

                        foreach (var achievement in SteamUserStats.Achievements)
                        {
                            if (achievement.State)
                            {
                                Achievements.Unlock(achievement.Identifier);
                            }
                        }
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                Achievements.UnlockedCallback += (id) => {
                    try {
                        new Achievement(id).Trigger();
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                Achievements.LockedCallback += (id) => {
                    try {
                        new Achievement(id).Clear();
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                Achievements.ProgressSetCallback += (id, progress, max) => {
                    try {
                        SteamUserStats.IndicateAchievementProgress(id, progress, max);
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                InGameState.SyncAchievements += () => {
                    try {
                        foreach (var achievement in Achievements.Defined)
                        {
                            if (achievement.Value.Unlocked)
                            {
                                new Achievement(achievement.Key).Trigger();
                            }
                        }

                        foreach (var achievement in SteamUserStats.Achievements)
                        {
                            if (achievement.State)
                            {
                                Achievements.Unlock(achievement.Identifier);
                            }
                        }
                    } catch (Exception e) {
                        Log.Error(e);
                    }
                };

                try {
                    SaveManager.LoadCloudSaves();
                } catch (Exception e) {
                    Log.Error(e);
                }

                SteamFriends.OnGameOverlayActivated += () => {
                    Engine.Instance.State.Paused = true;
                };
            } catch (Exception e) {
                Log.Error(e);
                Log.Info("No steam no fire :/");
            }
        }
Exemplo n.º 7
0
 public Achievement(Achievements achievements, IntPtr stats, string achievementName, bool isAchieved)
 {
   this._stats = stats;
   this._achievements = achievements;
   this._achievementName = achievementName;
   this._isAchieved = isAchieved;
 }
Exemplo n.º 8
0
 public IAchievement AchievementOf(string id)
 {
     return(Achievements.FirstOrDefault(achievement => achievement.id == id));
 }
Exemplo n.º 9
0
 public void ResetProgress()
 {
     Achievements.Clear();
     Levels.ResetProgress();
     Levels.LoadMenu();
 }
        /// <summary>
        /// Get all achievements for a Steam game.
        /// </summary>
        /// <param name="PlayniteApi"></param>
        /// <param name="Id"></param>
        /// <param name="PluginUserDataPath"></param>
        /// <returns></returns>
        public GameAchievements GetAchievements(IPlayniteAPI PlayniteApi, Guid Id, string PluginUserDataPath, bool isLocal = false)
        {
            List <Achievements> Achievements = new List <Achievements>();
            string GameName        = PlayniteApi.Database.Games.Get(Id).Name;
            string ClientId        = PlayniteApi.Database.Games.Get(Id).GameId;
            bool   HaveAchivements = false;
            int    Total           = 0;
            int    Unlocked        = 0;
            int    Locked          = 0;

            GameAchievements Result = new GameAchievements
            {
                Name            = GameName,
                HaveAchivements = HaveAchivements,
                Total           = Total,
                Unlocked        = Unlocked,
                Locked          = Locked,
                Progression     = 0,
                Achievements    = Achievements
            };

            var    url       = "";
            string ResultWeb = "";

            // Get Steam configuration if exist.
            string userId    = "";
            string apiKey    = "";
            string SteamUser = "";

            try
            {
                JObject SteamConfig = JObject.Parse(File.ReadAllText(PluginUserDataPath + "\\..\\CB91DFC9-B977-43BF-8E70-55F46E410FAB\\config.json"));
                userId    = (string)SteamConfig["UserId"];
                apiKey    = (string)SteamConfig["ApiKey"];
                SteamUser = (string)SteamConfig["UserName"];
            }
            catch
            {
            }

            if (userId == "" || apiKey == "" || SteamUser == "")
            {
                logger.Error($"SuccessStory - No Steam configuration.");
                AchievementsDatabase.ListErrors.Add($"Error on SteamAchievements: no Steam configuration and/or API key in settings menu for Steam Library.");
                return(null);
            }

            if (!isLocal)
            {
                string lang = CodeLang.GetSteamLang(Localization.GetPlayniteLanguageConfiguration(PlayniteApi.Paths.ConfigurationPath));

                // List acheviements (default return in english)
                url = string.Format(@"https://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v0001/?appid={0}&key={1}&steamid={2}&l={3}",
                                    ClientId, apiKey, userId, lang);

                ResultWeb = "";
                try
                {
                    ResultWeb = HttpDownloader.DownloadString(url, Encoding.UTF8);
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                    {
                        var resp = (HttpWebResponse)ex.Response;
                        switch (resp.StatusCode)
                        {
                        case HttpStatusCode.BadRequest:     // HTTP 400
                            break;

                        case HttpStatusCode.ServiceUnavailable:     // HTTP 503
                            break;

                        default:
                            Common.LogError(ex, "SuccessStory", $"Failed to load from {url}. ");
                            break;
                        }
                        return(Result);
                    }
                }

                if (ResultWeb != "")
                {
                    JObject resultObj   = new JObject();
                    JArray  resultItems = new JArray();

                    try
                    {
                        resultObj = JObject.Parse(ResultWeb);

                        if ((bool)resultObj["playerstats"]["success"])
                        {
                            resultItems = (JArray)resultObj["playerstats"]["achievements"];
                            if (resultItems.Count > 0)
                            {
                                HaveAchivements = true;

                                for (int i = 0; i < resultItems.Count; i++)
                                {
                                    Achievements temp = new Achievements
                                    {
                                        Name         = (string)resultItems[i]["name"],
                                        ApiName      = (string)resultItems[i]["apiname"],
                                        Description  = (string)resultItems[i]["description"],
                                        UrlUnlocked  = "",
                                        UrlLocked    = "",
                                        DateUnlocked = ((int)resultItems[i]["unlocktime"] == 0) ? default(DateTime) : new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)resultItems[i]["unlocktime"])
                                    };

                                    // Achievement without unlocktime but achieved = 1
                                    if ((int)resultItems[i]["achieved"] == 1 && temp.DateUnlocked == new DateTime(1970, 1, 1, 0, 0, 0, 0))
                                    {
                                        temp.DateUnlocked = new DateTime(1982, 12, 15, 0, 0, 0, 0);
                                    }

                                    Total += 1;
                                    if ((int)resultItems[i]["unlocktime"] == 0)
                                    {
                                        Locked += 1;
                                    }
                                    else
                                    {
                                        Unlocked += 1;
                                    }

                                    Achievements.Add(temp);
                                }
                            }
                            else
                            {
                                logger.Info($"SuccessStory - No list achievement for {ClientId}. ");
                                return(Result);
                            }
                        }
                        else
                        {
                            logger.Info($"SuccessStory - No Succes for {ClientId}. ");
                            return(Result);
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogError(ex, "SuccessStory", $"[{ClientId}] Failed to parse {ResultWeb}");
                        return(Result);
                    }


                    // List details acheviements
                    url = string.Format(@"https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/?key={0}&appid={1}&l={2}",
                                        apiKey, ClientId, lang);

                    ResultWeb = "";
                    try
                    {
                        ResultWeb = HttpDownloader.DownloadString(url, Encoding.UTF8);
                    }
                    catch (WebException ex)
                    {
                        if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                        {
                            var resp = (HttpWebResponse)ex.Response;
                            switch (resp.StatusCode)
                            {
                            case HttpStatusCode.BadRequest:     // HTTP 400
                                break;

                            case HttpStatusCode.ServiceUnavailable:     // HTTP 503
                                break;

                            default:
                                Common.LogError(ex, "SuccessStory", $"Failed to load from {url}");
                                break;
                            }
                            return(Result);
                        }
                    }

                    if (ResultWeb != "")
                    {
                        resultObj = JObject.Parse(ResultWeb);

                        try
                        {
                            resultItems = (JArray)resultObj["game"]["availableGameStats"]["achievements"];

                            for (int i = 0; i < resultItems.Count; i++)
                            {
                                for (int j = 0; j < Achievements.Count; j++)
                                {
                                    if (Achievements[j].ApiName.ToLower() == ((string)resultItems[i]["name"]).ToLower())
                                    {
                                        Achievements temp = new Achievements
                                        {
                                            Name         = (string)resultItems[i]["displayName"],
                                            ApiName      = Achievements[j].ApiName,
                                            Description  = Achievements[j].Description,
                                            UrlUnlocked  = (string)resultItems[i]["icon"],
                                            UrlLocked    = (string)resultItems[i]["icongray"],
                                            DateUnlocked = Achievements[j].DateUnlocked
                                        };

                                        if ((int)resultItems[i]["hidden"] == 1)
                                        {
                                            temp.Description = FindHiddenDescription(SteamUser, userId, ClientId, temp.Name, lang);
                                        }

                                        Achievements[j] = temp;
                                        j = Achievements.Count;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Common.LogError(ex, "SuccessStory", $"Failed to parse");
                            return(Result);
                        }
                    }
                }

                //logger.Info($"SuccessStory - No data for {ClientId}. ");

                Result = new GameAchievements
                {
                    Name            = GameName,
                    HaveAchivements = HaveAchivements,
                    Total           = Total,
                    Unlocked        = Unlocked,
                    Locked          = Locked,
                    Progression     = (Total != 0) ? (int)Math.Ceiling((double)(Unlocked * 100 / Total)) : 0,
                    Achievements    = Achievements
                };
            }
            else
            {
                SteamEmulators se = new SteamEmulators(PlayniteApi, PluginUserDataPath);
                ClientId = se.GetSteamId().ToString();

                var temp = se.GetAchievementsLocal(GameName, apiKey);

                if (temp.Achievements.Count > 0)
                {
                    Result.HaveAchivements = true;
                    Result.Total           = temp.Total;
                    Result.Locked          = temp.Locked;
                    Result.Unlocked        = temp.Unlocked;
                    Result.Progression     = temp.Progression;

                    for (int i = 0; i < temp.Achievements.Count; i++)
                    {
                        Result.Achievements.Add(new Achievements
                        {
                            Name         = temp.Achievements[i].Name,
                            Description  = temp.Achievements[i].Description,
                            UrlUnlocked  = temp.Achievements[i].UrlUnlocked,
                            UrlLocked    = temp.Achievements[i].UrlLocked,
                            DateUnlocked = temp.Achievements[i].DateUnlocked
                        });
                    }
                }
            }

            // Percentages
            url = string.Format(@"http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid={0}&format=json",
                                ClientId);
            ResultWeb = "";
            try
            {
                ResultWeb = HttpDownloader.DownloadString(url, Encoding.UTF8);
            }
            catch (WebException ex)
            {
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                {
                    var resp = (HttpWebResponse)ex.Response;
                    switch (resp.StatusCode)
                    {
                    case HttpStatusCode.BadRequest:     // HTTP 400
                        break;

                    case HttpStatusCode.ServiceUnavailable:     // HTTP 503
                        break;

                    default:
                        Common.LogError(ex, "SuccessStory", $"Failed to load from {url}. ");
                        break;
                    }
                    return(Result);
                }
            }

            if (ResultWeb != "")
            {
                JObject resultObj   = new JObject();
                JArray  resultItems = new JArray();

                try
                {
                    resultObj = JObject.Parse(ResultWeb);

                    if (resultObj["achievementpercentages"]["achievements"] != null)
                    {
                        foreach (JObject data in resultObj["achievementpercentages"]["achievements"])
                        {
                            for (int i = 0; i < Result.Achievements.Count; i++)
                            {
                                if (Result.Achievements[i].ApiName == (string)data["name"])
                                {
                                    Result.Achievements[i].Percent = (float)data["percent"];
                                    i = Result.Achievements.Count;
                                }
                            }
                        }
                    }
                    else
                    {
                        logger.Info($"SuccessStory - No percentages for {ClientId}. ");
                        return(Result);
                    }
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "SuccessStory", $"[{ClientId}] Failed to parse {ResultWeb}");
                    return(Result);
                }
            }


            return(Result);
        }
Exemplo n.º 11
0
 void Start()
 {
     achieves = GameObject.Find ("Follow Camera").GetComponent<Achievements> ();
 }
Exemplo n.º 12
0
 public Sportsman(string name, string surName, int weight, int height, int age, double experience, string diet, string injury, int numberOfWins, Achievements achievement)
     : base(name, surName, weight, height, age)
 {
     Experience   = experience;
     Diet         = diet;
     Injury       = injury;
     NumberOfWins = numberOfWins;
     Achievement  = achievement;
 }
Exemplo n.º 13
0
 private void Achievements_Load(object sender, EventArgs e)
 {
     IEnumerable <string> allAchievements = Achievements.ReadAchievements();
     //Do stuff with the achievements
 }
Exemplo n.º 14
0
 private void removeAchievement_Click(object sender, EventArgs e)
 {
     Achievements.RemoveSelected();
 }
Exemplo n.º 15
0
 private void editAchievement_Click(object sender, EventArgs e)
 {
     using (AchievementWindow window = new AchievementWindow(AchievementWindow.Operation.Edit, Achievements.GetSelectedRow()))
     {
         var result = window.ShowDialog();
         if (result == DialogResult.OK)
         {
             string row = window.Value;
             Achievements.EditSelectedRow(row);
         }
     }
 }
Exemplo n.º 16
0
 public bool HasAchieved(Achievements ach)
 {
     return achieved[ach];
 }
        /// <summary>
        /// Get all achievements for a GOG game.
        /// </summary>
        /// <param name="PlayniteApi"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public override GameAchievements GetAchievements(Game game)
        {
            List <Achievements> Achievements = new List <Achievements>();
            string GameName        = game.Name;
            string ClientId        = game.GameId;
            bool   HaveAchivements = false;
            int    Total           = 0;
            int    Unlocked        = 0;
            int    Locked          = 0;

            GameAchievements Result = new GameAchievements
            {
                Name            = GameName,
                HaveAchivements = HaveAchivements,
                Total           = Total,
                Unlocked        = Unlocked,
                Locked          = Locked,
                Progression     = 0,
                Achievements    = Achievements
            };

            string ResultWeb = string.Empty;

            // Only if user is logged.
            if (gogAPI.GetIsUserLoggedIn())
            {
                string accessToken = gogAPI.GetAccountInfo().accessToken;

                string userId = gogAPI.GetAccountInfo().userId;
                string lang   = CodeLang.GetGogLang(_PlayniteApi.ApplicationSettings.Language);

                // Achievements
                string url = string.Format(@"https://gameplay.gog.com/clients/{0}/users/{1}/achievements", ClientId, userId);

                try
                {
                    string urlLang = string.Format(@"https://www.gog.com/user/changeLanguage/{0}", lang.ToLower());
                    ResultWeb = DonwloadStringData(urlLang, url, accessToken).GetAwaiter().GetResult();
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null)
                    {
                        var resp = (HttpWebResponse)ex.Response;
                        switch (resp.StatusCode)
                        {
                        case HttpStatusCode.ServiceUnavailable:     // HTTP 503
                            Common.LogError(ex, "SuccessStory", $"HTTP 503 to load from {url}");
                            break;

                        default:
                            Common.LogError(ex, "SuccessStory", $"Failed to load from {url}");
                            break;
                        }
                    }
                    return(Result);
                }

                // Parse data
                if (ResultWeb != string.Empty)
                {
                    JObject resultObj = JObject.Parse(ResultWeb);
                    try
                    {
                        JArray resultItems = (JArray)resultObj["items"];
                        if (resultItems.Count > 0)
                        {
                            HaveAchivements = true;

                            for (int i = 0; i < resultItems.Count; i++)
                            {
                                Achievements temp = new Achievements
                                {
                                    ApiName      = (string)resultItems[i]["achievement_key"],
                                    Name         = (string)resultItems[i]["name"],
                                    Description  = (string)resultItems[i]["description"],
                                    UrlUnlocked  = (string)resultItems[i]["image_url_unlocked"],
                                    UrlLocked    = (string)resultItems[i]["image_url_locked"],
                                    DateUnlocked = ((string)resultItems[i]["date_unlocked"] == null) ? default(DateTime) : (DateTime)resultItems[i]["date_unlocked"],
                                    Percent      = (float)resultItems[i]["rarity"]
                                };

                                Total += 1;
                                if ((string)resultItems[i]["date_unlocked"] == null)
                                {
                                    Locked += 1;
                                }
                                else
                                {
                                    Unlocked += 1;
                                }

                                Achievements.Add(temp);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Common.LogError(ex, "SuccessStory", $"Failed to parse");
                        return(Result);
                    }
                }
            }
            else
            {
                _PlayniteApi.Notifications.Add(new NotificationMessage(
                                                   "SuccessStory-Gog-NoAuthenticate",
                                                   $"SuccessStory\r\n{resources.GetString("LOCSuccessStoryNotificationsGogNoAuthenticate")}",
                                                   NotificationType.Error
                                                   ));
                logger.Warn("SuccessStory - GOG user is not Authenticate");
            }

            Result = new GameAchievements
            {
                Name            = GameName,
                HaveAchivements = HaveAchivements,
                Total           = Total,
                Unlocked        = Unlocked,
                Locked          = Locked,
                Progression     = (Total != 0) ? (int)Math.Ceiling((double)(Unlocked * 100 / Total)) : 0,
                Achievements    = Achievements
            };

            return(Result);
        }
Exemplo n.º 18
0
 public override void PlaceRewards()
 {
     base.PlaceRewards();
     Achievements.Unlock("bk:democracy");
 }
Exemplo n.º 19
0
        public static void InitialiseWorld(string assetPath)
        {
            Initialise(assetPath);

            var sw = new Stopwatch();

            sw.Start();

            Achievements        = LoadSheet <Achievement>();
            ClassJobs           = LoadSheet <ClassJob>();
            EquipSlotCategories = LoadSheet <EquipSlotCategory>();
            Items            = LoadSheet <Item>();
            ItemUiCategories = LoadSheet <ItemUICategory>();
            Quests           = LoadSheet <Quest>();
            OpeningEvents    = realm.GameData.GetSheet("Opening");
            PlaceNames       = LoadSheet <PlaceName>();
            Races            = LoadSheet <Race>();
            TerritoryTypes   = LoadSheet <TerritoryType>();

            AchievementXCriteriaType = new ReadOnlyDictionary <byte, ReadOnlyCollection <Achievement> >(Achievements
                                                                                                        .GroupBy(e => e.Type)
                                                                                                        .OrderBy(g => g.Key)
                                                                                                        .ToDictionary(o => o.Key, o => new ReadOnlyCollection <Achievement>(o.ToList())));

            AchievementXCriteriaCounterType = new ReadOnlyDictionary <ushort, ReadOnlyCollection <Achievement> >(Achievements
                                                                                                                 .Where(e => e.Type == 1)
                                                                                                                 .GroupBy(w => w.Data[0])
                                                                                                                 .OrderBy(g => g.Key)
                                                                                                                 .ToDictionary(o => (ushort)o.Key, o => new ReadOnlyCollection <Achievement>(o.ToList())));

            Console.WriteLine($"Initialised GameTables in {sw.ElapsedMilliseconds}ms.");
        }
 private static Achievement GetAchievement(int id)
 {
     return(Achievements.FirstOrDefault(data => data.Id == id));
 }
Exemplo n.º 21
0
 public override void Update(GameTime gameTime)
 {
   this.sinceChecked += gameTime.ElapsedGameTime;
   if (this.sinceChecked < TrialAndAwards.CheckFrequency)
     return;
   this.sinceChecked = TimeSpan.Zero;
   bool flag = PauseMenu.Instance != null && PauseMenu.Instance.EndGameMenu;
   if (this.GameState.Paused && !flag || this.GameState.InCutscene && !flag || this.GameState.Loading)
     return;
   if (this.Achievements == null)
   {
     CommunityExpress.Instance.UserAchievements.InitializeAchievementList((IEnumerable<string>) new string[12]
     {
       "Achievement_01",
       "Achievement_02",
       "Achievement_03",
       "Achievement_04",
       "Achievement_05",
       "Achievement_06",
       "Achievement_07",
       "Achievement_08",
       "Achievement_09",
       "Achievement_10",
       "Achievement_11",
       "Achievement_12"
     });
     this.Achievements = CommunityExpress.Instance.UserAchievements;
   }
   foreach (Achievement achievement in this.Achievements)
   {
     if (!achievement.IsAchieved && this.CheckAchievement(achievement.AchievementName))
     {
       if (!this.GameState.SaveData.EarnedAchievements.Contains(achievement.AchievementName))
         this.GameState.SaveData.EarnedAchievements.Add(achievement.AchievementName);
       this.GameState.AwardAchievement(achievement);
     }
   }
 }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (Utils.User.IsCurrentUserModerator())
            {
                ModeratorCount = ModeratorStats.GetComplaintsCount() + ModeratorStats.GetUnapprovedMsgsCount();
            }

            bool integratedAuthEnabled = Utils.Settings.IntegratedAuthentication;

            if (Utils.User.CurrentUserID == 0)             //not logged in
            {
                //if (registerLink != null) registerLink.Visible = !integratedAuthEnabled;
                if (logoutLink != null)
                {
                    logoutLink.Visible = false;
                }
                if (viewProfileLink != null)
                {
                    viewProfileLink.Visible = false;
                }
                if (loginTable != null)
                {
                    loginTable.Visible = !integratedAuthEnabled && ShowLoginTable;
                }
                if (curuserTable != null)
                {
                    curuserTable.Visible = false;
                }
                if (usersLink != null)
                {
                    usersLink.Visible = false;
                }
                if (aOpenId != null)
                {
                    aOpenId.Visible = Utils.Settings.EnableOpenId;
                }
                if (aTwitter != null)
                {
                    aTwitter.Visible = !string.IsNullOrEmpty(Utils.Settings.TwitterConsumerKey) && !string.IsNullOrEmpty(Utils.Settings.TwitterConsumerSecret);
                }
                if (aFacebook != null)
                {
                    aFacebook.Visible = !string.IsNullOrEmpty(Utils.Settings.FacebookAppID) && !string.IsNullOrEmpty(Utils.Settings.FacebookAppSecret);
                }
            }
            else             //logged in
            {
                //if (registerLink != null) registerLink.Visible = false;
                if (logoutLink != null)
                {
                    logoutLink.Visible = !integratedAuthEnabled;
                }
                if (loginTable != null)
                {
                    loginTable.Visible = false;
                }
                if (curuserTable != null)
                {
                    curuserTable.Visible = ShowLoginTable;
                }
                if (usersLink != null)
                {
                    usersLink.Visible = true;
                }
                //if (editProfileHeaderLink != null) editProfileHeaderLink.Visible = true;

                if (viewProfileLink != null)
                {
                    viewProfileLink.Visible = true;
                    string username;
                    //IF "integrated auth" is enabled
                    //AND it is windows-authenctication
                    //then lets remove tha domain name from "domain\user" username
                    if (Page.User is System.Security.Principal.WindowsPrincipal &&
                        Utils.Settings.IntegratedAuthentication)
                    {
                        username = Session["aspnetforumUserName"].ToString();
                        username = username.Substring(username.IndexOf("\\") + 1);
                    }
                    else
                    {
                        username = Session["aspnetforumUserName"].ToString();
                    }
                    viewProfileLink.InnerHtml = username;
                    viewProfileLink.HRef      = "viewprofile.aspx?UserID=" + Utils.User.CurrentUserID.ToString();
                }

                cn.Open();
                int    unreadPrivateMsgs = GetUnreadPersonalMessagesCount();
                string avatarPath        = Utils.User.GetCurrUserAvatarImagePath(cn);
                cn.Close();

                if (imgAvatar != null)
                {
                    imgAvatar.Src = avatarPath;
                }
                if (spanNumMsgs != null)
                {
                    spanNumMsgs.InnerHtml = unreadPrivateMsgs.ToString();
                    if (unreadPrivateMsgs > 0)
                    {
                        spanNumMsgs.Style["font-weight"] = "bold";
                    }
                }
                if (spanNumUnreadThreads != null)
                {
                    spanNumUnreadThreads.InnerHtml = GetUpdatedThreadCount().ToString();
                }
            }

            adminLink.Visible = Utils.User.IsAdministrator(Utils.User.CurrentUserID) && adminLink != null;

            if (!Utils.Settings.DisableAchievements)
            {
                Achievements.RegisterNewAchievements(Page);
            }
        }
Exemplo n.º 23
0
 public void ChangeAchievementToShow(Achievements achievement)
 {
     ListOf.Revision.Add();
     achievementToShow = achievement;
 }
Exemplo n.º 24
0
        public Data Create(Row row)
        {
            Data data;

            switch (Index)
            {
            case 1:
            {
                data = new Achievements(row, this);
                break;
            }

            case 2:
            {
                data = new Alliance_badges(row, this);
                break;
            }

            case 3:
            {
                data = new Alliance_portal(row, this);
                break;
            }

            case 4:
            {
                data = new Billing_packages(row, this);
                break;
            }

            case 5:
            {
                data = new Building_classes(row, this);
                break;
            }

            case 6:
            {
                data = new Buildings(row, this);
                break;
            }

            case 7:
            {
                data = new Characters(row, this);
                break;
            }

            case 8:
            {
                data = new Decos(row, this);
                break;
            }

            case 9:
            {
                data = new Effects(row, this);
                break;
            }

            case 10:
            {
                data = new Experience_levels(row, this);
                break;
            }

            case 11:
            {
                data = new Faq(row, this);
                break;
            }

            case 12:
            {
                data = new Globals(row, this);
                break;
            }

            case 13:
            {
                data = new Heroes(row, this);
                break;
            }

            case 14:
            {
                data = new Hints(row, this);
                break;
            }

            case 15:
            {
                data = new Leagues(row, this);
                break;
            }

            case 16:
            {
                data = new Locales(row, this);
                break;
            }

            case 17:
            {
                data = new Missions(row, this);
                break;
            }

            case 18:
            {
                data = new News(row, this);
                break;
            }

            case 19:
            {
                data = new Npcs(row, this);
                break;
            }

            case 20:
            {
                data = new Obstacles(row, this);
                break;
            }

            case 21:
            {
                data = new Particle_emitters(row, this);
                break;
            }

            case 22:
            {
                data = new Projectiles(row, this);
                break;
            }

            case 23:
            {
                data = new Resource_packs(row, this);
                break;
            }

            case 24:
            {
                data = new Logic.Resources(row, this);
                break;
            }

            case 25:
            {
                data = new Shields(row, this);
                break;
            }

            case 26:
            {
                data = new Spells(row, this);
                break;
            }

            case 27:
            {
                data = new Texts(row, this);
                break;
            }

            case 28:
            {
                data = new Traps(row, this);
                break;
            }

            default:
            {
                data = new Data(row, this);
                break;
            }
            }

            return(data);
        }
Exemplo n.º 25
0
        public async void GetXml()
        {
            if (NetworkCheck.IsInternet())
            {
                Uri                 geturi      = new Uri("http://demo.msensis.com/paokbc/lineup.xml");
                HttpClient          client      = new HttpClient(new NativeMessageHandler());
                HttpResponseMessage responseGet = await client.GetAsync(geturi);

                string response = await responseGet.Content.ReadAsStringAsync();

                List <Athlete> AthleteList = new List <Athlete>();
                XDocument      doc         = XDocument.Parse(response);
                foreach (var item in doc.Descendants("athlete"))
                {
                    Achievements a = new Achievements()
                    {
                        Achievement = "N/A"
                    };

                    Athlete itemAthl = new Athlete(a);

                    itemAthl.Label       = item.Element("label").Value.ToString();
                    itemAthl.Number      = item.Element("number").Value.ToString().Trim();
                    itemAthl.FullName    = item.Element("fullname").Value.ToString().Trim();
                    itemAthl.Nationality = item.Element("nationality").Value.ToString().Trim();
                    itemAthl.Position    = item.Element("position").Value.ToString().Trim();
                    itemAthl.Height      = item.Element("height").Value.ToString().Trim();
                    itemAthl.Birthday    = item.Element("birthday").Value.ToString().Trim();
                    itemAthl.ImgUrl      = item.Element("img_url").Value.ToString().Trim();

                    //Debug.WriteLine("-----------------------------------");
                    try
                    {
                        var html = new HtmlDocument();
                        html.LoadHtml(item.Element("achievements").Value.ToString());
                        var    ps     = html.DocumentNode.Descendants("p");
                        string noHTML = "";
                        foreach (var p in ps)
                        {
                            var textContent = p.InnerText;
                            noHTML = noHTML + " " + Regex.Replace(textContent, @"<[^>]+>|&nbsp;", "").Trim().ToString();
                        }

                        //Debug.WriteLine(noHTML);
                        itemAthl.AthlAchievements.Achievement = noHTML;
                        //Debug.WriteLine(itemAthl.AthlAchievements.Achievement);
                    }
                    catch
                    {
                        itemAthl.AthlAchievements.Achievement = "N/A";
                        //Debug.WriteLine(itemAthl.AthlAchievements.Achievement);
                    }

                    AthleteList.Add(itemAthl);
                }

                /*Debug.WriteLine("--------------------------");
                 * foreach (var athlete in AthleteList)
                 * {
                 *
                 *  Debug.WriteLine(athlete.AthlAchievements.Achievement);
                 * }*/

                listviewAthletes.ItemsSource = AthleteList;
            }
            else
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await DisplayAlert("XmlParsing!", "No network is available.", "Ok");
                });
            }

            ProgressLoader.IsRunning = false;
        }
Exemplo n.º 26
0
    void Start()
    {
        achievement_skript = gameObject.GetComponent<Achievements> ();
        if(GameObject.Find("repeator") == null) {
            repeator = new GameObject();
            repeator.name = "repeator";
            DontDestroyOnLoad(repeator);
            repeator.AddComponent<repeatController>();
        }
        if(GameObject.Find("repeator") != null)
            repeator = GameObject.Find("repeator");
        if(repeator.GetComponent<repeatController>().new_round)
            gameObject.GetComponent<StartGame>().Run(false);

        // Get prefab of spawning circle (image + text)
        gameObjectCircles = Resources.Load("Prefabs/Circle", typeof(GameObject)) as GameObject;

        // determin values with threshold for tablet and phone
        if ((Screen.height / Screen.dpi) < 3.1f) {
            // it's a phone
            // FullHD Displays
            if (Screen.width >= 1920 && Screen.height >= 1080) {
                // set collider size of circle (radius)!!!
                this.start_circle_size = 60;
                // update text size of circle
                this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMinSize = 14;
                this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMaxSize = 50;
            } else {
                // All other Displays
                // set collider size of circle (radius)!!!
                this.start_circle_size = 55;
                // update text size of circle
                this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMinSize = 14;
                this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMaxSize = 45;
            }
        } else {
            // it's a tablet
            // set collider size of circle (radius)!!!
            this.start_circle_size = 50;
            // update text size of circle
            this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMinSize = 14;
            this.gameObjectCircles.transform.FindChild("Text").GetComponent<Text>().resizeTextMaxSize = 40;
        }

        this.max_circle_size = 2 * this.start_circle_size;

        // set image size of circle!!!
        gameObjectCircles.GetComponent<RectTransform> ().sizeDelta = new Vector2 (max_circle_size, max_circle_size);

        // init params
        framecount = 0;
        circlecount = 1;
        spawn_speed = 70;
        next_spawn = 70;
        // get circle count for unlocking achievements
        circlecount_achievements = PlayerPrefs.GetInt ("Circlecount");
    }
Exemplo n.º 27
0
 void ReportThisAchievement(Achievements a)
 {
     //		print("report " + a.name.ToString());
     for (int i = 0; i < 3; i++)
     {
         if (!a.got[i] && Difficulty.setting == i)
         {
             a.got[i] = true;
             a.trophy[i].enabled = true;
             achievementID = a.name.Replace("'", "");
             PlayerPrefs.SetInt(a.name + i, 1);
             achievementID = achievementID.Replace(" ", "") + i;
             print("achievementID: " + achievementID);
             AchievementControl.instance.Achievement(achievementID);
         }
     }
 }
Exemplo n.º 28
0
        private void GetUserData()
        {
            Task.Run(async() =>
            {
                User = await ServiceBus.UserService.GetUserByServerId(UserId);

                var userCvs  = await ServiceBus.UserService.GetUserCvsByServerId(UserId);
                var userInfo = await ServiceBus.UserService.GetUserInfoById(User.UserId);

                Position = userInfo?.Department ?? "?";

                InvokeOnMainThread(() => { UserTechnologyCategoryViewModels.Clear(); });

                var technologyCategoryIds = new Dictionary <string, UserTechnologyCategoryViewModel>();
                foreach (var technologyCvs in userCvs.UserCv.Technologies)
                {
                    if (!technologyCategoryIds.ContainsKey(technologyCvs.Category.Id))
                    {
                        var userTechnologyCategoryViewModel = new UserTechnologyCategoryViewModel
                        {
                            Name = technologyCvs.Category.Name
                        };
                        technologyCategoryIds.Add(technologyCvs.Category.Id, userTechnologyCategoryViewModel);

                        // TODO: Currently replaced with awful approach below
                        InvokeOnMainThread(
                            () => { CategoryViewModels.Add(userTechnologyCategoryViewModel); });
                    }

                    InvokeOnMainThread(() =>
                    {
                        technologyCategoryIds[technologyCvs.Category.Id].UserTechnologyViewModels.Add(
                            new UserTechnologyViewModel(technologyCvs.Name, technologyCvs.Stars));
                    });
                }

                // TODO: Awful approach suggested due to Nested ListViews are poorly supported.
                // TODO: Anyway, UserTechnologyCategoryViewModel has propriate collection of user technologies to create nested binding in future.
                foreach (var userTechnologyCategoryViewModel in technologyCategoryIds.OrderBy(t => t.Value.Name))
                {
                    InvokeOnMainThread(
                        () =>
                    {
                        UserTechnologyCategoryViewModels.Add(userTechnologyCategoryViewModel.Value);
                        foreach (
                            var userTechnologyViewModel in userTechnologyCategoryViewModel
                            .Value
                            .UserTechnologyViewModels
                            .OrderByDescending(i => i.Stars))
                        {
                            UserTechnologyCategoryViewModels.Add(userTechnologyViewModel);
                        }
                    });
                }

                RaisePropertyChanged(() => TechnologiesVisibility);

                foreach (var achievementId in _user.Pdp.AchievementsIds)
                {
                    var achievement       = await ServiceBus.UserService.GetAchievementsById(achievementId);
                    var userAchievementVm = new UserAchievementViewModel
                    {
                        Name     = achievement.Name,
                        Category = achievement.Category.Name,
                        ImageUri = Constants.BaseUrl + achievement.ImageUri
                    };
                    InvokeOnMainThread(() => { Achievements.Add(userAchievementVm); });
                }

                RaisePropertyChanged(() => AchievementsVisibility);

                foreach (var certificationId in _user.Pdp.CertificationsIds)
                {
                    var certification       = await ServiceBus.UserService.GetCertificateByIdAsync(certificationId);
                    var userCertificationVm = new UserCertificationViewModel
                    {
                        Name     = certification.Name,
                        Category = certification.Category.Name,
                        ImageUri = Constants.BaseUrl + certification.ImageUri
                    };
                    InvokeOnMainThread(() => { Certifications.Add(userCertificationVm); });
                }

                RaisePropertyChanged(() => CertificationsVisibility);
            });
        }
Exemplo n.º 29
0
 public void RemovePoints(int amount)
 {
     _score             = _score - amount > 0 ? _score - amount : 0;
     Achievements.SCORE = _score;
     Achievements.AchievementCheck();
 }
 /// <summary>
 /// Inserts the achievement on submit.
 /// </summary>
 /// <param name="achievement">The achievement.</param>
 public void InsertOnSubmit(Achievement achievement)
 {
     Achievements.InsertOnSubmit(achievement);
 }
Exemplo n.º 31
0
        public static String Conditions(Achievements a)
        {
            switch (a)
            {
                case Achievements.AttackItsWeakPoint:
                    return "Deal 250 poison damage to a single armored enemy.";

                case Achievements.Miser:
                    return "Save up $5000.";

                case Achievements.GenevaConvention:
                    return "Win the game without using poison or spikes.";

                case Achievements.Luddite:
                    return "Win the game without using any upgrades.";

                case Achievements.MissingThePoint:
                    return "Die without using any terrain modification.";

                case Achievements.StayAWhile:
                    return "Slow a fast enemy with 5 different fully upgraded spike traps.";

                case Achievements.TheseAreCheaper:
                    return "Win the game without using any cannons.";

                case Achievements.Victory:
                    return "Win the game.";

                case Achievements.WhyWontYouDie:
                    return "Hit the same poison-immune enemy 5 times with a fully upgraded poison trap.";

                default:
                    throw new NotImplementedException();
            }
        }
Exemplo n.º 32
0
        public override void DoJob()
        {
            Console.WriteLine("Starting TotalUpaiedInvoiceJob...");
            RestClient    client   = RevisoRestClient.CreateClient();
            RestRequest   request  = new RestRequest("v2/invoices/unpaid?pageSize=10000", Method.GET);
            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                string err = String.Format("{0} => {1}", response.StatusCode, response.ErrorMessage);
                throw new InvalidOperationException(err);
            }

            string json = response.Content;
            // deserializzazione e test delle proprietà principali
            JsonObject dto   = JsonConvert.DeserializeObject <JsonObject>(json);
            JArray     array = dto["collection"] as JArray;

            if (array == null)
            {
                throw new InvalidOperationException("array");
            }

            List <Invoice>   listInvoice      = JsonConvert.DeserializeObject <List <Invoice> >(array.ToString());
            AchievementLevel level            = Achievements.ElaborateTotalUnpaied2018Invoice(listInvoice);
            string           connectionString = "Data Source=NB-FMARCHETTI2;Initial Catalog=HACKNIGHT_TSPESARO;Persist Security Info=True;User ID=sa;Password=teamsystem";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    connection.Open();
                    int    goalRuleId = GetUpaiedGoalRuleByLevel(level);
                    string sqlCommand = null;
                    if (level == AchievementLevel.Zero)
                    {
                        sqlCommand = "DELETE FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID IN (10, 11, 12)";
                    }
                    else if (level == AchievementLevel.One)
                    {
                        sqlCommand = String.Format(@"DELETE FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID IN(11, 12)
IF NOT EXISTS (SELECT TOP 1 1 FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID = {0})
BEGIN
    INSERT INTO USER_ACHIEVEMENTS (USR_ID, GOAL_RULE_ID) VALUES (1, {0})
END;", goalRuleId);
                    }
                    else if (level == AchievementLevel.Two)
                    {
                        sqlCommand = String.Format(@"DELETE FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID IN(12)
IF NOT EXISTS (SELECT TOP 1 1 FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID = {0})
BEGIN
    INSERT INTO USER_ACHIEVEMENTS (USR_ID, GOAL_RULE_ID) VALUES (1, {0})
END;", goalRuleId);
                    }
                    else
                    {
                        sqlCommand = String.Format(@"IF NOT EXISTS (SELECT TOP 1 1 FROM USER_ACHIEVEMENTS WHERE USR_ID = 1 AND GOAL_RULE_ID = {0})
BEGIN
    INSERT INTO USER_ACHIEVEMENTS (USR_ID, GOAL_RULE_ID) VALUES (1, {0})
END;", goalRuleId);
                    }
                    command.CommandText = sqlCommand;
                    command.ExecuteNonQuery();
                    connection.Close();
                }
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Draws the content of this screen.
        /// </summary>
        /// <param name="spriteBatch">spriteBatch that this object should draw to.</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();

            base.Draw(spriteBatch);

            // background window
            spriteBatch.StrokedRectangle(mMenuBoxPosition,
                                         mMenuBoxSize,
                                         Color.White,
                                         Color.White,
                                         0.5f,
                                         0.21f);

            // window title
            spriteBatch.DrawString(mLibSans36,
                                   text: WindowTitleStr,
                                   position: mMenuBoxPosition + new Vector2(20, 10),
                                   color: mTextColor * mMenuOpacity);

            // Back Button
            mBackButton.Draw(spriteBatch);

            #region Achievements

            // First
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.SystemOnline() ? "The system goes online August 14th 1997" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 80),
                                   mTextColor * mMenuOpacity * (Achievements.SystemOnline() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Place 1 Platform",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 110),
                                   mTextColor * mMenuOpacity * (Achievements.SystemOnline() ? 1 : 0.5f));

            // Second
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.SelfAware() ? "It becomes self aware at 2:14 AM" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 140),
                                   mTextColor * mMenuOpacity * (Achievements.SelfAware() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Complete the tutorial",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 170),
                                   mTextColor * mMenuOpacity * (Achievements.SystemOnline() ? 1 : 0.5f));

            // Third
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.Skynet() ? "Skynet" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 200),
                                   mTextColor * mMenuOpacity * (Achievements.Skynet() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Build a network of 30 platforms",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 230),
                                   mTextColor * mMenuOpacity * (Achievements.Skynet() ? 1 : 0.5f));

            // Fourth
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.WallE() ? "Wall E" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 260),
                                   mTextColor * mMenuOpacity * (Achievements.WallE() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Burn 10,000 units of trash",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 290),
                                   mTextColor * mMenuOpacity * (Achievements.WallE() ? 1 : 0.5f));

            // Fifth
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.Hal9000() ? "HAL 9000" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 320),
                                   mTextColor * mMenuOpacity * (Achievements.Hal9000() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Complete the campaign",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 350),
                                   mTextColor * mMenuOpacity * (Achievements.Hal9000() ? 1 : 0.5f));

            // Sixth
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.Replicant() ? "Replicant" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 380),
                                   mTextColor * mMenuOpacity * (Achievements.Replicant() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Produce 50 units",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 410),
                                   mTextColor * mMenuOpacity * (Achievements.Replicant() ? 1 : 0.5f));

            // Seventh
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.RateOurGame() ? "Please rate our game perfect 5/7" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 440),
                                   mTextColor * mMenuOpacity * (Achievements.RateOurGame() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Build 1,000 Military units",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 470),
                                   mTextColor * mMenuOpacity * (Achievements.RateOurGame() ? 1 : 0.5f));

            // Third
            spriteBatch.DrawString(mLibSans20,
                                   Achievements.Overachiever() ? "Overachiever" : "???",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 500),
                                   mTextColor * mMenuOpacity * (Achievements.Overachiever() ? 1 : 0.5f));
            spriteBatch.DrawString(mLibSans12,
                                   "Unlock all achievements",
                                   new Vector2(mMenuBoxPosition.X + AchievementOffset, mMenuBoxPosition.Y + 530),
                                   mTextColor * mMenuOpacity * (Achievements.Overachiever() ? 1 : 0.5f));
            #endregion

            spriteBatch.End();
        }
        /// <summary>
        /// Platform agnostic way for unlocking achievements. Can be called repeatedly.
        /// </summary>
        /// <param name="ach">The achievement to unlock.</param>
        public void UnlockAchievement(Achievements ach)
        {
#if __ANDROID__
            BumpSetSpike_Android.Activity1 activity = Game1.Activity as BumpSetSpike_Android.Activity1;
            if (activity.pGooglePlayClient.IsConnected)
            {
                activity.pGooglePlayClient.UnlockAchievement(activity.Resources.GetString(mAchievementMapping[(Int32)ach].mResourceId));
            }
#endif //__ANDROID__
            DebugMessageDisplay.pInstance.AddConstantMessage("Unlocked: " + ach.ToString());
        }
Exemplo n.º 35
0
        /// <summary>
        /// Returns true if Player instances are equal
        /// </summary>
        /// <param name="input">Instance of Player to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Player?input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Clan == input.Clan ||
                     (Clan != null &&
                      Clan.Equals(input.Clan))
                     ) &&
                 (
                     League == input.League ||
                     (League != null &&
                      League.Equals(input.League))
                 ) &&
                 (
                     Role == input.Role ||
                     Role.Equals(input.Role)
                 ) &&
                 (
                     AttackWins == input.AttackWins ||
                     AttackWins.Equals(input.AttackWins)
                 ) &&
                 (
                     DefenseWins == input.DefenseWins ||
                     DefenseWins.Equals(input.DefenseWins)
                 ) &&
                 (
                     TownHallLevel == input.TownHallLevel ||
                     TownHallLevel.Equals(input.TownHallLevel)
                 ) &&
                 (
                     TownHallWeaponLevel == input.TownHallWeaponLevel ||
                     TownHallWeaponLevel.Equals(input.TownHallWeaponLevel)
                 ) &&
                 (
                     VersusBattleWins == input.VersusBattleWins ||
                     VersusBattleWins.Equals(input.VersusBattleWins)
                 ) &&
                 (
                     LegendStatistics == input.LegendStatistics ||
                     (LegendStatistics != null &&
                      LegendStatistics.Equals(input.LegendStatistics))
                 ) &&
                 (
                     Troops == input.Troops ||
                     Troops != null &&
                     input.Troops != null &&
                     Troops.SequenceEqual(input.Troops)
                 ) &&
                 (
                     Heroes == input.Heroes ||
                     Heroes != null &&
                     input.Heroes != null &&
                     Heroes.SequenceEqual(input.Heroes)
                 ) &&
                 (
                     Spells == input.Spells ||
                     Spells != null &&
                     input.Spells != null &&
                     Spells.SequenceEqual(input.Spells)
                 ) &&
                 (
                     Labels == input.Labels ||
                     Labels != null &&
                     input.Labels != null &&
                     Labels.SequenceEqual(input.Labels)
                 ) &&
                 (
                     Tag == input.Tag ||
                     (Tag != null &&
                      Tag.Equals(input.Tag))
                 ) &&
                 (
                     Name == input.Name ||
                     (Name != null &&
                      Name.Equals(input.Name))
                 ) &&
                 (
                     ExpLevel == input.ExpLevel ||
                     ExpLevel.Equals(input.ExpLevel)
                 ) &&
                 (
                     Trophies == input.Trophies ||
                     Trophies.Equals(input.Trophies)
                 ) &&
                 (
                     BestTrophies == input.BestTrophies ||
                     BestTrophies.Equals(input.BestTrophies)
                 ) &&
                 (
                     Donations == input.Donations ||
                     Donations.Equals(input.Donations)
                 ) &&
                 (
                     DonationsReceived == input.DonationsReceived ||
                     DonationsReceived.Equals(input.DonationsReceived)
                 ) &&
                 (
                     BuilderHallLevel == input.BuilderHallLevel ||
                     BuilderHallLevel.Equals(input.BuilderHallLevel)
                 ) &&
                 (
                     VersusTrophies == input.VersusTrophies ||
                     VersusTrophies.Equals(input.VersusTrophies)
                 ) &&
                 (
                     BestVersusTrophies == input.BestVersusTrophies ||
                     BestVersusTrophies.Equals(input.BestVersusTrophies)
                 ) &&
                 (
                     WarStars == input.WarStars ||
                     WarStars.Equals(input.WarStars)
                 ) &&
                 (
                     Achievements == input.Achievements ||
                     Achievements != null &&
                     input.Achievements != null &&
                     Achievements.SequenceEqual(input.Achievements)
                 ) &&
                 (
                     VersusBattleWinCount == input.VersusBattleWinCount ||
                     VersusBattleWinCount.Equals(input.VersusBattleWinCount)
                 ));
        }
Exemplo n.º 36
0
        public void LoadFromJSON(string jsonString)
        {
            var jsonObject = JObject.Parse(jsonString);

            m_vId                  = jsonObject["avatar_id"].ToObject <long>();
            m_vHighInt             = jsonObject["id_high_int"].ToObject <int>();
            m_vLowInt              = jsonObject["id_low_int"].ToObject <int>();
            m_vToken               = jsonObject["token"].ToObject <string>();
            m_vRegion              = jsonObject["region"].ToObject <string>();
            m_vAccountCreationDate = jsonObject["avatar_creation_date"].ToObject <DateTime>();
            m_vActiveLayout        = jsonObject["active_layout"].ToObject <int>();
            m_vAndroid             = jsonObject["android"].ToObject <bool>();
            m_vCurrentHomeId       = jsonObject["current_home_id"].ToObject <long>();
            m_vAllianceId          = jsonObject["alliance_id"].ToObject <long>();
            SetAllianceCastleLevel(jsonObject["alliance_castle_level"].ToObject <int>());
            SetAllianceCastleTotalCapacity(jsonObject["alliance_castle_total_capacity"].ToObject <int>());
            SetAllianceCastleUsedCapacity(jsonObject["alliance_castle_used_capacity"].ToObject <int>());
            SetTownHallLevel(jsonObject["townhall_level"].ToObject <int>());
            m_vAvatarName  = jsonObject["avatar_name"].ToObject <string>();
            m_vAvatarLevel = jsonObject["avatar_level"].ToObject <int>();
            m_vExperience  = jsonObject["experience"].ToObject <int>();
            m_vCurrentGems = jsonObject["current_gems"].ToObject <int>();
            SetScore(jsonObject["score"].ToObject <int>());
            m_vNameChangingLeft = jsonObject["nameChangesLeft"].ToObject <byte>();
            m_vnameChosenByUser = jsonObject["nameChosenByUser"].ToObject <byte>();

            var jsonBookmarkedClan = (JArray)jsonObject["bookmark"];

            foreach (JObject jobject in jsonBookmarkedClan)
            {
                var data = (JObject)jobject;
                var ds   = new BookmarkSlot(0);
                ds.Load(data);
                BookmarkedClan.Add(ds);
            }

            var jsonResources = (JArray)jsonObject["resources"];

            foreach (JObject resource in jsonResources)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(resource);
                GetResources().Add(ds);
            }

            var jsonUnits = (JArray)jsonObject["units"];

            foreach (JObject unit in jsonUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unit);
                m_vUnitCount.Add(ds);
            }

            var jsonSpells = (JArray)jsonObject["spells"];

            foreach (JObject spell in jsonSpells)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(spell);
                m_vSpellCount.Add(ds);
            }

            var jsonUnitLevels = (JArray)jsonObject["unit_upgrade_levels"];

            foreach (JObject unitLevel in jsonUnitLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unitLevel);
                m_vUnitUpgradeLevel.Add(ds);
            }

            var jsonSpellLevels = (JArray)jsonObject["spell_upgrade_levels"];

            foreach (JObject data in jsonSpellLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vSpellUpgradeLevel.Add(ds);
            }

            var jsonHeroLevels = (JArray)jsonObject["hero_upgrade_levels"];

            foreach (JObject data in jsonHeroLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroUpgradeLevel.Add(ds);
            }

            var jsonHeroHealth = (JArray)jsonObject["hero_health"];

            foreach (JObject data in jsonHeroHealth)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroHealth.Add(ds);
            }

            var jsonHeroState = (JArray)jsonObject["hero_state"];

            foreach (JObject data in jsonHeroState)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroState.Add(ds);
            }

            var jsonAllianceUnits = (JArray)jsonObject["alliance_units"];

            foreach (JObject data in jsonAllianceUnits)
            {
                var ds = new TroopDataSlot(null, 0, 0);
                ds.Load(data);
                AllianceUnits.Add(ds);
            }
            TutorialStepsCount = jsonObject["tutorial_step"].ToObject <uint>();

            var jsonAchievementsProgress = (JArray)jsonObject["achievements_progress"];

            foreach (JObject data in jsonAchievementsProgress)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                Achievements.Add(ds);
            }

            var jsonNpcStars = (JArray)jsonObject["npc_stars"];

            foreach (JObject data in jsonNpcStars)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcStars.Add(ds);
            }

            var jsonNpcLootedGold = (JArray)jsonObject["npc_looted_gold"];

            foreach (JObject data in jsonNpcLootedGold)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedGold.Add(ds);
            }

            var jsonNpcLootedElixir = (JArray)jsonObject["npc_looted_elixir"];

            foreach (JObject data in jsonNpcLootedElixir)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedElixir.Add(ds);
            }
            var jsonQuickTrain1 = (JArray)jsonObject["quick_train_1"];

            foreach (JObject data in jsonQuickTrain1)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain1.Add(ds);
            }
            var jsonQuickTrain2 = (JArray)jsonObject["quick_train_2"];

            foreach (JObject data in jsonQuickTrain2)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain2.Add(ds);
            }
            var jsonQuickTrain3 = (JArray)jsonObject["quick_train_3"];

            foreach (JObject data in jsonQuickTrain3)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain3.Add(ds);
            }
            m_vPremium = jsonObject["Premium"].ToObject <bool>();
        }
Exemplo n.º 37
0
        public bool IsAchieved(string id)
        {
            var achievement = Achievements.FirstOrDefault(ac => ac.id == id);

            return(achievement != null && achievement.completed);
        }
Exemplo n.º 38
0
 void fillStatistics(UserSearchDTO user)
 {
     lvStatistics.Items.Clear();
     if (user.Statistics != null)
     {
         addStatistic(string.Format(ApplicationStrings.UserStatistics_TrainingDaysCountText, user.Statistics.TrainingDaysCount), Achievements.GetTrainingDaysCount(user), Achievements.GetTrainingDaysInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_WorkoutPlansText, user.Statistics.WorkoutPlansCount), Achievements.GetWorkoutPlansCount(user), Achievements.GetWorkoutPlansInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_FriendsCountText, user.Statistics.FriendsCount), Achievements.GetFriendsCount(user), Achievements.GetFriendsInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_FollowersCountText, user.Statistics.FollowersCount), Achievements.GetFollowersCount(user), Achievements.GetFollowersInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_VotesCountText, user.Statistics.VotingsCount), Achievements.GetVotingsCount(user), Achievements.GetVotingsInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_BlogCommentsCountText, user.Statistics.BlogCommentsCount), Achievements.GetBlogCommentsCount(user), Achievements.GetBlogCommentsInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_MyBlogCommentsCount, user.Statistics.MyBlogCommentsCount), Achievements.GetMyBlogCommentsCount(user), Achievements.GetMyBlogCommentsInfo());
         addStatistic(string.Format(ApplicationStrings.UserStatistics_StrengthTrainingEntriesCount, user.Statistics.StrengthTrainingEntriesCount), Achievements.GetStrengthTrainingEntriesCount(user), Achievements.GetStrengthTrainingEntriesInfo());
         addStatistic(string.Format(DomainModelStrings.UserStatistics_SizeEntriesCount, user.Statistics.SizeEntriesCount), Achievements.GetSizeEntriesCount(user), Achievements.GetSizeEntriesInfo());
         addStatistic(string.Format(DomainModelStrings.UserStatistics_SupplementsEntriesCount, user.Statistics.SupplementEntriesCount), Achievements.GetSupplementsEntriesCount(user), Achievements.GetSupplementEntriesInfo());
         addStatistic(string.Format(DomainModelStrings.UserStatistics_BlogEntriesCount, user.Statistics.BlogEntriesCount), Achievements.GetBlogEntriesCount(user), Achievements.GetBlogEntriesInfo());
         addStatistic(string.Format(DomainModelStrings.UserStatistics_A6WEntriesCount, user.Statistics.A6WEntriesCount), Achievements.GetA6WEntriesCount(user), Achievements.GetA6WEntriesInfo());
         addStatistic(string.Format(DomainModelStrings.UserStatistics_A6WFullCyclesCount, user.Statistics.A6WFullCyclesCount), Achievements.GetA6WFullCyclesCount(user), Achievements.GetA6WFullCyclesInfo());
         if (!user.IsMe() && UserContext.CurrentProfile.Role == Role.Administrator)
         {//show last login date only when we view another user. We user ToCalendar to hide a time of login - we show only the date
             lvStatistics.Items.Add(string.Format(DomainModelStrings.UserStatistics_LastLoginDate, user.Statistics.LastLoginDate != null? user.Statistics.LastLoginDate.Value.ToCalendarDate(): string.Empty));
         }
         lvStatistics.Items.Add(string.Format(DomainModelStrings.UserStatistics_LastEntryDate, user.Statistics.LastEntryDate != null? user.Statistics.LastEntryDate.Value.ToCalendarDate(): string.Empty));
     }
 }
Exemplo n.º 39
0
 public Achievement(Achievements achievements, IntPtr stats)
 {
   this._stats = stats;
   this._achievements = achievements;
 }
Exemplo n.º 40
0
        public void LoadFromJSON(string jsonString)
        {
            JObject jsonObject = JObject.Parse(jsonString);

            m_vId            = jsonObject["avatar_id"].ToObject <long>();
            m_vCurrentHomeId = jsonObject["current_home_id"].ToObject <long>();
            m_vAllianceId    = jsonObject["alliance_id"].ToObject <long>();
            SetAllianceCastleLevel(jsonObject["alliance_castle_level"].ToObject <int>());
            SetAllianceCastleTotalCapacity(jsonObject["alliance_castle_total_capacity"].ToObject <int>());
            SetAllianceCastleUsedCapacity(jsonObject["alliance_castle_used_capacity"].ToObject <int>());
            SetTownHallLevel(jsonObject["townhall_level"].ToObject <int>());
            m_vAvatarName      = jsonObject["avatar_name"].ToObject <string>();
            m_vAvatarLevel     = jsonObject["avatar_level"].ToObject <int>();
            m_vExperience      = jsonObject["experience"].ToObject <int>();
            m_vCurrentGems     = jsonObject["current_gems"].ToObject <int>();
            m_vScore           = jsonObject["score"].ToObject <int>();
            m_vIsAvatarNameSet = jsonObject["is_avatar_name_set"].ToObject <byte>();

            /*JArray jsonMaxResources = (JArray)jsonObject["max_resources"];
             * foreach (JObject resource in jsonMaxResources)
             * {
             *  var ds = new DataSlot(null, 0);
             *  ds.Load(resource);
             *  m_vResourceCaps.Add(ds);
             * }*/

            JArray jsonResources = (JArray)jsonObject["resources"];

            foreach (JObject resource in jsonResources)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(resource);
                GetResources().Add(ds);
            }

            JArray jsonUnits = (JArray)jsonObject["units"];

            foreach (JObject unit in jsonUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unit);
                m_vUnitCount.Add(ds);
            }

            JArray jsonSpells = (JArray)jsonObject["spells"];

            foreach (JObject spell in jsonSpells)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(spell);
                m_vSpellCount.Add(ds);
            }

            JArray jsonUnitLevels = (JArray)jsonObject["unit_upgrade_levels"];

            foreach (JObject unitLevel in jsonUnitLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unitLevel);
                m_vUnitUpgradeLevel.Add(ds);
            }

            JArray jsonSpellLevels = (JArray)jsonObject["spell_upgrade_levels"];

            foreach (JObject data in jsonSpellLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vSpellUpgradeLevel.Add(ds);
            }

            JArray jsonHeroLevels = (JArray)jsonObject["hero_upgrade_levels"];

            foreach (JObject data in jsonHeroLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroUpgradeLevel.Add(ds);
            }

            JArray jsonHeroHealth = (JArray)jsonObject["hero_health"];

            foreach (JObject data in jsonHeroHealth)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroHealth.Add(ds);
            }

            JArray jsonHeroState = (JArray)jsonObject["hero_state"];

            foreach (JObject data in jsonHeroState)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroState.Add(ds);
            }

            JArray jsonAllianceUnits = (JArray)jsonObject["alliance_units"];

            foreach (JObject data in jsonAllianceUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                AllianceUnits.Add(ds);
            }

            TutorialStepsCount = jsonObject["tutorial_step"].ToObject <uint>();

            /*JArray jsonUnlockedAchievements = (JArray)jsonObject["unlocked_achievements"];
             * foreach (JObject data in jsonUnlockedAchievements)
             * {
             *  int globalId = data["global_id"].ToObject<int>();
             *  Achievements.Add(globalId);
             * }*/

            JArray jsonAchievementsProgress = (JArray)jsonObject["achievements_progress"];

            foreach (JObject data in jsonAchievementsProgress)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                Achievements.Add(ds);
            }

            JArray jsonNpcStars = (JArray)jsonObject["npc_stars"];

            foreach (JObject data in jsonNpcStars)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcStars.Add(ds);
            }

            JArray jsonNpcLootedGold = (JArray)jsonObject["npc_looted_gold"];

            foreach (JObject data in jsonNpcLootedGold)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedGold.Add(ds);
            }

            JArray jsonNpcLootedElixir = (JArray)jsonObject["npc_looted_elixir"];

            foreach (JObject data in jsonNpcLootedElixir)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedElixir.Add(ds);
            }
        }
Exemplo n.º 41
0
        void Start()
        {
            gameManager = GameObject.Find ("Follow Camera").GetComponent<GmaeManage> ();
            umbrella = GameObject.Find ("main_Sphere");
            if (gameManager.consoleControllerType == ConsoleControllerType.PS3) {
                tutorial = GameObject.Find ("Tutorial_PS3").GetComponent<Tutuorial> ();
            } else if (gameManager.consoleControllerType == ConsoleControllerType.XBox) {
                tutorial = GameObject.Find ("Tutorial_XBox").GetComponent<Tutuorial> ();
            }

            achieves = GameObject.Find ("Follow Camera").GetComponent<Achievements> ();
            rb = umbrella.GetComponent<Rigidbody> ();
            umbrellaCol = umbrella.GetComponent<Collider> ();
        }
Exemplo n.º 42
0
 public AchievementItem(Achievements achievement, GameUpdater env, SpriteFont font)
     : base("A\nA", font)
 {
     this.ach = achievement;
     this.env = env;
 }
Exemplo n.º 43
0
    public void SetHitsCount(int hits, bool blink = true)
    {
        if (On == false || ComboMessageOn == true)
        {
            return;
        }

        if (hits == 0)
        {
            GuiManager.StopCoroutine("BlinkSprite");

            if (SpriteHitsMessage.hidden == false)
            {
                GuiManager.StartCoroutine(DisappearSprite(SpriteHitsMessage, 0.2f));
            }

            if (SpriteHitNumbers.Sprites[0].hidden == false)
            {
                GuiManager.StartCoroutine(DisappearSprite(SpriteHitNumbers.Sprites[0], 0.2f));
            }

            if (SpriteHitNumbers.Sprites[1].hidden == false)
            {
                GuiManager.StartCoroutine(DisappearSprite(SpriteHitNumbers.Sprites[1], 0.2f));
            }
        }
        else
        {
            // of	unlockAchievement
            if (hits == 10)
            {
                Achievements.UnlockAchievement(11);
            }
            else if (hits == 50)
            {
                Achievements.UnlockAchievement(12);
            }
            else if (hits == 100)
            {
                Achievements.UnlockAchievement(13);
            }
            if (hits > 99)
            {
                hits = 99;
            }

            //Debug.Log("show sprites");

            if (SpriteHitsMessage.hidden)
            {
                GuiManager.StartCoroutine(ShowSprite(SpriteHitsMessage, 0.2f));
            }

            if (blink)
            {
                GuiManager.StartCoroutine(BlinkSprite(SpriteHitsMessage, 1.8f, 10, 1, 0.0f, GuiCombatProgress.HScreenWidth, GuiCombatProgress.HScreenHeight));
            }

            int number = hits % 10;
            int tents  = hits / 10;

            if (SpriteHitNumbers.Sprites[0].hidden)
            {
                GuiManager.StartCoroutine(ShowSprite(SpriteHitNumbers.Sprites[0], 0.2f));
            }

            SpriteHitNumbers.Sprites[0].lowerLeftUV = DefaultSpriteUI.PixelCoordToUVCoord(GuiHitNumbers.Instance.UvLeft + GuiHitNumbers.Instance.UvWidth * number, GuiHitNumbers.Instance.UvTop);

            if (blink)
            {
                GuiManager.StartCoroutine(BlinkSprite(SpriteHitNumbers.Sprites[0], 1.6f, 6, 4, 0.1f, GuiHitNumbers.Instance.ScreenWidth, GuiHitNumbers.Instance.ScreenHeight));
            }

            if (hits > 9)
            {
                if (SpriteHitNumbers.Sprites[1].hidden)
                {
                    GuiManager.StartCoroutine(ShowSprite(SpriteHitNumbers.Sprites[1], 0.2f));
                }

                SpriteHitNumbers.Sprites[1].lowerLeftUV = DefaultSpriteUI.PixelCoordToUVCoord(GuiHitNumbers.Instance.UvLeft + GuiHitNumbers.Instance.UvWidth * tents, GuiHitNumbers.Instance.UvTop);

                if (blink)
                {
                    GuiManager.StartCoroutine(BlinkSprite(SpriteHitNumbers.Sprites[1], 1.6f, 6, 4, 0.1f, GuiHitNumbers.Instance.ScreenWidth, GuiHitNumbers.Instance.ScreenHeight));
                }
            }
        }
    }
Exemplo n.º 44
0
    void checkForAchievements(float n, float s)
    {
        UnityEngine.UI.Text achievementsText = Achievements.GetComponent <UnityEngine.UI.Text>();

        //Debug.Log(game_data.AchievementDict[0].Name + " is " + game_data.AchievementDict[0].Earned);
        isNewBadge = false;
        // dark side
        if ((n < 1 && s > 10 || s < 2 && n > 10) && !game_data.AchievementDict[0].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[0].Name);
            game_data.AchievementDict[0].Earned = true;
            isNewBadge = true;
        }
        // good and golden
        else if (n < 9 && s < 9 && s > 7 && n > 7 && !game_data.AchievementDict[1].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[1].Name);
            game_data.AchievementDict[1].Earned = true;
            isNewBadge = true;
        }
        // unroasted
        else if (n < 2 && s < 2 && !game_data.AchievementDict[2].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[2].Name);
            game_data.AchievementDict[2].Earned = true;
            isNewBadge = true;
        }
        // charred
        else if (n > 10 && s > 10 && !game_data.AchievementDict[3].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[3].Name);
            game_data.AchievementDict[3].Earned = true;
            isNewBadge = true;
        }
        // 6666
        else if (Mathf.Round(n * 10f) == 66 && Mathf.Round(s * 10f) == 66 && !game_data.AchievementDict[4].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[4].Name);
            game_data.AchievementDict[4].Earned = true;
            isNewBadge = true;
        }
        // Rapid Roast
        else if (timePassedPerMallow <= 25f && n < 9 && s < 9 && s > 7 && n > 7 && !game_data.AchievementDict[5].Earned && game_data.AchievementDict[1].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[5].Name);
            game_data.AchievementDict[5].Earned = true;
            isNewBadge = true;
        }
        // one flame
        else if (fireCounterPerMallow == 1 && !game_data.AchievementDict[6].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[6].Name);
            game_data.AchievementDict[6].Earned = true;
            isNewBadge = true;
        }
        // two flame
        else if (fireCounterPerMallow >= 2 && !game_data.AchievementDict[7].Earned)
        {
            achievementsText.text = ("New Achievement! " + game_data.AchievementDict[7].Name);
            game_data.AchievementDict[7].Earned = true;
            isNewBadge = true;
        }
        // we need an if statement here!
        if (isNewBadge == true)
        {
            StartCoroutine(FadeTextToZeroAlpha(3f, achievementsText));
        }
    }
Exemplo n.º 45
0
 // Use this for initialization
 void Start()
 {
     achievements = GetComponent<Achievements>();
     achievementPopup = GetComponent<AchievementPopup>();
 }
Exemplo n.º 46
0
    void Start()
    {
        achiev_images.Add (Bircircle);
        achiev_images.Add (WhatGoesAround);
        achiev_images.Add (ComesBackAround);
        achiev_images.Add (TheySeeMeRollin);
        achiev_images.Add (FingerLickingGood);
        achiev_images.Add (CheGuefinger);
        achiev_images.Add (Kreiselficker);
        achiev_images.Add (TheNewB);
        achiev_images.Add (FuckTheSystem);
        achiev_images.Add (MultiFingering);

        achievement_comp = gameObject.GetComponent<Achievements> ();
    }