Esempio n. 1
0
        private void ShowInstructionalTextOnFirstEmptyCard(UXGrid grid)
        {
            if (!this.ListHasEmptyFirstCard(grid))
            {
                return;
            }
            List <UXElement> elementList = grid.GetElementList();
            int num   = 500000;
            int i     = 0;
            int count = elementList.Count;

            while (i < count)
            {
                SortableEquipment sortableEquipment = elementList[i].Tag as SortableEquipment;
                if (sortableEquipment.EmptyIndex < num)
                {
                    num = sortableEquipment.EmptyIndex;
                }
                i++;
            }
            StringBuilder stringBuilder = new StringBuilder("EMPTY");
            string        itemUid       = stringBuilder.Append(num).ToString();
            UXLabel       subElement    = grid.GetSubElement <UXLabel>(itemUid, "LabelEquipmentActiveInstructions");

            subElement.Visible = true;
        }
Esempio n. 2
0
        private UXElement CreateActiveCard(UXGrid grid, EquipmentVO equipment, CurrentPlayer player)
        {
            UXElement         uXElement         = this.CreateCommonEquipmentCard(this.activeGrid, equipment, "LabelEquipmentActiveName", "LabelEquipmentActiveLevel", "SpriteEquipmentActiveItemImage", "EquipmentActiveItemCardQ{0}", true, false);
            SortableEquipment sortableEquipment = uXElement.Tag as SortableEquipment;

            sortableEquipment.IncrementingIndex = this.activeCardID++;
            UXLabel subElement = this.activeGrid.GetSubElement <UXLabel>(equipment.Uid, "LabelEquipmentActiveInstructions");

            subElement.Visible = false;
            UXButton subElement2 = this.activeGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentActiveCancel");

            subElement2.OnClicked = new UXButtonClickedDelegate(this.OnCancelButtonClicked);
            subElement2.Tag       = uXElement;
            UXButton subElement3 = this.activeGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentActiveItemCard");

            subElement3.Tag       = equipment;
            subElement3.OnClicked = new UXButtonClickedDelegate(this.OnActiveCardButtonClicked);
            UXSprite subElement4 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentActiveImageBkgStroke");
            UXSprite subElement5 = grid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentActiveImageBkgGlow");

            subElement4.Color = ArmoryScreen.qualityColor[equipment.Quality];
            subElement5.Color = ArmoryScreen.qualityColor[equipment.Quality];
            subElement5.Alpha = 0.4f;
            this.activeGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteEquipmentActiveImageEmptySlot").Visible = false;
            return(uXElement);
        }
Esempio n. 3
0
        private static int SortByQuality(SortableEquipment a, SortableEquipment b)
        {
            int num = b.Equipment.Quality - a.Equipment.Quality;

            if (num != 0)
            {
                return(num);
            }
            return(0);
        }
Esempio n. 4
0
        private static int SortByDecrementingIndex(SortableEquipment a, SortableEquipment b)
        {
            int num = b.IncrementingIndex - a.IncrementingIndex;

            if (num != 0)
            {
                return(num);
            }
            return(0);
        }
Esempio n. 5
0
        private static int SortByIncrementingEmptyIndex(SortableEquipment a, SortableEquipment b)
        {
            int num = a.EmptyIndex - b.EmptyIndex;

            if (num != 0)
            {
                return(num);
            }
            return(0);
        }
Esempio n. 6
0
        private static int SortByCapacitySize(SortableEquipment a, SortableEquipment b)
        {
            int num = a.Equipment.Size - b.Equipment.Size;

            if (num != 0)
            {
                return(num);
            }
            return(0);
        }
Esempio n. 7
0
 private static int SortByEmptyEquipment(SortableEquipment a, SortableEquipment b)
 {
     if (a.HasEquipment() && !b.HasEquipment())
     {
         return(1);
     }
     if (b.HasEquipment() && !a.HasEquipment())
     {
         return(-1);
     }
     return(0);
 }
Esempio n. 8
0
        private bool ListHasEmptyFirstCard(UXGrid grid)
        {
            UXElement item = grid.GetItem(0);

            if (item == null)
            {
                return(false);
            }
            SortableEquipment sortableEquipment = item.Tag as SortableEquipment;

            return(sortableEquipment != null && !sortableEquipment.HasEquipment());
        }
