public void OnViewClockTime(float dt) { bool flag = false; int i = 0; int count = this.rewardsGrid.Count; while (i < count) { UXElement item = this.rewardsGrid.GetItem(i); PlanetLootEntryVO lootEntry = (PlanetLootEntryVO)item.Tag; if (this.DoesLootEntryHaveCountdown(lootEntry)) { flag = true; this.UpdateTimeRemainingLabel(lootEntry); } i++; } if (!flag) { Service.Get <ViewTimeEngine>().UnregisterClockTimeObserver(this); this.RefreshGrid(); } this.currentPlanet.UpdateThrashingPopulation(dt); this.forcesCountLabel.Text = this.currentPlanet.ThrashingPopulation.ToString(); }
private void UpdateTimeRemainingLabel(PlanetLootEntryVO lootEntry) { UXLabel subElement = this.rewardsGrid.GetSubElement <UXLabel>(lootEntry.Uid, "LabelRewardTypeLootTimer"); int totalSeconds = (int)((long)lootEntry.HideDateTimeStamp - (long)((ulong)ServerTime.Time)); subElement.Text = Service.Get <Lang>().Get("PLANET_INFO_ITEM_TIMER", new object[] { GameUtils.GetTimeLabelFromSeconds(totalSeconds) }); }
private bool IsPlanetLootEntryValidToShow(CurrentPlayer player, PlanetLootEntryVO lootEntry) { int num = player.Map.FindHighestHqLevel(); if (lootEntry.MinHQ > 0 && num < lootEntry.MinHQ) { return(false); } if (lootEntry.MaxHQ > 0 && num > lootEntry.MaxHQ) { return(false); } int time = (int)ServerTime.Time; return(lootEntry.ShowDateTimeStamp <= time && (lootEntry.HideDateTimeStamp <= 0 || time < lootEntry.HideDateTimeStamp)); }
public List <PlanetLootEntryVO> GetFeaturedLootEntriesForEpisodeTask(EpisodeTaskVO vo, int maxEntries) { StaticDataController staticDataController = Service.StaticDataController; CurrentPlayer currentPlayer = Service.CurrentPlayer; List <PlanetLootEntryVO> list = new List <PlanetLootEntryVO>(); string[] array; if (currentPlayer.Faction == FactionType.Empire) { array = vo.EmpireRewardItemIds; } else { array = vo.RebelRewardItemIds; } if (array == null) { return(list); } int i = 0; int num = array.Length; while (i < num) { PlanetLootEntryVO optional = staticDataController.GetOptional <PlanetLootEntryVO>(array[i]); if (optional == null) { Service.Logger.ErrorFormat("Couldn't find PlanetLootEntryVO: {0} specified in EpisodeTaskVO: {1}", new object[] { array[i], vo.Uid }); } else if (this.IsPlanetLootEntryValidToShow(currentPlayer, optional)) { list.Add(optional); if (list.Count >= maxEntries) { break; } } i++; } return(list); }
private void SetupLockedRewardItemElements(string itemUID, PlanetLootEntryVO lootEntry) { UXSprite subElement = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteLockIcon"); UXSprite subElement2 = this.rewardsGrid.GetSubElement <UXSprite>(itemUID, "SpriteDimLock"); UXLabel subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(itemUID, "LabelEquipmentRequirement"); subElement.Visible = false; subElement2.Visible = false; subElement3.Visible = false; bool flag = lootEntry.ReqArmory && !ArmoryUtils.PlayerHasArmory(); if (flag) { subElement2.Visible = true; subElement.Visible = true; subElement3.Visible = true; subElement3.Text = this.lang.Get("EQUIPMENT_ARMORY_REQUIRED", new object[0]); } }
public List <PlanetLootEntryVO> GetFeaturedLootEntriesForPlanet(Planet currentPlanet) { IDataController dataController = Service.Get <IDataController>(); CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); List <PlanetLootEntryVO> list = new List <PlanetLootEntryVO>(); PlanetLootVO planetLootVO = dataController.Get <PlanetLootVO>(currentPlanet.VO.PlanetLootUid); string[] array; if (currentPlayer.Faction == FactionType.Empire) { array = planetLootVO.EmpirePlanetLootEntryUids; } else { array = planetLootVO.RebelPlanetLootEntryUids; } int i = 0; int num = array.Length; while (i < num) { PlanetLootEntryVO optional = dataController.GetOptional <PlanetLootEntryVO>(array[i]); if (optional == null) { Service.Get <StaRTSLogger>().ErrorFormat("Couldn't find PlanetLootEntryVO: {0} specified in PlanetLoot: {1}", new object[] { array[i], currentPlanet.VO.PlanetLootUid }); } else if (this.IsPlanetLootEntryValidToShow(currentPlayer, optional)) { list.Add(optional); if (list.Count >= GameConstants.PLANET_REWARDS_ITEM_THROTTLE) { break; } } i++; } return(list); }
private int SortFeaturedLootEntries(PlanetLootEntryVO vo1, PlanetLootEntryVO vo2) { return(string.Compare(vo1.Uid, vo2.Uid)); }
private bool DoesLootEntryHaveCountdown(PlanetLootEntryVO lootEntry) { int time = (int)ServerTime.Time; return(lootEntry.ShowDateTimeStamp <= time && (lootEntry.HideDateTimeStamp > 0 && time < lootEntry.HideDateTimeStamp)); }
private void AddFeaturedRewardItemToGrid(PlanetLootEntryVO lootEntry, int order) { IDataController dataController = Service.Get <IDataController>(); InventoryCrateRewardController inventoryCrateRewardController = Service.Get <InventoryCrateRewardController>(); Lang lang = Service.Get <Lang>(); CrateSupplyVO optional = dataController.GetOptional <CrateSupplyVO>(lootEntry.SupplyDataUid); if (optional == null) { Service.Get <StaRTSLogger>().ErrorFormat("Couldn't find CrateSupplyVO: {0} specified in PlanetLootEntryVO: {1}", new object[] { lootEntry.SupplyDataUid, lootEntry.Uid }); return; } string uid = lootEntry.Uid; UXElement uXElement = this.rewardsGrid.CloneTemplateItem(uid); uXElement.Tag = lootEntry; UXLabel subElement = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardName"); subElement.Text = inventoryCrateRewardController.GetCrateSupplyRewardName(optional); UXUtils.ClampUILabelWidth(subElement, 200, 0); UXLabel subElement2 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelGate"); subElement2.Text = string.Empty; if (!string.IsNullOrEmpty(lootEntry.NotesString)) { subElement2.Text = lang.Get(lootEntry.NotesString, new object[0]); UXUtils.ClampUILabelWidth(subElement2, 200, 0); } for (int i = 1; i <= 3; i++) { string name = string.Format("RewardItemCardQ{0}", new object[] { i }); this.rewardsGrid.GetSubElement <UXElement>(uid, name).Visible = false; } this.rewardsGrid.GetSubElement <UXElement>(uid, "RewardItemDefault").Visible = false; this.rewardsGrid.GetSubElement <UXElement>(uid, "pBarRewardItemFrag").Visible = false; this.rewardsGrid.GetSubElement <UXElement>(uid, "IconUpgrade").Visible = false; UXLabel subElement3 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardTypeLootTimer"); UXUtils.ClampUILabelWidth(subElement3, 200, 0); bool flag = this.DoesLootEntryHaveCountdown(lootEntry); subElement3.Visible = flag; if (flag) { this.UpdateTimeRemainingLabel(lootEntry); } UXButton subElement4 = this.rewardsGrid.GetSubElement <UXButton>(uid, "BtnRewardInfo"); UXButton subElement5 = this.rewardsGrid.GetSubElement <UXButton>(uid, "BtnRewardItemCard"); subElement5.InitTweenComponent(); subElement4.Visible = false; if (optional.Type == SupplyType.Hero || optional.Type == SupplyType.Troop || optional.Type == SupplyType.SpecialAttack || optional.Type == SupplyType.Shard || optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack) { subElement4.Visible = true; subElement4.Tag = optional; subElement4.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); subElement5.Tag = optional; subElement5.OnClicked = new UXButtonClickedDelegate(this.OnInfoButtonClicked); } else { subElement5.DisablePlayTween(); } UXLabel subElement6 = this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelRewardTypeLootTable"); subElement6.Visible = true; this.rewardsGrid.GetSubElement <UXSprite>(uid, "SpriteIconFragmentLootTable").Visible = false; if (optional.Type == SupplyType.ShardTroop || optional.Type == SupplyType.ShardSpecialAttack) { this.SetupShardRewardItemElements(uid, optional); } else if (optional.Type == SupplyType.Shard) { this.SetupEquipmentShardRewardItemElements(uid, optional); } else { this.rewardsGrid.GetSubElement <UXElement>(uid, "RewardItemDefault").Visible = true; this.rewardsGrid.GetSubElement <UXLabel>(uid, "LabelFragProgress").Text = string.Empty; UXSprite subElement7 = this.rewardsGrid.GetSubElement <UXSprite>(uid, "SpriteRewardItemImage"); IGeometryVO geometryVO = null; if (optional.Type == SupplyType.Currency) { subElement6.Visible = false; geometryVO = UXUtils.GetDefaultCurrencyIconVO(optional.RewardUid); } else if (optional.Type == SupplyType.Hero || optional.Type == SupplyType.Troop) { geometryVO = dataController.Get <TroopTypeVO>(optional.RewardUid); } else if (optional.Type == SupplyType.SpecialAttack) { geometryVO = dataController.Get <SpecialAttackTypeVO>(optional.RewardUid); } if (geometryVO != null) { ProjectorConfig config = ProjectorUtils.GenerateGeometryConfig(geometryVO, subElement7, false); GeometryProjector item = ProjectorUtils.GenerateProjector(config); this.projectors.Add(item); } } this.SetupLockedRewardItemElements(uid, lootEntry); if (subElement6.Visible) { string typeStringID = lootEntry.TypeStringID; if (!string.IsNullOrEmpty(typeStringID)) { subElement6.Visible = true; subElement6.Text = lang.Get(typeStringID, new object[0]); } else { subElement6.Visible = false; } } subElement6.InitTweenComponent(); subElement3.InitTweenComponent(); if (flag && subElement6.Visible) { subElement6.EnablePlayTween(); subElement3.EnablePlayTween(); } else { subElement6.ResetPlayTweenTarget(); subElement3.ResetPlayTweenTarget(); subElement6.TextColor = Color.white; subElement3.TextColor = Color.white; } this.rewardsGrid.AddItem(uXElement, order); }