Beispiel #1
0
        public static Target CreateTargetForTroop(SmartEntity troopEntity, SmartEntity targetEntity, SecondaryTargetsComponent secondaryTargets)
        {
            if (targetEntity == null)
            {
                return(null);
            }
            Target target;

            if (secondaryTargets.ObstacleTarget != null)
            {
                target = new Target();
                target.TargetEntity = targetEntity;
                target.TargetBoardX = secondaryTargets.ObstacleTargetPoint.x;
                target.TargetBoardZ = secondaryTargets.ObstacleTargetPoint.z;
                Target.SetDefaultTargetWorldLocation(target, 1.25f);
                return(target);
            }
            TransformComponent transformComponent = (!TroopController.IsEntityHealer(troopEntity)) ? targetEntity.TransformComp : troopEntity.TransformComp;

            if (transformComponent == null)
            {
                return(null);
            }
            target = new Target();
            target.TargetEntity = targetEntity;
            target.TargetBoardX = transformComponent.CenterGridX();
            target.TargetBoardZ = transformComponent.CenterGridZ();
            Target.SetDefaultTargetWorldLocation(target, 1.25f);
            return(target);
        }
Beispiel #2
0
        public bool RestartPathing(SmartEntity troopEntity, out bool found, bool ignoreWall)
        {
            ShooterComponent   shooterComp = troopEntity.ShooterComp;
            IShooterVO         shooterVO   = shooterComp.ShooterVO;
            TroopComponent     troopComp   = troopEntity.TroopComp;
            TeamComponent      teamComp    = troopEntity.TeamComp;
            ITroopDeployableVO troopType   = troopComp.TroopType;
            uint            maxAttackRange = this.GetMaxAttackRange(troopEntity, shooterComp.Target);
            PathTroopParams troopParams    = new PathTroopParams
            {
                TroopWidth            = troopEntity.SizeComp.Width,
                DPS                   = shooterVO.DPS,
                MinRange              = shooterVO.MinAttackRange,
                MaxRange              = maxAttackRange,
                MaxSpeed              = troopComp.SpeedVO.MaxSpeed,
                PathSearchWidth       = troopType.PathSearchWidth,
                IsMelee               = shooterComp.IsMelee,
                IsOverWall            = shooterVO.OverWalls,
                IsHealer              = TroopController.IsEntityHealer(troopEntity),
                SupportRange          = troopType.SupportFollowDistance,
                ProjectileType        = shooterVO.ProjectileType,
                CrushesWalls          = TroopController.CanEntityCrushWalls(troopEntity),
                IsTargetShield        = GameUtils.IsEntityShieldGenerator(troopEntity.ShooterComp.Target),
                TargetInRangeModifier = troopType.TargetInRangeModifier
            };
            PathBoardParams boardParams = new PathBoardParams
            {
                IgnoreWall   = ignoreWall || TroopController.CanEntityIgnoreWalls(troopEntity),
                Destructible = teamComp.CanDestructBuildings()
            };

            return(this.StartPathing(troopEntity, shooterComp.Target, troopEntity.TransformComp, true, out found, -1, troopParams, boardParams, true, false));
        }
Beispiel #3
0
        public SmartEntity CreateTroopEntity(TroopTypeVO troopType, TeamType teamType, IntPosition boardPosition, Entity spawnBuilding, TroopSpawnMode spawnMode, bool isShooter, bool requestAsset)
        {
            SmartEntity   smartEntity = this.CreateWalkerBaseEntity(boardPosition, troopType.SizeX, troopType.SizeY);
            TeamComponent component   = new TeamComponent(teamType);

            smartEntity.Add(component);
            if (teamType == TeamType.Defender)
            {
                DefenderComponent component2;
                if (spawnMode == TroopSpawnMode.LeashedToBuilding)
                {
                    DamageableComponent damageableComponent = spawnBuilding.Get <DamageableComponent>();
                    component2 = new DefenderComponent(boardPosition.x, boardPosition.z, damageableComponent, true, damageableComponent.GetLastSpawnIndex());
                }
                else
                {
                    component2 = new DefenderComponent(boardPosition.x, boardPosition.z, null, spawnMode == TroopSpawnMode.LeashedToSpawnPoint, 0);
                }
                smartEntity.Add(component2);
            }
            else
            {
                smartEntity.Add(new AttackerComponent());
            }
            TroopComponent troopComponent = new TroopComponent(troopType);

            smartEntity.Add(troopComponent);
            smartEntity.Add(new BuffComponent());
            smartEntity.Add(new HealthViewComponent());
            if (isShooter)
            {
                ShooterComponent component3 = new ShooterComponent(troopType);
                smartEntity.Add(component3);
            }
            Service.EventManager.SendEvent(EventId.TroopCreated, smartEntity);
            if (isShooter)
            {
                smartEntity.ShooterComp.TargetingDelayed = (teamType == TeamType.Attacker);
                bool       flag       = TroopController.IsEntityHealer(smartEntity);
                HealthType healthType = (!flag) ? HealthType.Damaging : HealthType.Healing;
                smartEntity.ShooterComp.AttackFSM = new AttackFSM(Service.BattleController, smartEntity, smartEntity.StateComp, smartEntity.ShooterComp, smartEntity.TransformComp, healthType);
                if (flag)
                {
                    smartEntity.Add(new PathingComponent());
                    smartEntity.Add(new HealerComponent());
                }
                else
                {
                    smartEntity.Add(new KillerComponent());
                }
                SecondaryTargetsComponent component4 = new SecondaryTargetsComponent();
                smartEntity.Add(component4);
            }
            HealthComponent component5 = new HealthComponent(troopType.Health, troopComponent.TroopType.ArmorType);

            smartEntity.Add(component5);
            if (troopType.ShieldHealth > 0)
            {
                TroopShieldHealthComponent component6 = new TroopShieldHealthComponent(troopType.ShieldHealth, ArmorType.Shield);
                smartEntity.Add(component6);
            }
            if (requestAsset)
            {
                Service.EntityViewManager.LoadEntityAsset(smartEntity);
            }
            return(smartEntity);
        }