Esempio n. 9
0
        private int SortActiveGrid(UXElement elementA, UXElement elementB)
        {
            SortableEquipment a = elementA.Tag as SortableEquipment;
            SortableEquipment b = elementB.Tag as SortableEquipment;

            return(ArmorySortUtils.SortWithList(a, b, new List <EquipmentSortMethod>
            {
                EquipmentSortMethod.EmptyEquipment,
                EquipmentSortMethod.DecrementingIndex,
                EquipmentSortMethod.IncrementingEmptyIndex
            }));
        }
Esempio n. 10
0
        private static int SortByCurrentPlanet(SortableEquipment a, SortableEquipment b)
        {
            bool flag  = ArmoryUtils.IsEquipmentOnValidPlanet(a.Player, a.Equipment);
            bool flag2 = ArmoryUtils.IsEquipmentOnValidPlanet(b.Player, b.Equipment);

            if (flag && !flag2)
            {
                return(-1);
            }
            if (flag2 && !flag)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 11
0
        private static int SortByRequirementsMet(SortableEquipment a, SortableEquipment b)
        {
            bool flag  = ArmoryUtils.IsBuildingRequirementMet(a.Equipment);
            bool flag2 = ArmoryUtils.IsBuildingRequirementMet(b.Equipment);

            if (flag && !flag2)
            {
                return(-1);
            }
            if (flag2 && !flag)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 12
0
        private int SortInactiveGrid(UXElement elementA, UXElement elementB)
        {
            SortableEquipment a = elementA.Tag as SortableEquipment;
            SortableEquipment b = elementB.Tag as SortableEquipment;

            return(ArmorySortUtils.SortWithList(a, b, new List <EquipmentSortMethod>
            {
                EquipmentSortMethod.UnlockedEquipment,
                EquipmentSortMethod.RequirementsMet,
                EquipmentSortMethod.CurrentPlanet,
                EquipmentSortMethod.Quality,
                EquipmentSortMethod.CapacitySize,
                EquipmentSortMethod.Alphabetical
            }));
        }
Esempio n. 13
0
        private static int SortByUnlockedEquipment(SortableEquipment a, SortableEquipment b)
        {
            bool flag  = a.Player.UnlockedLevels.Equipment.Levels.ContainsKey(a.Equipment.EquipmentID);
            bool flag2 = b.Player.UnlockedLevels.Equipment.Levels.ContainsKey(b.Equipment.EquipmentID);

            if (flag && !flag2)
            {
                return(-1);
            }
            if (flag2 && !flag)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 14
0
        private UXElement CreateEmptyCard(UXGrid grid)
        {
            SortableEquipment sortableEquipment = new SortableEquipment(null);

            sortableEquipment.EmptyIndex = 0;
            StringBuilder stringBuilder = new StringBuilder("EMPTY");
            string        text          = stringBuilder.Append(sortableEquipment.EmptyIndex).ToString();
            UXElement     uXElement     = this.CreateEmptyCardInternal(grid, text);

            uXElement.Tag = sortableEquipment;
            UXLabel subElement = this.activeGrid.GetSubElement <UXLabel>(text, "LabelEquipmentActiveInstructions");

            subElement.Text    = this.lang.Get("ACTIVATE_INSTRUCTION", new object[0]);
            subElement.Visible = false;
            return(uXElement);
        }
Esempio n. 15
0
        private bool IsElementInGrid(UXGrid grid, string cardUid)
        {
            List <UXElement> elementList = grid.GetElementList();
            int i     = 0;
            int count = elementList.Count;

            while (i < count)
            {
                SortableEquipment sortableEquipment = elementList[i].Tag as SortableEquipment;
                if (sortableEquipment.Equipment != null && sortableEquipment.Equipment.Uid == cardUid)
                {
                    return(true);
                }
                i++;
            }
            return(false);
        }
Esempio n. 16
0
        private void RemoveCardFromGridByUid(UXGrid grid, string cardUid)
        {
            List <UXElement> elementList = grid.GetElementList();
            int i     = 0;
            int count = elementList.Count;

            while (i < count)
            {
                SortableEquipment sortableEquipment = elementList[i].Tag as SortableEquipment;
                if (cardUid == sortableEquipment.Equipment.Uid)
                {
                    this.RemoveCardFromGrid(grid, elementList[i]);
                    return;
                }
                i++;
            }
        }
Esempio n. 17
0
        public static int SortWithList(SortableEquipment a, SortableEquipment b, List <EquipmentSortMethod> sortingPriority)
        {
            Dictionary <EquipmentSortMethod, ArmorySortUtils.SortEquipmentDelegate> dictionary = ArmorySortUtils.CreateSortDictionary();
            int i     = 0;
            int count = sortingPriority.Count;

            while (i < count)
            {
                ArmorySortUtils.SortEquipmentDelegate sortEquipmentDelegate = dictionary[sortingPriority[i]];
                int num = sortEquipmentDelegate(a, b);
                if (num != 0)
                {
                    return(num);
                }
                i++;
            }
            return(0);
        }
Esempio n. 18
0
 private static int SortAlphabetically(SortableEquipment a, SortableEquipment b)
 {
     return(string.Compare(a.Equipment.EquipmentID, b.Equipment.EquipmentID));
 }
Esempio n. 19
0
        public override EatResponse OnEvent(EventId id, object cookie)
        {
            CurrentPlayer currentPlayer         = Service.CurrentPlayer;
            ActiveArmory  activeArmory          = currentPlayer.ActiveArmory;
            EquipmentVO   equipmentVO           = cookie as EquipmentVO;
            float         currentScrollPosition = this.activeGrid.GetCurrentScrollPosition(false);

            this.inactiveScrollPosition = this.inactiveGrid.GetCurrentScrollPosition(false);
            if (id != EventId.EquipmentActivated)
            {
                if (id == EventId.EquipmentDeactivated)
                {
                    UXButton  subElement = this.activeGrid.GetSubElement <UXButton>(equipmentVO.Uid, "BtnEquipmentActiveCancel");
                    UXElement uXElement  = subElement.Tag as UXElement;
                    this.RemoveCardFromGrid(this.activeGrid, uXElement);
                    this.activeGrid.RepositionItems(false);
                    this.ShowInstructionalTextOnFirstEmptyCard(this.activeGrid);
                    if (this.activeGrid.Count > 5)
                    {
                        this.activeGrid.Scroll(currentScrollPosition);
                    }
                    else
                    {
                        this.activeGrid.Scroll(0f);
                    }
                    SortableEquipment sortableEquipment = uXElement.Tag as SortableEquipment;
                    if (this.equipmentTabs.IsEquipmentValidForTab(sortableEquipment.Equipment, (EquipmentTab)this.equipmentTabs.CurrentTab))
                    {
                        UXElement item = this.CreateInactiveCard(this.inactiveGrid, sortableEquipment.Equipment, currentPlayer);
                        this.inactiveGrid.AddItem(item, this.inactiveGrid.Count + 1);
                        this.inactiveGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.RepositionInactiveGridItemsCallback));
                    }
                    this.currentCapacityLabel.Text = this.lang.Get("ARMORY_CAPACITY", new object[]
                    {
                        ArmoryUtils.GetCurrentActiveEquipmentCapacity(activeArmory),
                        activeArmory.MaxCapacity
                    });
                    this.RefreshInactiveCardStatusesBasedOnOverallCapacity();
                }
            }
            else
            {
                this.RemoveCardFromGridByUid(this.inactiveGrid, equipmentVO.Uid);
                this.inactiveGrid.RepositionItemsFrameDelayed(new UXDragDelegate(this.RepositionInactiveGridItemsCallback));
                this.RemoveAnEmptyCard(this.activeGrid);
                UXElement item2 = this.CreateActiveCard(this.activeGrid, equipmentVO, currentPlayer);
                this.activeGrid.AddItem(item2, this.activeCardID++);
                this.activeGrid.RepositionItems(false);
                this.ShowInstructionalTextOnFirstEmptyCard(this.activeGrid);
                if (this.activeGrid.Count > 5)
                {
                    this.activeGrid.Scroll(currentScrollPosition);
                }
                else
                {
                    this.activeGrid.Scroll(0f);
                }
                this.currentCapacityLabel.Text = this.lang.Get("ARMORY_CAPACITY", new object[]
                {
                    ArmoryUtils.GetCurrentActiveEquipmentCapacity(activeArmory),
                    activeArmory.MaxCapacity
                });
                this.RefreshInactiveCardStatusesBasedOnOverallCapacity();
            }
            return(base.OnEvent(id, cookie));
        }