Exemple #1
0
        private void AddFilterData(PerkVO perkData, UXElement perkItem, ref List <UXElement> sortList)
        {
            string[] filterTabs = perkData.FilterTabs;
            int      num        = filterTabs.Length;

            for (int i = 0; i < num; i++)
            {
                string text = filterTabs[i];
                if (!this.filterMap.ContainsKey(text))
                {
                    this.filterMap.Add(text, new List <UXElement>());
                    UXElement item = this.CreateFilterTab(text);
                    sortList.Add(item);
                }
                this.filterMap[text].Add(perkItem);
            }
        }
Exemple #2
0
        private static List <CurrencyPerkEffectDataTO> GetAllCurrencyPerksEffectsActiveDuringTimeWindow(CurrencyType type, uint startTime, uint endTime, List <ActivatedPerkData> allPerks)
        {
            StaticDataController            staticDataController = Service.StaticDataController;
            List <CurrencyPerkEffectDataTO> result = new List <CurrencyPerkEffectDataTO>();
            int count = allPerks.Count;

            for (int i = 0; i < count; i++)
            {
                ActivatedPerkData activatedPerkData = allPerks[i];
                if (ResourceGenerationPerkUtils.IsPerkActiveDuringTimeWindow(activatedPerkData, startTime, endTime))
                {
                    PerkVO perkData = staticDataController.Get <PerkVO>(activatedPerkData.PerkId);
                    ResourceGenerationPerkUtils.AddEffectsOfMatchingCurrencyType(perkData, type, activatedPerkData.StartTime, activatedPerkData.EndTime, ref result);
                }
            }
            return(result);
        }
Exemple #3
0
        public bool HasPrerequistesUnlocked(PerkVO perk, Dictionary <string, string> availablePerks)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            bool   result    = false;
            string perkGroup = perk.PerkGroup;

            if (availablePerks.ContainsKey(perkGroup))
            {
                PerkVO perkVO = staticDataController.Get <PerkVO>(availablePerks[perkGroup]);
                result = (perk.PerkTier == perkVO.PerkTier + 1);
            }
            else if (perk.PerkTier == 1)
            {
                result = true;
            }
            return(result);
        }
Exemple #4
0
        public List <string> GetPerkEffectIds(List <string> perkIds)
        {
            List <string> list = new List <string>();

            if (perkIds != null)
            {
                StaticDataController staticDataController = Service.StaticDataController;
                int i     = 0;
                int count = perkIds.Count;
                while (i < count)
                {
                    PerkVO perkVO = staticDataController.Get <PerkVO>(perkIds[i]);
                    list.AddRange(perkVO.PerkEffects);
                    i++;
                }
            }
            return(list);
        }
        private void OnPerkButtonClicked(UXButton button)
        {
            if (base.ShouldBlockInput())
            {
                return;
            }
            PerkViewController perkViewController = Service.Get <PerkViewController>();
            PerkVO             perkVO             = (PerkVO)button.Tag;
            string             perkGroup          = perkVO.PerkGroup;

            if (perkViewController.IsPerkGroupBadged(perkGroup))
            {
                perkViewController.RemovePerkGroupFromBadgeList(perkGroup);
                this.screen.UpdateBadges();
            }
            Service.Get <EventManager>().SendEvent(EventId.PerkSelected, null);
            this.ShowActivationView(perkVO, true);
        }
Exemple #6
0
        private void OnPerkClicked(UXButton btn)
        {
            if (base.ShouldBlockInput())
            {
                return;
            }
            PerkViewController perkViewController = Service.PerkViewController;
            PerkVO             perkVO             = (PerkVO)btn.Tag;
            string             perkGroup          = perkVO.PerkGroup;

            if (perkViewController.IsPerkGroupBadged(perkGroup))
            {
                perkViewController.RemovePerkGroupFromBadgeList(perkGroup);
                this.screen.UpdateBadges();
            }
            this.ShowConfirmUpgradeView(perkVO);
            Service.EventManager.SendEvent(EventId.PerkSelected, null);
        }
