Example #1
0
        private void ProcessSkin(SmartEntity entity)
        {
            ActiveArmory  activeArmory   = (!(Service.GameStateMachine.CurrentState is HomeState)) ? null : Service.CurrentPlayer.ActiveArmory;
            CurrentBattle battle         = (activeArmory != null) ? null : Service.BattleController.GetCurrentBattle();
            SkinTypeVO    applicableSkin = this.GetApplicableSkin((TroopTypeVO)entity.TroopComp.TroopType, activeArmory, battle, entity.TeamComp.TeamType);

            if (applicableSkin != null)
            {
                entity.TroopComp.AssetName = applicableSkin.AssetName;
                entity.TroopComp.AudioVO   = applicableSkin;
                if (entity.ShooterComp != null)
                {
                    entity.ShooterComp.isSkinned = true;
                }
                if (applicableSkin.Override != null)
                {
                    entity.TroopComp.TroopShooterVO         = new SkinnedTroopShooterFacade(entity.TroopComp.TroopShooterVO, applicableSkin.Override);
                    entity.TroopComp.OriginalTroopShooterVO = new SkinnedTroopShooterFacade(entity.TroopComp.OriginalTroopShooterVO, applicableSkin.Override);
                    if (entity.ShooterComp != null)
                    {
                        entity.ShooterComp.SetVOData(new SkinnedShooterFacade(entity.ShooterComp.ShooterVO, applicableSkin.Override));
                        entity.ShooterComp.OriginalShooterVO = new SkinnedShooterFacade(entity.ShooterComp.OriginalShooterVO, applicableSkin.Override);
                    }
                }
                if (entity.WalkerComp != null)
                {
                    entity.WalkerComp.SetVOData(applicableSkin);
                }
            }
        }
Example #2
0
 private void Init(IGeometryVO geometry, ProjectorConfig projector, string assetName, string tooltipText, BattleEntry battle, ActiveArmory armory)
 {
     this.geometry    = geometry;
     this.projector   = projector;
     this.assetName   = assetName;
     this.tooltipText = tooltipText;
     this.battle      = battle;
     this.armory      = armory;
 }
Example #3
0
        public static int GetCurrentActiveEquipmentCapacity(ActiveArmory playerArmory)
        {
            IDataController dataController = Service.Get <IDataController>();
            int             num            = 0;
            int             i     = 0;
            int             count = playerArmory.Equipment.Count;

            while (i < count)
            {
                EquipmentVO equipmentVO = dataController.Get <EquipmentVO>(playerArmory.Equipment[i]);
                num += equipmentVO.Size;
                i++;
            }
            return(num);
        }
Example #4
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]);
        }
Example #5
0
        private SkinTypeVO GetApplicableSkin(TroopTypeVO troop, ActiveArmory armory, BattleEntry battle, TeamType team)
        {
            if (armory != null)
            {
                return(this.GetApplicableSkin(troop, armory.Equipment));
            }
            if (battle == null)
            {
                return(null);
            }
            List <string> equipmentList = null;

            if (team == TeamType.Attacker)
            {
                equipmentList = battle.AttackerEquipment;
            }
            else if (team == TeamType.Defender)
            {
                equipmentList = battle.DefenderEquipment;
            }
            return(this.GetApplicableSkin(troop, equipmentList));
        }
        private bool BuildingEligibleForIdleAnimation(Entity entity, IState gameState, BuildingAnimationComponent animComp)
        {
            if (entity == null)
            {
                return(false);
            }
            if (gameState is EditBaseState)
            {
                return(false);
            }
            if (animComp.BuildingUpgrading)
            {
                return(false);
            }
            if (Service.Get <PostBattleRepairController>().IsEntityInRepair(entity))
            {
                return(false);
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            if (buildingComponent == null)
            {
                return(false);
            }
            if (!(gameState is HomeState))
            {
                return(false);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.ScoutTower)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Armory)
            {
                ActiveArmory activeArmory = Service.Get <CurrentPlayer>().ActiveArmory;
                return(!ArmoryUtils.IsAnyEquipmentActive(activeArmory));
            }
            return(false);
        }
