Exemple #1
0
        private static void AddBuildingProjectileAssets(Map map, List <IAssetVO> assets, IDataController dc)
        {
            int i     = 0;
            int count = map.Buildings.Count;

            while (i < count)
            {
                BuildingTypeVO buildingTypeVO = dc.Get <BuildingTypeVO>(map.Buildings[i].Uid);
                if (!string.IsNullOrEmpty(buildingTypeVO.TurretUid))
                {
                    TurretTypeVO turretTypeVO = dc.Get <TurretTypeVO>(buildingTypeVO.TurretUid);
                    ProjectileUtils.AddProjectileAssets(turretTypeVO.ProjectileType, assets, dc);
                }
                if (buildingTypeVO.TrapUid != null)
                {
                    TrapTypeVO trapTypeVO = dc.Get <TrapTypeVO>(buildingTypeVO.TrapUid);
                    if (trapTypeVO.TurretTED != null && !string.IsNullOrEmpty(trapTypeVO.TurretTED.TurretUid))
                    {
                        TurretTypeVO turretTypeVO2 = dc.Get <TurretTypeVO>(trapTypeVO.TurretTED.TurretUid);
                        ProjectileUtils.AddProjectileAssets(turretTypeVO2.ProjectileType, assets, dc);
                    }
                    if (trapTypeVO.ShipTED != null && !string.IsNullOrEmpty(trapTypeVO.ShipTED.SpecialAttackName))
                    {
                        ProjectileUtils.AddSpecialAttackProjectileAssets(trapTypeVO.ShipTED.SpecialAttackName, assets, dc);
                    }
                }
                i++;
            }
        }
 public EatResponse OnEvent(EventId id, object cookie)
 {
     if (id != EventId.EntityKilled)
     {
         if (id == EventId.BattleEndProcessing)
         {
             NodeList <TrapNode> nodeList = Service.Get <EntityController>().GetNodeList <TrapNode>();
             for (TrapNode trapNode = nodeList.Head; trapNode != null; trapNode = trapNode.Next)
             {
                 if (trapNode.TrapComp.CurrentState == TrapState.Active && trapNode.TrapComp.Type.EventType == TrapEventType.Turret)
                 {
                     this.SwapTurretToTrap((SmartEntity)trapNode.Entity);
                 }
             }
         }
     }
     else
     {
         SmartEntity smartEntity = cookie as SmartEntity;
         if (smartEntity.TrapComp != null)
         {
             TrapTypeVO type = smartEntity.TrapComp.Type;
             this.SetTrapState(smartEntity.TrapComp, TrapState.Spent);
             TrapEventType eventType = type.EventType;
             if (eventType == TrapEventType.Turret)
             {
                 this.SwapTurretToTrap(smartEntity);
             }
         }
     }
     return(EatResponse.NotEaten);
 }