Exemple #7
0
        private void AddPerkToGrid(ActivatedPerkData perkData)
        {
            string             perkId             = perkData.PerkId;
            PerkViewController perkViewController = Service.PerkViewController;
            PerkVO             perkVO             = Service.StaticDataController.Get <PerkVO>(perkId);
            UXElement          uXElement          = this.perksGrid.CloneTemplateItem(perkId);

            uXElement.Tag = perkData;
            UXLabel subElement = this.perksGrid.GetSubElement <UXLabel>(perkId, "LabelPerkTitleModalActivePerks");

            subElement.Text = perkViewController.GetPerkNameForGroup(perkVO.PerkGroup);
            UXTexture subElement2 = this.perksGrid.GetSubElement <UXTexture>(perkId, "TexturePerkArtModalActivePerks");

            perkViewController.SetPerkImage(subElement2, perkVO);
            UXLabel subElement3 = this.perksGrid.GetSubElement <UXLabel>(perkId, "LabelPerkLvlModalActivePerks");

            subElement3.Text = StringUtils.GetRomanNumeral(perkVO.PerkTier);
            UXLabel subElement4 = this.perksGrid.GetSubElement <UXLabel>(perkId, "ItemLabelModalActivePerks");

            subElement4.Visible = false;
            UXGrid subElement5 = this.perksGrid.GetSubElement <UXGrid>(perkId, "GridSubModalActivePerks");

            subElement5.SetTemplateItem("ItemLabelModalActivePerks");
            subElement5.Clear();
            PerkManager perkManager = Service.PerkManager;
            int         i           = 0;
            int         num         = perkVO.PerkEffects.Length;

            while (i < num)
            {
                string       text         = perkVO.PerkEffects[i];
                PerkEffectVO perkEffectVO = Service.StaticDataController.Get <PerkEffectVO>(text);
                UXLabel      uXLabel      = (UXLabel)subElement5.CloneTemplateItem(text);
                uXLabel.Text = this.lang.Get(perkEffectVO.StatStringId, new object[0]) + Service.PerkViewController.GetFormattedValueBasedOnEffectType(perkEffectVO, null);
                if (!perkManager.IsPerkEffectAppliedToBuilding(perkEffectVO, this.buildingVO))
                {
                    uXLabel.TextColor = UXUtils.COLOR_PERK_EFFECT_NOT_APPLIED;
                }
                subElement5.AddItem(uXLabel, i);
                i++;
            }
            this.UpdatePerkTimer(uXElement);
            this.perksGrid.AddItem(uXElement, 1);
        }
Exemple #8
0
        private int SortUpgradeList(UXElement a, UXElement b)
        {
            PerkManager perkManager = Service.PerkManager;
            Squad       squad       = Service.CurrentPlayer.Squad;
            Dictionary <string, string> available = squad.Perks.Available;
            int    level   = squad.Level;
            PerkVO perkVO  = (PerkVO)a.Tag;
            PerkVO perkVO2 = (PerkVO)b.Tag;
            int    num     = perkVO.SortOrder;
            int    num2    = perkVO2.SortOrder;

            if (perkManager.IsPerkLevelLocked(perkVO, level) && perkManager.IsPerkLevelLocked(perkVO2, level))
            {
                num  = perkVO.SquadLevelUnlock;
                num2 = perkVO2.SquadLevelUnlock;
            }
            if (perkManager.IsPerkMaxTier(perkVO) && available.ContainsValue(perkVO.Uid))
            {
                num += 20000;
            }
            else if (perkManager.IsPerkLevelLocked(perkVO, level))
            {
                num += 10000;
            }
            if (!a.Visible)
            {
                num += 40000;
            }
            if (perkManager.IsPerkMaxTier(perkVO2) && available.ContainsValue(perkVO2.Uid))
            {
                num2 += 20000;
            }
            else if (perkManager.IsPerkLevelLocked(perkVO2, level))
            {
                num2 += 10000;
            }
            if (!b.Visible)
            {
                num2 += 40000;
            }
            return(num - num2);
        }
