示例#1
0
        private void SetUpArmoryScreenInfo(CurrentPlayer player)
        {
            this.SetTitleText(base.GetElement <UXLabel>("DialogBldgUpgradeTitle"), "BUILDING_INFO", this.selectedEquipment.EquipmentName, this.selectedEquipment.Lvl);
            UXLabel element = base.GetElement <UXLabel>("LabelRequirement");

            element.Visible = true;
            UXLabel  element2 = base.GetElement <UXLabel>("LabelNormalIntro");
            UXButton element3 = base.GetElement <UXButton>("BtnNormal");

            element3.Visible   = true;
            element3.OnClicked = new UXButtonClickedDelegate(this.OnMainButtonClicked);
            if (!ArmoryUtils.IsEquipmentOwned(player, this.selectedEquipment))
            {
                element3.Enabled = false;
                element2.Text    = this.lang.Get("ARMORY_ACTIVATE", new object[0]);
                element.Text     = this.lang.Get("EQUIPMENT_LOCKED", new object[]
                {
                    this.CalculateFragmentsNeededForUnlock(this.selectedEquipment.UpgradeShards, this.selectedEquipment.EquipmentID)
                });
                return;
            }
            if (ArmoryUtils.IsEquipmentActive(player, this.selectedEquipment))
            {
                element2.Text    = this.lang.Get("ARMORY_DEACTIVATE", new object[0]);
                element3.Enabled = true;
            }
            else
            {
                bool flag  = ArmoryUtils.HasEnoughCapacityToActivateEquipment(player.ActiveArmory, this.selectedEquipment);
                bool flag2 = ArmoryUtils.IsEquipmentValidForPlanet(this.selectedEquipment, player.PlanetId);
                element3.Enabled = (flag && flag2);
                element2.Text    = this.lang.Get("ARMORY_ACTIVATE", new object[0]);
                if (!flag2)
                {
                    string planetDisplayName = LangUtils.GetPlanetDisplayName(player.PlanetId);
                    element.Text = this.lang.Get("ARMORY_INVALID_EQUIPMENT_PLANET", new object[]
                    {
                        planetDisplayName
                    });
                    return;
                }
                if (!flag)
                {
                    element.Text = this.lang.Get("ARMORY_NOT_ENOUGH_CAPACITY", new object[0]);
                    return;
                }
            }
            element.Text = string.Empty;
        }
示例#2
0
        private void OnCardButtonClicked(UXButton button)
        {
            CurrentPlayer currentPlayer       = Service.CurrentPlayer;
            EquipmentVO   equipmentVOFromCard = this.GetEquipmentVOFromCard(button.Tag as UXElement);

            if (!ArmoryUtils.IsEquipmentValidForPlanet(equipmentVOFromCard, currentPlayer.PlanetId))
            {
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(this.lang.Get("BASE_ON_INCORRECT_PLANET", new object[0]));
                return;
            }
            if (!ArmoryUtils.HasEnoughCapacityToActivateEquipment(currentPlayer.ActiveArmory, equipmentVOFromCard))
            {
                Service.UXController.MiscElementsManager.ShowPlayerInstructions(this.lang.Get("ARMORY_FULL", new object[0]));
                return;
            }
            Service.ArmoryController.ActivateEquipment(equipmentVOFromCard.EquipmentID);
        }
