private void UpdateTabJewels() { ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; this.cratesJewel.Value = Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.NumInventoryCratesNotViewed)); this.buildingsJewel.Value = 0; this.troopsJewel.Value = Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.NumInventoryTroopsNotViewed)); this.currencyJewel.Value = Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.NumInventoryCurrencyNotViewed)); }
private void OnFactionFlipConfirmed(object result, object cookie) { if (result == null) { return; } if (!Convert.ToBoolean(result)) { this.Visible = true; return; } ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; if (serverPlayerPrefs.GetPref(ServerPref.FactionFlipped) == "0") { serverPlayerPrefs.SetPref(ServerPref.FactionFlipped, "1"); Service.ServerAPI.Enqueue(new SetPrefsCommand(false)); } if (this.oppositePlayerInfo != null && !string.IsNullOrEmpty(this.oppositePlayerInfo.PlayerId)) { Service.PlayerIdentityController.SwitchIdentity(this.oppositePlayerInfo.PlayerId); } else { Service.PlayerIdentityController.SwitchToNewIdentity(); } }
public CampaignController() { Service.CampaignController = this; this.player = Service.CurrentPlayer; this.progress = this.player.CampaignProgress; this.server = Service.ServerAPI; this.sdc = Service.StaticDataController; this.rm = Service.RewardManager; this.hud = Service.UXController.HUD; this.activeMissionConductors = new List <MissionConductor>(); this.progress.RemoveMissingMissionData(); List <CampaignMissionVO> allMissionsInProgress = this.progress.GetAllMissionsInProgress(); int i = 0; int count = allMissionsInProgress.Count; while (i < count) { this.ResumeMission(allMissionsInProgress[i]); i++; } this.progress.CheckForNewMissions(ref this.newChapterMissionFlag); ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; if (Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.ChapterMissionViewed)) > 0) { this.newChapterMissionFlag = false; } }
public EatResponse OnEvent(EventId id, object cookie) { if (Service.NotificationController.HasAgreedToNotifications()) { return(EatResponse.NotEaten); } uint time = ServerTime.Time; ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; int num = Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.PushAuthPromptedCount)); bool flag = this.HasReachedPushNotificationLimit(num); switch (id) { case EventId.SquadJoinedByCurrentPlayer: case EventId.SquadJoinInviteAcceptedByCurrentPlayer: if (!flag && this.HasEnoughTimeElapsed(time, ServerPref.LastPushAuthPromptSquadJoinedTime, GameConstants.PUSH_NOTIFICATION_SQUAD_JOIN_COOLDOWN) && !this.IsHolonetOpen()) { new ActionChain("SocialPushNotifRepromptActionForSquadJoin"); serverPlayerPrefs.SetPref(ServerPref.LastPushAuthPromptSquadJoinedTime, time.ToString()); serverPlayerPrefs.SetPref(ServerPref.PushAuthPromptedCount, (num + 1).ToString()); Service.ServerAPI.Sync(new SetPrefsCommand(false)); } return(EatResponse.NotEaten); case EventId.SquadJoinApplicationAcceptedByCurrentPlayer: case EventId.SquadWarTroopsRequestStartedByCurrentPlayer: IL_57: if (id != EventId.RaidNotifyRequest) { return(EatResponse.NotEaten); } new ActionChain("SocialPushNotifRepromptActionForRaids"); serverPlayerPrefs.SetPref(ServerPref.LastPushAuthPromptTroopRequestTime, time.ToString()); serverPlayerPrefs.SetPref(ServerPref.PushAuthPromptedCount, (num + 1).ToString()); Service.ServerAPI.Sync(new SetPrefsCommand(false)); return(EatResponse.NotEaten); case EventId.SquadTroopsRequestedByCurrentPlayer: if (!flag && this.HasEnoughTimeElapsed(time, ServerPref.LastPushAuthPromptTroopRequestTime, GameConstants.PUSH_NOTIFICATIONS_TROOP_REQUEST_COOLDOWN)) { new ActionChain("SocialPushNotifRepromptActionForTroopRequest"); serverPlayerPrefs.SetPref(ServerPref.LastPushAuthPromptTroopRequestTime, time.ToString()); serverPlayerPrefs.SetPref(ServerPref.PushAuthPromptedCount, (num + 1).ToString()); Service.ServerAPI.Sync(new SetPrefsCommand(false)); } return(EatResponse.NotEaten); case EventId.SquadWarTroopsRequestedByCurrentPlayer: if (!flag && this.HasEnoughTimeElapsed(time, ServerPref.LastPushAuthPromptTroopRequestTime, GameConstants.PUSH_NOTIFICATIONS_TROOP_REQUEST_COOLDOWN)) { new ActionChain("SocialPushNotifRepromptActionForWarTroopRequest"); serverPlayerPrefs.SetPref(ServerPref.LastPushAuthPromptTroopRequestTime, time.ToString()); serverPlayerPrefs.SetPref(ServerPref.PushAuthPromptedCount, (num + 1).ToString()); Service.ServerAPI.Sync(new SetPrefsCommand(false)); } return(EatResponse.NotEaten); } goto IL_57; }
private bool HasEnoughTimeElapsed(uint nowSeconds, ServerPref pref, float cooldown) { ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; uint num = Convert.ToUInt32(serverPlayerPrefs.GetPref(pref)); uint num2 = nowSeconds - num; uint num3 = (uint)(cooldown * 3600f); return(num2 > num3); }
public void UpdateBadgingBasedOnAvailableCrates() { ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; int num = Convert.ToInt32(serverPlayerPrefs.GetPref(ServerPref.NumInventoryCratesNotViewed)); int availableCountAfterLastView = this.GetAvailableCountAfterLastView(); num = availableCountAfterLastView - num; GameUtils.UpdateInventoryCrateBadgeCount(num); }
private void UpdateMissionsViewedPref(int amount) { ServerPref pref = ServerPref.ChapterMissionViewed; ServerPlayerPrefs serverPlayerPrefs = Service.ServerPlayerPrefs; int num = Convert.ToInt32(serverPlayerPrefs.GetPref(pref)); num = amount; serverPlayerPrefs.SetPref(pref, num.ToString()); Service.ServerAPI.Enqueue(new SetPrefsCommand(false)); }
private void UpdateMissionsViewedPref(int amount) { ServerPref pref = ServerPref.ChapterMissionViewed; ServerPlayerPrefs serverPlayerPrefs = Service.Get <ServerPlayerPrefs>(); int num = Convert.ToInt32(serverPlayerPrefs.GetPref(pref), CultureInfo.InvariantCulture); num = amount; serverPlayerPrefs.SetPref(pref, num.ToString()); Service.Get <ServerAPI>().Enqueue(new SetPrefsCommand(false)); }
public override ISerializable FromObject(object obj) { CurrentPlayer currentPlayer = Service.CurrentPlayer; Dictionary <string, object> dictionary = obj as Dictionary <string, object>; if (dictionary == null) { return(this); } if (dictionary.ContainsKey("triggers")) { Service.QuestController.SavePendingTriggers((List <object>)dictionary["triggers"]); } currentPlayer.FirstTimePlayer = (bool)dictionary["firstTimePlayer"]; if (dictionary.ContainsKey("created")) { Service.CurrentPlayer.FirstLoginTime = Convert.ToUInt32(dictionary["created"] as string); } string prefsString = dictionary["clientPrefs"] as string; ServerPlayerPrefs serverPlayerPrefs = new ServerPlayerPrefs(prefsString); if (dictionary.ContainsKey("scalars")) { Dictionary <string, object> dictionary2 = dictionary["scalars"] as Dictionary <string, object>; if (dictionary2 != null) { if (dictionary2.ContainsKey("attackRating")) { currentPlayer.AttackRating = Convert.ToInt32(dictionary2["attackRating"]); } if (dictionary2.ContainsKey("defenseRating")) { currentPlayer.DefenseRating = Convert.ToInt32(dictionary2["defenseRating"]); } if (dictionary2.ContainsKey("attacksWon")) { currentPlayer.AttacksWon = Convert.ToInt32(dictionary2["attacksWon"]); } if (dictionary2.ContainsKey("defensesWon")) { currentPlayer.DefensesWon = Convert.ToInt32(dictionary2["defensesWon"]); } } } if (dictionary.ContainsKey("sharedPrefs")) { Service.SharedPlayerPrefs.Populate(dictionary["sharedPrefs"] as Dictionary <string, object>); } if (dictionary.ContainsKey("name")) { currentPlayer.PlayerName = (dictionary["name"] as string); } if (dictionary.ContainsKey("currentlyDefending")) { Dictionary <string, object> dictionary3 = dictionary["currentlyDefending"] as Dictionary <string, object>; if (dictionary3 == null) { currentPlayer.CurrentlyDefending = false; } else { currentPlayer.CurrentlyDefendingExpireTime = Convert.ToUInt32(dictionary3["expiration"]); if (currentPlayer.CurrentlyDefendingExpireTime > ServerTime.Time) { currentPlayer.CurrentlyDefending = true; } else { currentPlayer.CurrentlyDefending = false; } } } else { currentPlayer.CurrentlyDefending = false; } if (dictionary.ContainsKey("pushRewarded")) { currentPlayer.IsPushIncentivized = (bool)dictionary["pushRewarded"]; } if (dictionary.ContainsKey("playerModel")) { Dictionary <string, object> dictionary4 = dictionary["playerModel"] as Dictionary <string, object>; FactionType faction = StringUtils.ParseEnum <FactionType>(dictionary4["faction"].ToString()); currentPlayer.Faction = faction; currentPlayer.Map.FromObject(dictionary4["map"]); currentPlayer.BattleHistory.FromObject(dictionary4["battleLogs"]); if (dictionary4.ContainsKey("currentQuest")) { currentPlayer.RestoredQuest = (dictionary4["currentQuest"] as string); } currentPlayer.SpecOpIntros = new List <string>(); if (dictionary4.ContainsKey("intros")) { List <object> list = dictionary4["intros"] as List <object>; int i = 0; int count = list.Count; while (i < count) { currentPlayer.SpecOpIntros.Add(list[i] as string); i++; } } if (dictionary4.ContainsKey("protectedUntil")) { currentPlayer.ProtectedUntil = Convert.ToUInt32(dictionary4["protectedUntil"]); } if (dictionary4.ContainsKey("protectionFrom")) { currentPlayer.ProtectionFrom = Convert.ToUInt32(dictionary4["protectionFrom"]); } if (dictionary4.ContainsKey("protectionCooldownUntil")) { Dictionary <string, object> dictionary5 = dictionary4["protectionCooldownUntil"] as Dictionary <string, object>; if (dictionary5 != null) { foreach (KeyValuePair <string, object> current in dictionary5) { currentPlayer.AddProtectionCooldownUntil(current.Key, Convert.ToUInt32(current.Value)); } } } Dictionary <string, object> dictionary6 = dictionary4["inventory"] as Dictionary <string, object>; if (dictionary6 != null && dictionary6.ContainsKey("capacity") && dictionary6["capacity"] != null) { currentPlayer.Inventory.FromObject(dictionary4["inventory"]); } if (dictionary4.ContainsKey("prizes")) { currentPlayer.Prizes.FromObject(dictionary4["prizes"]); } currentPlayer.CampaignProgress.FromObject(dictionary4); currentPlayer.TournamentProgress.FromObject(dictionary4); SquadStateManager stateManager = Service.SquadController.StateManager; if (dictionary4.ContainsKey("guildInfo")) { Dictionary <string, object> dictionary7 = dictionary4["guildInfo"] as Dictionary <string, object>; if (dictionary7 != null && dictionary7.ContainsKey("guildId")) { string squadID = Convert.ToString(dictionary7["guildId"]); currentPlayer.Squad = Service.LeaderboardController.GetOrCreateSquad(squadID); currentPlayer.Squad.FromLoginObject(dictionary7); if (dictionary7.ContainsKey("joinDate")) { stateManager.JoinDate = Convert.ToUInt32(dictionary7["joinDate"]); } } } if (dictionary.ContainsKey("lastTroopRequestTime")) { stateManager.TroopRequestDate = Convert.ToUInt32(dictionary["lastTroopRequestTime"]); } if (dictionary.ContainsKey("lastWarTroopRequestTime")) { stateManager.WarTroopRequestDate = Convert.ToUInt32(dictionary["lastWarTroopRequestTime"]); } if (dictionary4.ContainsKey("donatedTroops")) { stateManager.Troops = SquadUtils.GetSquadDonatedTroopsFromObject(dictionary4["donatedTroops"]); } if (dictionary4.ContainsKey("deviceInfo")) { Dictionary <string, object> dictionary8 = dictionary4["deviceInfo"] as Dictionary <string, object>; if (dictionary8 != null && dictionary8.Count > 0) { PlayerSettings.SetNotificationsLevel(100); } } if (dictionary4.ContainsKey("contracts")) { Service.ISupportController.UpdateCurrentContractsListFromServer(dictionary4["contracts"]); } if (dictionary4.ContainsKey("unlockedPlanets")) { currentPlayer.UpdateUnlockedPlanetsFromServer(dictionary4["unlockedPlanets"]); } if (dictionary4.ContainsKey("playerObjectives")) { currentPlayer.Objectives.Clear(); Dictionary <string, object> dictionary9 = dictionary4["playerObjectives"] as Dictionary <string, object>; if (dictionary9 != null) { foreach (KeyValuePair <string, object> current2 in dictionary9) { currentPlayer.Objectives.Add(current2.Key, new ObjectiveGroup(current2.Key).FromObject(current2.Value) as ObjectiveGroup); } } } if (dictionary4.ContainsKey("perksInfo")) { currentPlayer.UpdatePerksInfo(dictionary4["perksInfo"]); } if (dictionary4.ContainsKey("episodeProgressInfo")) { currentPlayer.UpdateEpisodeProgressInfo(dictionary4["episodeProgressInfo"]); } if (dictionary4.ContainsKey("mcaInfo")) { currentPlayer.UpdateMobileConnectorAdsInfo(dictionary4["mcaInfo"]); } if (dictionary4.ContainsKey("activeArmory")) { currentPlayer.UpdateActiveArmory(dictionary4["activeArmory"]); } if (dictionary4.ContainsKey("armoryInfo")) { currentPlayer.UpdateArmoryInfo(dictionary4["armoryInfo"]); } if (dictionary4.ContainsKey("shards")) { currentPlayer.UpdateShardsInfo(dictionary4["shards"]); } if (dictionary4.ContainsKey("troopDonationProgress")) { currentPlayer.SetTroopDonationProgress(dictionary4["troopDonationProgress"]); } if (dictionary4.ContainsKey("raids")) { currentPlayer.UpdateCurrentRaid(dictionary4["raids"]); } if (dictionary4.ContainsKey("holonetRewards")) { currentPlayer.UpdateHolonetRewardsFromServer(dictionary4["holonetRewards"]); } if (dictionary4.ContainsKey("relocationStarCount")) { currentPlayer.SetRelocationStartsCount(Convert.ToInt32(dictionary4["relocationStarCount"])); } if (dictionary4.ContainsKey("frozenBuildings")) { Service.ISupportController.UpdateFrozenBuildingsListFromServer(dictionary4["frozenBuildings"]); } currentPlayer.DamagedBuildings = new Dictionary <string, int>(); Dictionary <string, object> dictionary10 = dictionary4["DamagedBuildings"] as Dictionary <string, object>; if (dictionary10 != null) { foreach (KeyValuePair <string, object> current3 in dictionary10) { currentPlayer.DamagedBuildings.Add(current3.Key, Convert.ToInt32(current3.Value)); } } if (dictionary4.ContainsKey("upgrades")) { currentPlayer.UnlockedLevels.FromObject(dictionary4["upgrades"]); } if (dictionary4.ContainsKey("isConnectedAccount")) { currentPlayer.IsConnectedAccount = (bool)dictionary4["isConnectedAccount"]; } if (dictionary4.ContainsKey("isRateIncentivized")) { currentPlayer.IsRateIncentivized = (bool)dictionary4["isRateIncentivized"]; } if (dictionary4.ContainsKey("lastWarParticipationTime")) { currentPlayer.LastWarParticipationTime = Convert.ToUInt32(dictionary4["lastWarParticipationTime"]); } if (dictionary4.ContainsKey("identitySwitchTimes")) { Dictionary <string, object> dictionary11 = dictionary4["identitySwitchTimes"] as Dictionary <string, object>; if (dictionary11 != null) { currentPlayer.NumIdentities = dictionary11.Count; } } if (dictionary4.ContainsKey("openOffer")) { Dictionary <string, object> dictionary12 = dictionary4["openOffer"] as Dictionary <string, object>; if (dictionary12 != null && dictionary12.ContainsKey("offerUid")) { currentPlayer.OfferId = Convert.ToString(dictionary12["offerUid"]); currentPlayer.TriggerDate = Convert.ToUInt32(dictionary12["triggerDate"]); } } if (dictionary4.ContainsKey("lastPaymentTime")) { currentPlayer.LastPaymentTime = Convert.ToUInt32(dictionary4["lastPaymentTime"]); } } if (dictionary.ContainsKey("liveness")) { Dictionary <string, object> dictionary13 = dictionary["liveness"] as Dictionary <string, object>; if (dictionary13 != null) { if (dictionary13.ContainsKey("lastLoginTime")) { string pref = serverPlayerPrefs.GetPref(ServerPref.LastLoginTime); uint loginTime = Convert.ToUInt32(dictionary13["lastLoginTime"]); if (!string.IsNullOrEmpty(pref)) { currentPlayer.LastLoginTime = Convert.ToUInt32(pref); } currentPlayer.LoginTime = loginTime; serverPlayerPrefs.SetPref(ServerPref.LastLoginTime, loginTime.ToString()); } if (dictionary13.ContainsKey("sessionCountToday")) { int sessionCountToday = Convert.ToInt32(dictionary13["sessionCountToday"]); currentPlayer.SessionCountToday = sessionCountToday; } if (dictionary13.ContainsKey("installDate")) { currentPlayer.InstallDate = Convert.ToUInt32(dictionary13["installDate"]); } } } currentPlayer.AbTests = new Dictionary <string, object>(); if (dictionary.ContainsKey("abTests")) { Dictionary <string, object> dictionary14 = dictionary["abTests"] as Dictionary <string, object>; if (dictionary14 != null) { foreach (KeyValuePair <string, object> current4 in dictionary14) { if (!(current4.Key == "#comment")) { currentPlayer.AbTests[current4.Key] = current4.Value; } } } } return(this); }