Exemple #9
0
        public void SetupStatGridForPerk(PerkVO targetPerkVO, UXGrid statGrid, string templateElement, string descriptionElement, string valueElement, bool useUpgrade)
        {
            Lang lang = Service.Lang;
            StaticDataController staticDataController = Service.StaticDataController;

            string[] array       = null;
            string[] perkEffects = targetPerkVO.PerkEffects;
            int      num         = perkEffects.Length;

            statGrid.SetTemplateItem(templateElement);
            string perkGroup = targetPerkVO.PerkGroup;
            int    perkTier  = targetPerkVO.PerkTier;

            if (useUpgrade && perkTier > 1)
            {
                PerkVO perkByGroupAndTier = GameUtils.GetPerkByGroupAndTier(perkGroup, perkTier - 1);
                array = perkByGroupAndTier.PerkEffects;
                if (perkEffects.Length != num)
                {
                    Service.Logger.Error("PerkEffects list not consistent between " + perkByGroupAndTier.Uid + " and " + targetPerkVO.Uid);
                }
            }
            statGrid.Clear();
            for (int i = 0; i < num; i++)
            {
                PerkEffectVO perkEffectVO = staticDataController.Get <PerkEffectVO>(perkEffects[i]);
                PerkEffectVO prevVO       = null;
                if (array != null)
                {
                    prevVO = staticDataController.Get <PerkEffectVO>(array[i]);
                }
                string    itemUid     = perkEffectVO.Uid + i;
                UXElement item        = statGrid.CloneTemplateItem(itemUid);
                UXLabel   subElement  = statGrid.GetSubElement <UXLabel>(itemUid, descriptionElement);
                UXLabel   subElement2 = statGrid.GetSubElement <UXLabel>(itemUid, valueElement);
                subElement.Text  = lang.Get(perkEffectVO.StatStringId, new object[0]);
                subElement2.Text = this.GetFormattedValueBasedOnEffectType(perkEffectVO, prevVO);
                statGrid.AddItem(item, i);
            }
            statGrid.RepositionItems();
        }
Exemple #10
0
        private List <string> GetListOfBadgedPerkGroups()
        {
            Squad currentSquad = Service.SquadController.StateManager.GetCurrentSquad();

            if (currentSquad == null)
            {
                return(null);
            }
            Dictionary <string, string> available = currentSquad.Perks.Available;
            int               level             = currentSquad.Level;
            PerkManager       perkManager       = Service.PerkManager;
            SharedPlayerPrefs sharedPlayerPrefs = Service.SharedPlayerPrefs;
            string            pref = sharedPlayerPrefs.GetPref <string>("perk_badges");

            if (!string.IsNullOrEmpty(pref))
            {
                List <string> list  = new List <string>();
                string[]      array = pref.Split(new char[]
                {
                    ' '
                });
                int num = array.Length;
                for (int i = 0; i < num; i++)
                {
                    string text = array[i];
                    if (available.ContainsKey(text))
                    {
                        PerkVO perkData = Service.StaticDataController.Get <PerkVO>(available[text]);
                        if (!perkManager.IsPerkLevelLocked(perkData, level) && !perkManager.IsPerkReputationLocked(perkData, level, available))
                        {
                            if (!perkManager.IsPerkGroupActive(text) && !perkManager.IsPerkGroupInCooldown(text))
                            {
                                list.Add(text);
                            }
                        }
                    }
                }
                return(list);
            }
            return(null);
        }
        public override EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.ActivePerksUpdated:
            case EventId.SquadPerkUpdated:
            case EventId.SquadLeveledUp:
                this.RefreshPerkStates();
                break;

            case EventId.PerkUnlocked:
            case EventId.PerkUpgraded:
                if (this.activationInfoView != null)
                {
                    PerkViewController perkViewController = Service.Get <PerkViewController>();
                    PerkVO             perkVO             = (PerkVO)cookie;
                    string             perkGroup          = perkVO.PerkGroup;
                    if (perkViewController.IsPerkGroupBadged(perkGroup))
                    {
                        this.CleanUpActivationInfoView();
                        perkViewController.RemovePerkGroupFromBadgeList(perkGroup);
                        this.screen.UpdateBadges();
                        Service.Get <ViewTimerManager>().CreateViewTimer(this.TIME_DELAY_TO_SHOW_CELEB, false, new TimerDelegate(this.ShowCelebAfterDelay), cookie);
                        return(EatResponse.NotEaten);
                    }
                }
                break;

            case EventId.PerkCelebClosed:
                this.ResetVisibilityStates();
                this.RefreshPerkStates();
                break;

            case EventId.PerkActivationClosed:
                this.activationInfoView = null;
                this.ResetVisibilityStates();
                this.RefreshPerkStates();
                break;
            }
            return(base.OnEvent(id, cookie));
        }