Exemple #3
0
        public static bool RearmTrapForClient(SmartEntity selectedBuilding)
        {
            BuildingTypeVO buildingType        = selectedBuilding.BuildingComp.BuildingType;
            TrapTypeVO     trapTypeVO          = Service.StaticDataController.Get <TrapTypeVO>(buildingType.TrapUid);
            int            rearmCreditsCost    = trapTypeVO.RearmCreditsCost;
            int            rearmMaterialsCost  = trapTypeVO.RearmMaterialsCost;
            int            rearmContrabandCost = trapTypeVO.RearmContrabandCost;

            if (!GameUtils.CanAffordCredits(rearmCreditsCost) || !GameUtils.CanAffordMaterials(rearmMaterialsCost))
            {
                int    arg_73_0 = rearmCreditsCost;
                int    arg_73_1 = rearmMaterialsCost;
                int    arg_73_2 = rearmContrabandCost;
                string arg_73_3 = GameUtils.GetBuildingPurchaseContext(buildingType, null, false, false);
                if (TrapUtils.< > f__mg$cache1 == null)
                {
                    TrapUtils.< > f__mg$cache1 = new OnScreenModalResult(TrapUtils.OnPayMeForCurrencyResultSingleTrap);
                }
                PayMeScreen.ShowIfNotEnoughCurrency(arg_73_0, arg_73_1, arg_73_2, arg_73_3, TrapUtils.< > f__mg$cache1);
                return(false);
            }
            GameUtils.SpendCurrency(rearmCreditsCost, rearmMaterialsCost, rearmContrabandCost, true);
            Service.TrapController.SetTrapState(selectedBuilding.TrapComp, TrapState.Armed);
            selectedBuilding.BuildingComp.BuildingTO.CurrentStorage = 1;
            Service.UXController.HUD.ShowContextButtons(selectedBuilding);
            Service.BuildingController.RedrawRadiusForSelectedBuilding();
            return(true);
        }
        public void AddTrapComponentsToEntity(Entity buildingEntity, BuildingTypeVO buildingType)
        {
            TrapTypeVO    type           = Service.Get <IDataController>().Get <TrapTypeVO>(buildingType.TrapUid);
            TrapState     currentStorage = (TrapState)buildingEntity.Get <BuildingComponent>().BuildingTO.CurrentStorage;
            TrapComponent component      = new TrapComponent(type, currentStorage);

            buildingEntity.Add(component);
        }
Exemple #5
0
        public static uint GetTrapMaxRadius(TrapTypeVO trapType)
        {
            List <TrapCondition> parsedTrapConditions = trapType.ParsedTrapConditions;

            for (int i = 0; i < parsedTrapConditions.Count; i++)
            {
                if (parsedTrapConditions[i] is RadiusTrapCondition)
                {
                    return(((RadiusTrapCondition)parsedTrapConditions[i]).Radius);
                }
            }
            return(0u);
        }
        protected override bool SetupParticlesOnShow(Entity entity)
        {
            BuildingTypeVO buildingType = entity.Get <BuildingComponent>().BuildingType;

            if (buildingType.Type == BuildingType.Trap && entity.Get <TrapComponent>().CurrentState != TrapState.Spent && !ContractUtils.IsBuildingUpgrading(entity) && !ContractUtils.IsBuildingConstructing(entity))
            {
                TrapTypeVO trapType         = Service.Get <IDataController>().Get <TrapTypeVO>(buildingType.TrapUid);
                uint       trapMaxRadius    = TrapUtils.GetTrapMaxRadius(trapType);
                uint       trapAttackRadius = TrapUtils.GetTrapAttackRadius(trapType);
                base.SetupParticleSystemWithRange(this.triggerRadius, 5f, trapMaxRadius);
                base.SetupParticleSystemWithRange(this.damageRadius, 5f, trapAttackRadius);
                return(true);
            }
            return(false);
        }
        public int GetTrapDamageForUIDisplay(TrapTypeVO trapType)
        {
            TrapEventType eventType = trapType.EventType;

            if (eventType == TrapEventType.SpecialAttack)
            {
                SpecialAttackTypeVO specialAttackTypeVO = Service.Get <IDataController>().Get <SpecialAttackTypeVO>(trapType.ShipTED.SpecialAttackName);
                return(specialAttackTypeVO.DPS);
            }
            if (eventType != TrapEventType.Turret)
            {
                return(0);
            }
            TurretTypeVO turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(trapType.TurretTED.TurretUid);

            return(turretTypeVO.DPS);
        }
Exemple #8
0
        protected override void OnLoaded()
        {
            IDataController dataController = Service.Get <IDataController>();

            this.trapVO = dataController.Get <TrapTypeVO>(this.buildingInfo.TrapUid);
            if (this.useUpgradeGroup && this.nextBuildingInfo != null)
            {
                this.nextTrapVO = dataController.Get <TrapTypeVO>(this.nextBuildingInfo.TrapUid);
            }
            if (this.maxBuildingInfo != null)
            {
                this.maxTrapVO = dataController.Get <TrapTypeVO>(this.maxBuildingInfo.TrapUid);
            }
            base.InitControls(2);
            this.UpdateDps();
            this.UpdateRadius();
        }