示例#3
0
        public EatResponse OnEvent(EventId id, object cookie)
        {
            switch (id)
            {
            case EventId.BattleReplaySetup:
            {
                BattleRecord battleRecord = (BattleRecord)cookie;
                ArmoryController.AddEquipmentBuffs(battleRecord.AttackerEquipment, battleRecord.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleRecordRetrieved:
            {
                GetReplayResponse getReplayResponse = (GetReplayResponse)cookie;
                BattleRecord      replayData        = getReplayResponse.ReplayData;
                ArmoryController.AddEquipmentBuffs(replayData.AttackerEquipment, replayData.DefenderEquipment);
                return(EatResponse.NotEaten);
            }

            case EventId.BattleLeftBeforeStarting:
            case EventId.BattleReplayEnded:
                goto IL_150;

            case EventId.BattleLoadedForDefend:
                break;

            default:
                switch (id)
                {
                case EventId.EquipmentUnlocked:
                    this.pendingCelebrationEquipment = (cookie as EquipmentVO);
                    this.UpdateLastEquipmentUnlocked(this.pendingCelebrationEquipment.Uid);
                    if (this.AllowUnlockCelebration)
                    {
                        if (GameUtils.IsUnlockBlockingScreenOpen())
                        {
                            Service.EventManager.RegisterObserver(this, EventId.ScreenClosing);
                        }
                        else
                        {
                            bool immediate = GameUtils.CanShardUnlockCelebrationPlayImmediately();
                            this.ShowEquipmentUnlockedCelebration(immediate);
                        }
                    }
                    return(EatResponse.NotEaten);

                case EventId.EquipmentUpgraded:
                {
                    ContractEventData    contractEventData    = cookie as ContractEventData;
                    StaticDataController staticDataController = Service.StaticDataController;
                    EquipmentVO          equipmentVO          = staticDataController.Get <EquipmentVO>(contractEventData.Contract.ProductUid);
                    this.UpdateActiveArmoryLevel(equipmentVO);
                    return(EatResponse.NotEaten);
                }

                case EventId.EquipmentActivated:
                case EventId.EquipmentDeactivated:
                    this.UpdateArmoryBuildingTooltip();
                    return(EatResponse.NotEaten);

                default:
                    switch (id)
                    {
                    case EventId.ScreenClosing:
                        if (cookie is InventoryCrateCollectionScreen)
                        {
                            GameUtils.CloseStoreOrInventoryScreen();
                            Service.EventManager.UnregisterObserver(this, EventId.ScreenClosing);
                            if (this.AllowUnlockCelebration)
                            {
                                this.ShowEquipmentUnlockedCelebration(false);
                            }
                        }
                        return(EatResponse.NotEaten);

                    case EventId.ScreenClosed:
                    case EventId.ScreenOverlayClosing:
                    {
IL_58:
                        if (id == EventId.BattleLoadStart)
                        {
                            goto IL_E3;
                        }
                        if (id == EventId.BattleEndFullyProcessed)
                        {
                            goto IL_150;
                        }
                        if (id != EventId.PlanetConfirmRelocate)
                        {
                            return(EatResponse.NotEaten);
                        }
                        CurrentPlayer        currentPlayer         = Service.CurrentPlayer;
                        StaticDataController staticDataController2 = Service.StaticDataController;
                        for (int i = currentPlayer.ActiveArmory.Equipment.Count - 1; i >= 0; i--)
                        {
                            EquipmentVO equipment = staticDataController2.Get <EquipmentVO>(currentPlayer.ActiveArmory.Equipment[i]);
                            if (!ArmoryUtils.IsEquipmentValidForPlanet(equipment, (string)cookie))
                            {
                                this.DeactivateEquipmentOnClient(currentPlayer, equipment);
                            }
                        }
                        return(EatResponse.NotEaten);
                    }

                    case EventId.ScreenLoaded:
                        if (cookie is ArmoryScreen)
                        {
                            this.UpdateLastEquipmentUnlocked("false");
                        }
                        return(EatResponse.NotEaten);
                    }
                    goto IL_58;
                }
                break;
            }
IL_E3:
            CurrentBattle currentBattle = Service.BattleController.GetCurrentBattle();

            ArmoryController.AddEquipmentBuffs(currentBattle.AttackerEquipment, currentBattle.DefenderEquipment);
            return(EatResponse.NotEaten);

IL_150:
            Service.BuffController.ClearEquipmentBuffs();
            return(EatResponse.NotEaten);
        }
示例#4
0
        private void SetDimmerBasedOnRequirements(CurrentPlayer player, EquipmentVO equipment)
        {
            UXSprite  subElement  = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteDim");
            UXSprite  subElement2 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteDimFull");
            UXLabel   subElement3 = this.inactiveGrid.GetSubElement <UXLabel>(equipment.Uid, "LabelEquipmentRequirement");
            UXSprite  subElement4 = this.inactiveGrid.GetSubElement <UXSprite>(equipment.Uid, "SpriteLockIcon");
            UXElement subElement5 = this.inactiveGrid.GetSubElement <UXElement>(equipment.Uid, "PlanetLocked");

            subElement2.Visible = false;
            subElement4.Visible = false;
            subElement5.Visible = false;
            bool flag = ArmoryUtils.IsEquipmentOwned(player, equipment);

            if (ArmoryUtils.IsBuildingRequirementMet(equipment) && flag && ArmoryUtils.IsEquipmentValidForPlanet(equipment, player.PlanetId))
            {
                subElement3.Text = string.Empty;
                if (ArmoryUtils.HasEnoughCapacityToActivateEquipment(player.ActiveArmory, equipment))
                {
                    this.UpdateMinimumInactiveSize(equipment.Size);
                    subElement.Visible = false;
                    return;
                }
                subElement3.Text   = this.lang.Get("ARMORY_INACTIVE_CAPACITY_REACHED", new object[0]);
                subElement.Visible = true;
                return;
            }
            else
            {
                if (!ArmoryUtils.IsBuildingRequirementMet(equipment))
                {
                    StaticDataController staticDataController = Service.StaticDataController;
                    BuildingTypeVO       buildingTypeVO       = staticDataController.Get <BuildingTypeVO>(equipment.BuildingRequirement);
                    subElement3.Text = this.lang.Get("BUILDING_REQUIREMENT", new object[]
                    {
                        buildingTypeVO.Lvl,
                        LangUtils.GetBuildingDisplayName(buildingTypeVO)
                    });
                    subElement2.Visible = true;
                    subElement.Visible  = false;
                    return;
                }
                UXButton subElement6 = this.inactiveGrid.GetSubElement <UXButton>(equipment.Uid, "BtnEquipmentItemCard");
                subElement6.Enabled = false;
                if (!ArmoryUtils.IsEquipmentOnValidPlanet(player, equipment) && flag)
                {
                    subElement.Visible  = false;
                    subElement2.Visible = true;
                    string planetDisplayName = LangUtils.GetPlanetDisplayName(player.PlanetId);
                    subElement3.Text = this.lang.Get("BASE_ON_INCORRECT_PLANET", new object[]
                    {
                        planetDisplayName
                    });
                    subElement5.Visible = true;
                    return;
                }
                subElement.Visible  = false;
                subElement2.Visible = true;
                subElement4.Visible = true;
                if (player.Shards.ContainsKey(equipment.EquipmentID))
                {
                    subElement3.Text = this.lang.Get("EQUIPMENT_LOCKED", new object[]
                    {
                        equipment.UpgradeShards - player.Shards[equipment.EquipmentID]
                    });
                }
                else
                {
                    subElement3.Text = this.lang.Get("EQUIPMENT_LOCKED", new object[]
                    {
                        equipment.UpgradeShards
                    });
                }
                return;
            }
        }