Example #7
0
        public static void AddTroopProjectileAssets(string troopUid, List <IAssetVO> assets, IDataController dc)
        {
            TroopTypeVO      troopTypeVO    = dc.Get <TroopTypeVO>(troopUid);
            ProjectileTypeVO projectileType = troopTypeVO.ProjectileType;
            ActiveArmory     activeArmory   = Service.Get <CurrentPlayer>().ActiveArmory;

            if (activeArmory != null)
            {
                SkinTypeVO applicableSkin = Service.Get <SkinController>().GetApplicableSkin(troopTypeVO, activeArmory.Equipment);
                if (applicableSkin != null && applicableSkin.Override != null && applicableSkin.Override.ProjectileType != null)
                {
                    projectileType = applicableSkin.Override.ProjectileType;
                }
            }
            ProjectileUtils.AddProjectileAssets(projectileType, assets, dc);
            ProjectileUtils.AddProjectileAssets(troopTypeVO.DeathProjectileType, assets, dc);
            ProjectileUtils.AddBuffProjectileAssets(troopTypeVO.SpawnApplyBuffs, assets, dc);
            if (!string.IsNullOrEmpty(troopTypeVO.Ability))
            {
                TroopAbilityVO troopAbilityVO = dc.Get <TroopAbilityVO>(troopTypeVO.Ability);
                ProjectileUtils.AddProjectileAssets(troopAbilityVO.ProjectileType, assets, dc);
                ProjectileUtils.AddBuffProjectileAssets(troopAbilityVO.SelfBuff, assets, dc);
            }
        }
Example #8
0
 public static bool HasEnoughCapacityToActivateEquipment(ActiveArmory armory, EquipmentVO equipment)
 {
     return(ArmoryUtils.GetCurrentActiveEquipmentCapacity(armory) + equipment.Size <= armory.MaxCapacity);
 }
Example #9
0
 public static bool IsAnyEquipmentActive(ActiveArmory armory)
 {
     return(ArmoryUtils.GetCurrentActiveEquipmentCapacity(armory) > 0);
 }
Example #10
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));
        }
Example #11
0
        private int GetCurrentActiveEquipmentSpace()
        {
            ActiveArmory activeArmory = Service.CurrentPlayer.ActiveArmory;

            return(activeArmory.MaxCapacity - ArmoryUtils.GetCurrentActiveEquipmentCapacity(activeArmory));
        }
Example #12
0
        private void ResetMinimumInactiveSize()
        {
            ActiveArmory activeArmory = Service.CurrentPlayer.ActiveArmory;

            this.minimumInactiveSize = activeArmory.MaxCapacity + 1;
        }
        private bool BuildingEligibleForActiveAnimation(Entity entity, IState gameState, BuildingAnimationComponent animComp)
        {
            if (entity == null)
            {
                return(false);
            }
            if (gameState is EditBaseState)
            {
                return(false);
            }
            if (animComp.BuildingUpgrading)
            {
                return(false);
            }
            if (Service.Get <PostBattleRepairController>().IsEntityInRepair(entity))
            {
                return(false);
            }
            if (animComp.Manufacturing)
            {
                return(true);
            }
            BuildingComponent buildingComponent = entity.Get <BuildingComponent>();

            if (buildingComponent == null)
            {
                return(false);
            }
            BuildingTypeVO buildingType = buildingComponent.BuildingType;

            if (buildingType.Type == BuildingType.HQ)
            {
                return(true);
            }
            if (buildingType.Type == BuildingType.ShieldGenerator && buildingType.SubType == BuildingSubType.OutpostDefenseGenerator)
            {
                return(true);
            }
            if (!(gameState is HomeState))
            {
                return(false);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Barracks || buildingComponent.BuildingType.Type == BuildingType.Cantina)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.DroidHut)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.ScoutTower)
            {
                return(Service.Get <RaidDefenseController>().IsRaidAvailable());
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Resource && buildingComponent.BuildingTO.AccruedCurrency < buildingType.Storage)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Storage && buildingComponent.BuildingTO.CurrentStorage < buildingType.Storage)
            {
                return(true);
            }
            if (buildingComponent.BuildingType.Type == BuildingType.Armory)
            {
                ActiveArmory activeArmory = Service.Get <CurrentPlayer>().ActiveArmory;
                return(ArmoryUtils.IsAnyEquipmentActive(activeArmory));
            }
            return(false);
        }
Example #14
0
 public GeometryTag(IGeometryVO geometry, ProjectorConfig projector, ActiveArmory armory)
 {
     this.Init(geometry, projector, null, null, null, armory);
 }