Exemple #9
0
        public static void GetRearmAllTrapsCost(out int creditsCost, out int materialsCost, out int contrabandCost)
        {
            creditsCost    = 0;
            materialsCost  = 0;
            contrabandCost = 0;
            StaticDataController staticDataController = Service.StaticDataController;
            List <SmartEntity>   rearmableTraps       = TrapUtils.GetRearmableTraps();
            int i     = 0;
            int count = rearmableTraps.Count;

            while (i < count)
            {
                TrapTypeVO trapTypeVO = staticDataController.Get <TrapTypeVO>(rearmableTraps[i].BuildingComp.BuildingType.TrapUid);
                creditsCost    += trapTypeVO.RearmCreditsCost;
                materialsCost  += trapTypeVO.RearmMaterialsCost;
                contrabandCost += trapTypeVO.RearmContrabandCost;
                i++;
            }
        }
Exemple #10
0
        public static uint GetTrapAttackRadius(TrapTypeVO trapType)
        {
            IDataController dataController = Service.Get <IDataController>();
            TrapEventType   eventType      = trapType.EventType;

            if (eventType == TrapEventType.SpecialAttack)
            {
                string specialAttackName = trapType.ShipTED.SpecialAttackName;
                SpecialAttackTypeVO specialAttackTypeVO = dataController.Get <SpecialAttackTypeVO>(specialAttackName);
                ProjectileTypeVO    projectileType      = specialAttackTypeVO.ProjectileType;
                return((uint)projectileType.SplashRadius);
            }
            if (eventType == TrapEventType.Turret)
            {
                string       turretUid    = trapType.TurretTED.TurretUid;
                TurretTypeVO turretTypeVO = dataController.Get <TurretTypeVO>(turretUid);
                return(turretTypeVO.MaxAttackRange);
            }
            return(0u);
        }
Exemple #11
0
        public static bool RearmTrapForClient(Entity selectedBuilding)
        {
            BuildingTypeVO buildingType        = selectedBuilding.Get <BuildingComponent>().BuildingType;
            TrapTypeVO     trapTypeVO          = Service.Get <IDataController>().Get <TrapTypeVO>(buildingType.TrapUid);
            int            rearmCreditsCost    = trapTypeVO.RearmCreditsCost;
            int            rearmMaterialsCost  = trapTypeVO.RearmMaterialsCost;
            int            rearmContrabandCost = trapTypeVO.RearmContrabandCost;

            if (!GameUtils.CanAffordCredits(rearmCreditsCost) || !GameUtils.CanAffordMaterials(rearmMaterialsCost))
            {
                PayMeScreen.ShowIfNotEnoughCurrency(rearmCreditsCost, rearmMaterialsCost, rearmContrabandCost, GameUtils.GetBuildingPurchaseContext(buildingType, null, false, false), new OnScreenModalResult(TrapUtils.OnPayMeForCurrencyResultSingleTrap));
                return(false);
            }
            GameUtils.SpendCurrency(rearmCreditsCost, rearmMaterialsCost, rearmContrabandCost, true);
            Service.Get <TrapController>().SetTrapState(selectedBuilding.Get <TrapComponent>(), TrapState.Armed);
            selectedBuilding.Get <BuildingComponent>().BuildingTO.CurrentStorage = 1;
            Service.Get <UXController>().HUD.ShowContextButtons(selectedBuilding);
            Service.Get <BuildingController>().RedrawRadiusForSelectedBuilding();
            return(true);
        }
Exemple #12
0
 public TrapComponent(TrapTypeVO type, TrapState state)
 {
     this.Type          = type;
     this.state         = state;
     this.PreviousState = TrapState.Spent;
 }