Exemple #12
0
        public bool IsPerkInCooldown(ActivatedPerkData playerPerk)
        {
            if (playerPerk == null)
            {
                return(false);
            }
            StaticDataController staticDataController = Service.StaticDataController;
            PerkVO perkVO    = staticDataController.Get <PerkVO>(playerPerk.PerkId);
            string perkGroup = perkVO.PerkGroup;
            Dictionary <string, uint> playerPerkGroupCooldowns = this.GetPlayerPerkGroupCooldowns();

            if (playerPerkGroupCooldowns == null || !playerPerkGroupCooldowns.ContainsKey(perkGroup))
            {
                return(false);
            }
            uint endTime = playerPerk.EndTime;
            uint num     = playerPerkGroupCooldowns[perkGroup];
            uint time    = ServerTime.Time;

            return(endTime <= time && num > time);
        }
Exemple #13
0
        public List <SmartEntity> GetBuildingsForPerk(PerkVO perkVO)
        {
            List <SmartEntity> list = new List <SmartEntity>();

            string[] perkEffects = perkVO.PerkEffects;
            if (perkEffects != null)
            {
                StaticDataController staticDataController = Service.StaticDataController;
                int i   = 0;
                int num = perkEffects.Length;
                while (i < num)
                {
                    PerkEffectVO       perkEffectVO       = staticDataController.Get <PerkEffectVO>(perkEffects[i]);
                    BuildingType       perkBuilding       = perkEffectVO.PerkBuilding;
                    List <SmartEntity> buildingListByType = Service.BuildingLookupController.GetBuildingListByType(perkBuilding);
                    list.AddRange(buildingListByType);
                    i++;
                }
            }
            return(list);
        }
Exemple #14
0
        private static void AddEffectsOfMatchingCurrencyType(PerkVO perkData, CurrencyType currencyType, uint startTime, uint endTime, ref List <CurrencyPerkEffectDataTO> matchingEffects)
        {
            if (matchingEffects == null)
            {
                Service.Get <StaRTSLogger>().Error("AddEffectsOfMatchingCurrencyType received null vo list");
                return;
            }
            IDataController dataController = Service.Get <IDataController>();

            string[] perkEffects = perkData.PerkEffects;
            int      num         = perkEffects.Length;

            for (int i = 0; i < num; i++)
            {
                PerkEffectVO perkEffectVO = dataController.Get <PerkEffectVO>(perkEffects[i]);
                if (perkEffectVO.Type == "generator" && perkEffectVO.Currency == currencyType)
                {
                    matchingEffects.Add(new CurrencyPerkEffectDataTO(perkEffectVO.GenerationRate, startTime, endTime));
                }
            }
        }
Exemple #15
0
        protected void SetupPerkBadge(PerkVO perkVO, string perkItemID, string jewelId)
        {
            PerkViewController perkViewController = Service.PerkViewController;
            PerkManager        perkManager        = Service.PerkManager;
            bool  flag         = true;
            Squad currentSquad = Service.SquadController.StateManager.GetCurrentSquad();
            int   level        = currentSquad.Level;
            Dictionary <string, string> available = currentSquad.Perks.Available;

            if (perkManager.IsPerkLevelLocked(perkVO, level) || perkManager.IsPerkReputationLocked(perkVO, level, available))
            {
                flag = false;
            }
            string       perkGroup = perkVO.PerkGroup;
            JewelControl jewelControl;

            if (this.perkBadgeMap.ContainsKey(perkGroup))
            {
                jewelControl = this.perkBadgeMap[perkGroup];
            }
            else
            {
                string name = UXUtils.FormatAppendedName(jewelId, perkItemID);
                jewelControl = JewelControl.Create(this.screen, name);
                this.perkBadgeMap.Add(perkGroup, jewelControl);
            }
            if (jewelControl != null)
            {
                bool flag2 = perkViewController.IsPerkGroupBadged(perkVO.PerkGroup);
                if (flag2 && flag)
                {
                    jewelControl.Text = "!";
                }
                else
                {
                    jewelControl.Value = 0;
                }
            }
        }
