Ejemplo n.º 1
0
        public void ActivateEquipment(string equipmentId)
        {
            CurrentPlayer currentPlayer            = Service.CurrentPlayer;
            EquipmentVO   currentEquipmentDataByID = ArmoryUtils.GetCurrentEquipmentDataByID(equipmentId);

            if (currentEquipmentDataByID == null)
            {
                Service.Logger.Warn("Invalid EquipmentID: " + equipmentId);
                return;
            }
            if (currentPlayer.ActiveArmory.Equipment.Contains(currentEquipmentDataByID.Uid))
            {
                return;
            }
            if (ArmoryUtils.GetCurrentActiveEquipmentCapacity(currentPlayer.ActiveArmory) + currentEquipmentDataByID.Size > currentPlayer.ActiveArmory.MaxCapacity)
            {
                string instructions = Service.Lang.Get("ARMORY_FULL", new object[0]);
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions);
                return;
            }
            if (!ArmoryUtils.IsEquipmentOnValidPlanet(currentPlayer, currentEquipmentDataByID))
            {
                string instructions2 = Service.Lang.Get("BASE_ON_INCORRECT_PLANET", new object[0]);
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(instructions2);
                return;
            }
            currentPlayer.ActiveArmory.Equipment.Add(currentEquipmentDataByID.Uid);
            Service.EventManager.SendEvent(EventId.EquipmentActivated, currentEquipmentDataByID);
            EquipmentIdRequest       request = new EquipmentIdRequest(equipmentId);
            ActivateEquipmentCommand activateEquipmentCommand = new ActivateEquipmentCommand(request);

            activateEquipmentCommand.Context = equipmentId;
            activateEquipmentCommand.AddFailureCallback(new AbstractCommand <EquipmentIdRequest, DefaultResponse> .OnFailureCallback(this.OnActivateEquipmentFailure));
            Service.ServerAPI.Enqueue(activateEquipmentCommand);
        }
Ejemplo n.º 2
0
        private void InitLabels()
        {
            ActiveArmory activeArmory = Service.CurrentPlayer.ActiveArmory;

            this.titleLabel      = base.GetElement <UXLabel>("LabelTitle");
            this.titleLabel.Text = this.lang.Get("BUILDING_INFO", new object[]
            {
                LangUtils.GetBuildingDisplayName(this.buildingInfo),
                this.buildingInfo.Lvl
            });
            this.currentCapacityLabel      = base.GetElement <UXLabel>("LabelEquipmentActive");
            this.currentCapacityLabel.Text = this.lang.Get("ARMORY_CAPACITY", new object[]
            {
                ArmoryUtils.GetCurrentActiveEquipmentCapacity(activeArmory),
                activeArmory.MaxCapacity
            });
            this.instructionsLabel      = base.GetElement <UXLabel>("LabelEquipment");
            this.instructionsLabel.Text = this.lang.Get("ARMORY_CTA", new object[0]);
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        private int GetCurrentActiveEquipmentSpace()
        {
            ActiveArmory activeArmory = Service.CurrentPlayer.ActiveArmory;

            return(activeArmory.MaxCapacity - ArmoryUtils.GetCurrentActiveEquipmentCapacity(activeArmory));
        }