Exemple #16
0
        private void OnCancelPerkModalResult(object result, object cookie)
        {
            if (result == null)
            {
                return;
            }
            PerkManager perkManager = Service.PerkManager;
            string      text        = cookie as string;
            bool        flag        = perkManager.CancelPlayerPerk(text);

            if (flag)
            {
                PerkVO             perkVO           = Service.StaticDataController.Get <PerkVO>(text);
                List <SmartEntity> buildingsForPerk = perkManager.GetBuildingsForPerk(perkVO);
                int i     = 0;
                int count = buildingsForPerk.Count;
                while (i < count)
                {
                    Service.BuildingController.UpdateBuildingHighlightForPerks(buildingsForPerk[i]);
                    i++;
                }
            }
        }
Exemple #17
0
 public virtual EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.SquadScreenOpenedOrClosed)
     {
         if (id == EventId.PerkUnlocked || id == EventId.PerkUpgraded)
         {
             PerkViewController perkViewController = Service.Get <PerkViewController>();
             PerkVO             perkVO             = (PerkVO)cookie;
             string             perkGroup          = perkVO.PerkGroup;
             if (perkViewController.IsPerkGroupBadged(perkGroup))
             {
                 this.ShowPerkCelebration(perkVO);
                 perkViewController.RemovePerkGroupFromBadgeList(perkGroup);
                 this.screen.UpdateBadges();
             }
         }
     }
     else if (!(bool)cookie)
     {
         this.lastFilterId = null;
     }
     return(EatResponse.NotEaten);
 }
Exemple #18
0
        public ActivatedPerkData GetPlayerPerkForGroup(string perkGroupId)
        {
            List <ActivatedPerkData> playerActivatedPerks = this.GetPlayerActivatedPerks();

            if (playerActivatedPerks == null)
            {
                return(null);
            }
            StaticDataController staticDataController = Service.StaticDataController;
            int i     = 0;
            int count = playerActivatedPerks.Count;

            while (i < count)
            {
                ActivatedPerkData activatedPerkData = playerActivatedPerks[i];
                PerkVO            perkVO            = staticDataController.Get <PerkVO>(activatedPerkData.PerkId);
                if (perkGroupId == perkVO.PerkGroup)
                {
                    return(activatedPerkData);
                }
                i++;
            }
            return(null);
        }
Exemple #19
0
        private void AddUnlockedPerksToGrid()
        {
            this.unlockedItemsGrid.SetTemplateItem("TemplateCard");
            if (this.unlockedPerks == null)
            {
                return;
            }
            PerkViewController perkViewController = Service.Get <PerkViewController>();
            int count = this.unlockedPerks.Count;

            for (int i = 0; i < count; i++)
            {
                PerkVO    perkVO     = this.unlockedPerks[i];
                string    uid        = perkVO.Uid;
                UXElement item       = this.unlockedItemsGrid.CloneTemplateItem(uid);
                UXLabel   subElement = this.unlockedItemsGrid.GetSubElement <UXLabel>(uid, "LabelPerkLvlUpCard");
                subElement.Text = StringUtils.GetRomanNumeral(perkVO.PerkTier);
                UXLabel subElement2 = this.unlockedItemsGrid.GetSubElement <UXLabel>(uid, "LabelPerkTitleUpCard");
                subElement2.Text = perkViewController.GetPerkNameForGroup(perkVO.PerkGroup);
                UXTexture subElement3 = this.unlockedItemsGrid.GetSubElement <UXTexture>(uid, "TexturePerkArtCard");
                perkViewController.SetPerkImage(subElement3, perkVO);
                this.unlockedItemsGrid.AddItem(item, this.unlockedItemsGrid.Count);
            }
        }
Exemple #20
0
        protected override void FilterGridBasedOnId(string filterId)
        {
            base.FilterGridBasedOnId(filterId);
            List <UXElement> list = new List <UXElement>(this.perkGrid.GetElementList());

            this.perkGrid.ClearWithoutDestroy();
            list.Sort(new Comparison <UXElement>(this.SortUpgradeList));
            UXUtils.SortListForTwoRowGrids(list, this.perkGrid);
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                UXElement uXElement = list[i];
                PerkVO    perkVO    = uXElement.Tag as PerkVO;
                string    rootName  = "PerkItem_" + perkVO.PerkGroup;
                uXElement.SetRootName(rootName);
                this.perkGrid.AddItem(uXElement, i);
            }
            List <UXElement> list2 = this.filterMap[filterId];

            this.gridToFilter.MaxItemsPerLine = (list2.Count + 1) / 2;
            this.perkGrid.RepositionItemsFrameDelayed(new UXDragDelegate(base.OnRepositionComplete));
            list.Clear();
        }
Exemple #21
0
        public void SetPerkImage(UXTexture perkImage, PerkVO perkVO)
        {
            FactionType faction = Service.CurrentPlayer.Faction;
            string      text    = string.Empty;

            if (faction == FactionType.Empire)
            {
                text = perkVO.TextureIdEmpire;
            }
            else
            {
                text = perkVO.TextureIdRebel;
            }
            if (!string.IsNullOrEmpty(text))
            {
                StaticDataController staticDataController = Service.StaticDataController;
                TextureVO            optional             = staticDataController.GetOptional <TextureVO>(text);
                if (optional != null && perkImage.Tag != optional)
                {
                    perkImage.LoadTexture(optional.AssetName);
                    perkImage.Tag = optional;
                }
            }
        }
Exemple #22
0
 public bool IsPerkReputationLocked(PerkVO perkData, int squadLevel, Dictionary <string, string> availablePerks)
 {
     return(!this.IsPerkLevelLocked(perkData, squadLevel) && !availablePerks.ContainsKey(perkData.PerkGroup));
 }
        private void ShowCelebAfterDelay(uint timerId, object cookie)
        {
            PerkVO perkData = (PerkVO)cookie;

            base.ShowPerkCelebration(perkData);
        }
        private void RefreshActivePerksGrid()
        {
            if (this.activePerksGrid == null)
            {
                this.activePerksGrid = this.screen.GetElement <UXGrid>("GridActSlotsPerks");
                this.activePerksGrid.SetTemplateItem("TemplateActSlotPerks");
            }
            this.activePerkTimerLabels.Clear();
            IDataController          dataController    = Service.Get <IDataController>();
            Lang                     lang              = Service.Get <Lang>();
            PerkManager              perkManager       = Service.Get <PerkManager>();
            List <ActivatedPerkData> playerActivePerks = perkManager.GetPlayerActivePerks();
            Squad                    currentSquad      = Service.Get <SquadController>().StateManager.GetCurrentSquad();

            if (currentSquad == null)
            {
                return;
            }
            string           squadLevelUIDFromSquad = GameUtils.GetSquadLevelUIDFromSquad(currentSquad);
            int              availableSlotsCount    = perkManager.GetAvailableSlotsCount(squadLevelUIDFromSquad);
            int              squadLevelMax          = perkManager.SquadLevelMax;
            List <UXElement> list = new List <UXElement>();
            int              num  = -1;
            int              i    = 1;
            int              num2 = 0;

            while (i <= squadLevelMax)
            {
                string       squadLevelUIDFromLevel = GameUtils.GetSquadLevelUIDFromLevel(i);
                SquadLevelVO squadLevelVO           = dataController.Get <SquadLevelVO>(squadLevelUIDFromLevel);
                int          slots = squadLevelVO.Slots;
                if (num != slots)
                {
                    bool      flag         = slots > availableSlotsCount;
                    bool      flag2        = num2 < playerActivePerks.Count && !flag;
                    int       level        = squadLevelVO.Level;
                    string    itemUid      = "PerkSlot_" + slots.ToString();
                    UXElement uXElement    = base.FetchPerkGridItem(this.activePerksGrid, itemUid);
                    UXElement subElement   = this.activePerksGrid.GetSubElement <UXElement>(itemUid, "AvailableSlotGroupPerks");
                    UXLabel   subElement2  = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelAvActSlotPerks");
                    UXElement subElement3  = this.activePerksGrid.GetSubElement <UXElement>(itemUid, "ActivatedSlotGroupPerks");
                    UXElement subElement4  = this.activePerksGrid.GetSubElement <UXElement>(itemUid, "LockedSlotGroupPerks");
                    UXLabel   subElement5  = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelPerkTitleActSlotPerks");
                    UXLabel   subElement6  = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelPerkLvlActSlotPerks");
                    UXLabel   subElement7  = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelPerkMessageTimerActSlotPerks");
                    UXLabel   subElement8  = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelPerkTimerActSlotPerks");
                    UXButton  subElement9  = this.activePerksGrid.GetSubElement <UXButton>(itemUid, "BtnRemoveActSlotPerks");
                    UXTexture subElement10 = this.activePerksGrid.GetSubElement <UXTexture>(itemUid, "TexturePerkArtActSlotPerks");
                    UXButton  uXButton     = uXElement as UXButton;
                    if (flag)
                    {
                        uXButton.Enabled    = false;
                        subElement.Visible  = false;
                        subElement4.Visible = true;
                        subElement3.Visible = false;
                        subElement9.Visible = false;
                        UXLabel subElement11 = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelSquadLvlLockedSlotPerks");
                        subElement11.Text = level.ToString();
                        UXLabel subElement12 = this.activePerksGrid.GetSubElement <UXLabel>(itemUid, "LabelSquadLvlLockedSlotPerks");
                        subElement12.Text = lang.Get("PERK_ACTIVATE_UPGRADE_CARD_LVL_REQ", new object[]
                        {
                            level
                        });
                    }
                    else if (flag2)
                    {
                        subElement.Visible  = false;
                        subElement4.Visible = false;
                        subElement3.Visible = true;
                        subElement9.Visible = true;
                        ActivatedPerkData  activatedPerkData  = playerActivePerks[num2++];
                        string             perkId             = activatedPerkData.PerkId;
                        PerkViewController perkViewController = Service.Get <PerkViewController>();
                        PerkVO             perkVO             = dataController.Get <PerkVO>(perkId);
                        subElement5.Text = perkViewController.GetPerkNameForGroup(perkVO.PerkGroup);
                        subElement6.Text = StringUtils.GetRomanNumeral(perkVO.PerkTier);
                        perkViewController.SetPerkImage(subElement10, perkVO);
                        subElement7.Text = lang.Get("PERK_ACTIVE_SLOT_ACTIVE_TIMER_DESC", new object[0]);
                        this.UpdateLabelTimeRemaining(subElement8, lang, "PERK_ACTIVE_SLOT_ACTIVE_TIMER", activatedPerkData.EndTime);
                        subElement8.Tag = activatedPerkData;
                        this.activePerkTimerLabels.Add(subElement8);
                        uXButton.Enabled      = true;
                        uXButton.Tag          = perkVO;
                        uXButton.OnClicked    = new UXButtonClickedDelegate(this.OnPerkSlotButtonClicked);
                        subElement9.Tag       = perkId;
                        subElement9.Visible   = true;
                        subElement9.OnClicked = new UXButtonClickedDelegate(this.OnRemoveButtonClicked);
                    }
                    else
                    {
                        uXButton.Enabled    = false;
                        subElement4.Visible = false;
                        subElement3.Visible = false;
                        subElement9.Visible = false;
                        subElement.Visible  = true;
                        subElement2.Text    = lang.Get("PERK_ACTIVE_SLOT_TITLE", new object[0]);
                    }
                    list.Add(uXElement);
                    num = slots;
                }
                i++;
            }
            this.activePerksGrid.ClearWithoutDestroy();
            int j     = 0;
            int count = list.Count;

            while (j < count)
            {
                this.activePerksGrid.AddItem(list[j], j);
                j++;
            }
            this.activePerksGrid.RepositionItems();
            list.Clear();
        }
        protected override bool CanShowGridItem(UXElement item)
        {
            PerkVO perkVO = (PerkVO)item.Tag;

            return((perkVO == null || !Service.Get <PerkManager>().IsPerkGroupActive(perkVO.PerkGroup)) && base.CanShowGridItem(item));
        }
Exemple #26
0
 public bool IsPerkLevelLocked(PerkVO perkData, int squadLevel)
 {
     return(squadLevel < perkData.SquadLevelUnlock);
 }
Exemple #27
0
 public SquadScreenUpgradeCelebPerkInfoView(SquadSlidingScreen screen, PerkVO targetPerkVO) : base(screen, targetPerkVO)
 {
     this.InitUI();
 }
Exemple #28
0
        public bool ActivatePlayerPerk(string targetPerkId, Dictionary <string, string> availablePerks, string guildLevelUid)
        {
            StaticDataController staticDataController = Service.StaticDataController;
            PerkVO perkVO    = staticDataController.Get <PerkVO>(targetPerkId);
            string perkGroup = perkVO.PerkGroup;

            if (!this.HasEmptyPerkActivationSlot(guildLevelUid))
            {
                return(false);
            }
            if (availablePerks == null || !availablePerks.ContainsValue(targetPerkId))
            {
                string message = "Perk not activated, not in available perks, perkId: " + targetPerkId;
                this.logger.ErrorFormat(message, new object[0]);
                return(false);
            }
            List <ActivatedPerkData>  playerActivatedPerks     = this.GetPlayerActivatedPerks();
            Dictionary <string, uint> playerPerkGroupCooldowns = this.GetPlayerPerkGroupCooldowns();

            if (this.IsPerkActive(targetPerkId))
            {
                ActivatedPerkData playerPerk = this.GetPlayerPerk(targetPerkId);
                string            message2   = string.Concat(new object[]
                {
                    "Perk not activated, perk already active, perkId: ",
                    targetPerkId,
                    " startTime: ",
                    playerPerk.StartTime,
                    " endTime: ",
                    playerPerk.EndTime
                });
                this.logger.ErrorFormat(message2, new object[0]);
                return(false);
            }
            if (this.IsPerkInCooldown(targetPerkId))
            {
                ActivatedPerkData playerPerk2 = this.GetPlayerPerk(targetPerkId);
                string            message3    = string.Concat(new object[]
                {
                    "Perk not activated, perk in cooldown, perkId: ",
                    targetPerkId,
                    " startTime: ",
                    playerPerk2.StartTime,
                    " endTime: ",
                    playerPerk2.EndTime,
                    " cooldownEndTime: ",
                    playerPerkGroupCooldowns[perkGroup]
                });
                this.logger.ErrorFormat(message3, new object[0]);
                return(false);
            }
            this.CleanupExpiredPlayerPerks();
            if (this.HasPlayerActivatedFirstPerk())
            {
                GameUtils.SpendHQScaledCurrency(perkVO.ActivationCost, false);
            }
            uint time  = ServerTime.Time;
            int  num   = perkVO.ActiveDurationMinutes * 60;
            uint num2  = time + (uint)num;
            int  num3  = perkVO.CooldownDurationMinutes * 60;
            uint value = num2 + (uint)num3;

            playerActivatedPerks.Add(new ActivatedPerkData
            {
                PerkId    = targetPerkId,
                StartTime = time,
                EndTime   = num2
            });
            playerPerkGroupCooldowns[perkGroup] = value;
            Service.EventManager.SendEvent(EventId.ActivePerksUpdated, null);
            PlayerPerkActivateRequest request = new PlayerPerkActivateRequest(targetPerkId);
            PlayerPerkActivateCommand command = new PlayerPerkActivateCommand(request);

            Service.ServerAPI.Sync(command);
            return(true);
        }
 public SquadScreenActivationInfoView(SquadSlidingScreen screen, PerkVO targetPerkVO, bool isActivation) : base(screen, targetPerkVO)
 {
     this.isActivation = isActivation;
     this.InitUI();
 }
Exemple #30
0
 public SquadScreenBasePerkInfoView(SquadSlidingScreen screen, PerkVO targetPerkVO)
 {
     this.squadScreen  = screen;
     this.targetPerkVO = targetPerkVO;
 }