コード例 #1
0
 public SmartEntity GetTroopTarget(SecondaryTargetsComponent secondaryTargets, ShooterComponent shooterComp)
 {
     if (secondaryTargets == null)
     {
         return(null);
     }
     if (shooterComp == null || shooterComp.Entity == null)
     {
         return(null);
     }
     if (secondaryTargets.ObstacleTarget != null)
     {
         return((SmartEntity)secondaryTargets.ObstacleTarget);
     }
     if (secondaryTargets.CurrentAlternateTarget != null)
     {
         return((SmartEntity)secondaryTargets.CurrentAlternateTarget);
     }
     if (secondaryTargets.AlternateTargets != null)
     {
         while (secondaryTargets.AlternateTargets.First != null)
         {
             Entity value = secondaryTargets.AlternateTargets.First.Value;
             secondaryTargets.AlternateTargets.RemoveFirst();
             if (this.ShouldAttackAlternateTarget(shooterComp, value))
             {
                 secondaryTargets.CurrentAlternateTarget = value;
                 return((SmartEntity)secondaryTargets.CurrentAlternateTarget);
             }
         }
     }
     return(shooterComp.Target);
 }
コード例 #2
0
 protected override void OnBeforeAttack(SmartEntity troop)
 {
     if (this.hitShieldCell == null)
     {
         return;
     }
     if (this.hitShieldCell.Obstacles != null)
     {
         int i     = 0;
         int count = this.hitShieldCell.Obstacles.Count;
         while (i < count)
         {
             if (this.hitShieldCell.Obstacles[i] != null)
             {
                 HealthComponent healthComp = ((SmartEntity)this.hitShieldCell.Obstacles[i]).HealthComp;
                 if (healthComp != null && !healthComp.IsDead())
                 {
                     SecondaryTargetsComponent secondaryTargetsComp = troop.SecondaryTargetsComp;
                     secondaryTargetsComp.ObstacleTarget      = this.hitShieldCell.Obstacles[i];
                     secondaryTargetsComp.ObstacleTargetPoint = new Point(this.hitShieldCell.X, this.hitShieldCell.Z);
                     break;
                 }
             }
             i++;
         }
     }
 }
コード例 #3
0
 public void OnPathingComplete(SmartEntity self, SecondaryTargetsComponent secondaryTargetsComp, StateComponent stateComp, ShooterComponent shooterComp, SmartEntity target)
 {
     this.UpdateAlterantiveTargets(secondaryTargetsComp, self, target);
     this.shooterController.StartMoving(self);
     if (!shooterComp.FirstTargetAcquired || (target.BuildingComp != null && target.BuildingComp.BuildingType.ShowReticleWhenTargeted))
     {
         shooterComp.FirstTargetAcquired = true;
         this.OnTroopAcquiredFirstTarget(self);
     }
 }
コード例 #4
0
 protected void OnTargetWallIsDestroyed(SmartEntity troop, SmartEntity wallTarget)
 {
     if (wallTarget != null)
     {
         Service.HealthController.KillEntity(wallTarget);
         SecondaryTargetsComponent secondaryTargetsComp = troop.SecondaryTargetsComp;
         if (secondaryTargetsComp.CurrentWallTarget != null)
         {
             secondaryTargetsComp.CurrentWallTarget = null;
             return;
         }
     }
 }
コード例 #5
0
        public void UpdateAlterantiveTargets(SecondaryTargetsComponent secondarTargets, SmartEntity troop, SmartEntity target)
        {
            if (!this.ShouldSeekAlternativeTarget(troop))
            {
                return;
            }
            secondarTargets.CurrentAlternateTarget = null;
            PathingComponent pathingComp = troop.PathingComp;

            if (pathingComp != null)
            {
                secondarTargets.WallTargets      = new LinkedList <Entity>();
                secondarTargets.AlternateTargets = pathingComp.CurrentPath.GetBlockingEntities(target.ID, out secondarTargets.WallTargets);
            }
        }
コード例 #6
0
        public Target GetTargetToAttack(SmartEntity entity)
        {
            ShooterComponent shooterComp = entity.ShooterComp;

            if (shooterComp == null)
            {
                return(null);
            }
            SecondaryTargetsComponent secondaryTargetsComp = entity.SecondaryTargetsComp;
            SmartEntity targetEntity;

            if (secondaryTargetsComp != null)
            {
                targetEntity = this.GetTroopTarget(secondaryTargetsComp, shooterComp);
                return(Target.CreateTargetForTroop(entity, targetEntity, secondaryTargetsComp));
            }
            targetEntity = this.GetTurretTarget(shooterComp);
            return(Target.CreateTargetForTurret(targetEntity));
        }
コード例 #7
0
        public void InvalidateCurrentTarget(SmartEntity entity)
        {
            ShooterComponent shooterComp = entity.ShooterComp;

            if (shooterComp == null)
            {
                return;
            }
            shooterComp.Target = null;
            SecondaryTargetsComponent secondaryTargetsComp = entity.SecondaryTargetsComp;

            if (secondaryTargetsComp != null)
            {
                secondaryTargetsComp.ObstacleTarget         = null;
                secondaryTargetsComp.CurrentAlternateTarget = null;
                secondaryTargetsComp.AlternateTargets       = null;
                secondaryTargetsComp.WallTargets            = null;
                secondaryTargetsComp.CurrentWallTarget      = null;
            }
        }
コード例 #8
0
        protected override void OnTargetIsDead(SmartEntity troop)
        {
            ShooterComponent          shooterComp          = troop.ShooterComp;
            SecondaryTargetsComponent secondaryTargetsComp = troop.SecondaryTargetsComp;

            this.StopAttackingIfAttacking(troop);
            if (secondaryTargetsComp.ObstacleTarget != null)
            {
                secondaryTargetsComp.ObstacleTarget = null;
                return;
            }
            if (secondaryTargetsComp.CurrentAlternateTarget != null)
            {
                secondaryTargetsComp.CurrentAlternateTarget = null;
                return;
            }
            if (secondaryTargetsComp.CurrentWallTarget != null)
            {
                secondaryTargetsComp.CurrentWallTarget = null;
                return;
            }
            shooterComp.Target = null;
        }
コード例 #9
0
 public override object Remove(Type compCls)
 {
     if (compCls == typeof(AreaTriggerComponent))
     {
         this.AreaTriggerComp = null;
     }
     else if (compCls == typeof(ArmoryComponent))
     {
         this.ArmoryComp = null;
     }
     else if (compCls == typeof(AssetComponent))
     {
         this.AssetComp = null;
     }
     else if (compCls == typeof(AttackerComponent))
     {
         this.AttackerComp = null;
     }
     else if (compCls == typeof(BarracksComponent))
     {
         this.BarracksComp = null;
     }
     else if (compCls == typeof(BoardItemComponent))
     {
         this.BoardItemComp = null;
     }
     else if (compCls == typeof(BuildingAnimationComponent))
     {
         this.BuildingAnimationComp = null;
     }
     else if (compCls == typeof(BuildingComponent))
     {
         this.BuildingComp = null;
     }
     else if (compCls == typeof(CantinaComponent))
     {
         this.CantinaComp = null;
     }
     else if (compCls == typeof(ChampionComponent))
     {
         this.ChampionComp = null;
     }
     else if (compCls == typeof(CivilianComponent))
     {
         this.CivilianComp = null;
     }
     else if (compCls == typeof(ClearableComponent))
     {
         this.ClearableComp = null;
     }
     else if (compCls == typeof(DamageableComponent))
     {
         this.DamageableComp = null;
     }
     else if (compCls == typeof(DefenderComponent))
     {
         this.DefenderComp = null;
     }
     else if (compCls == typeof(DefenseLabComponent))
     {
         this.DefenseLabComp = null;
     }
     else if (compCls == typeof(DroidComponent))
     {
         this.DroidComp = null;
     }
     else if (compCls == typeof(DroidHutComponent))
     {
         this.DroidHutComp = null;
     }
     else if (compCls == typeof(SquadBuildingComponent))
     {
         this.SquadBuildingComp = null;
     }
     else if (compCls == typeof(NavigationCenterComponent))
     {
         this.NavigationCenterComp = null;
     }
     else if (compCls == typeof(FactoryComponent))
     {
         this.FactoryComp = null;
     }
     else if (compCls == typeof(FleetCommandComponent))
     {
         this.FleetCommandComp = null;
     }
     else if (compCls == typeof(FollowerComponent))
     {
         this.FollowerComp = null;
     }
     else if (compCls == typeof(GameObjectViewComponent))
     {
         this.GameObjectViewComp = null;
     }
     else if (compCls == typeof(GeneratorComponent))
     {
         this.GeneratorComp = null;
     }
     else if (compCls == typeof(GeneratorViewComponent))
     {
         this.GeneratorViewComp = null;
     }
     else if (compCls == typeof(HealerComponent))
     {
         this.HealerComp = null;
     }
     else if (compCls == typeof(HealthComponent))
     {
         this.HealthComp = null;
     }
     else if (compCls == typeof(TroopShieldComponent))
     {
         this.TroopShieldComp = null;
     }
     else if (compCls == typeof(TroopShieldViewComponent))
     {
         this.TroopShieldViewComp = null;
     }
     else if (compCls == typeof(TroopShieldHealthComponent))
     {
         this.TroopShieldHealthComp = null;
     }
     else if (compCls == typeof(HealthViewComponent))
     {
         this.HealthViewComp = null;
     }
     else if (compCls == typeof(HQComponent))
     {
         this.HQComp = null;
     }
     else if (compCls == typeof(KillerComponent))
     {
         this.KillerComp = null;
     }
     else if (compCls == typeof(LootComponent))
     {
         this.LootComp = null;
     }
     else if (compCls == typeof(MeterShaderComponent))
     {
         this.MeterShaderComp = null;
     }
     else if (compCls == typeof(OffenseLabComponent))
     {
         this.OffenseLabComp = null;
     }
     else if (compCls == typeof(PathingComponent))
     {
         this.PathingComp = null;
     }
     else if (compCls == typeof(SecondaryTargetsComponent))
     {
         this.SecondaryTargetsComp = null;
     }
     else if (compCls == typeof(ShieldBorderComponent))
     {
         this.ShieldBorderComp = null;
     }
     else if (compCls == typeof(ShieldGeneratorComponent))
     {
         this.ShieldGeneratorComp = null;
     }
     else if (compCls == typeof(SizeComponent))
     {
         this.SizeComp = null;
     }
     else if (compCls == typeof(ShooterComponent))
     {
         this.ShooterComp = null;
     }
     else if (compCls == typeof(StarportComponent))
     {
         this.StarportComp = null;
     }
     else if (compCls == typeof(StateComponent))
     {
         this.StateComp = null;
     }
     else if (compCls == typeof(StorageComponent))
     {
         this.StorageComp = null;
     }
     else if (compCls == typeof(SupportComponent))
     {
         this.SupportComp = null;
     }
     else if (compCls == typeof(SupportViewComponent))
     {
         this.SupportViewComp = null;
     }
     else if (compCls == typeof(TacticalCommandComponent))
     {
         this.TacticalCommandComp = null;
     }
     else if (compCls == typeof(ChampionPlatformComponent))
     {
         this.ChampionPlatformComp = null;
     }
     else if (compCls == typeof(TeamComponent))
     {
         this.TeamComp = null;
     }
     else if (compCls == typeof(TrackingComponent))
     {
         this.TrackingComp = null;
     }
     else if (compCls == typeof(TrackingGameObjectViewComponent))
     {
         this.TrackingGameObjectViewComp = null;
     }
     else if (compCls == typeof(TransformComponent))
     {
         this.TransformComp = null;
     }
     else if (compCls == typeof(TransportComponent))
     {
         this.TransportComp = null;
     }
     else if (compCls == typeof(TroopComponent))
     {
         this.TroopComp = null;
     }
     else if (compCls == typeof(TurretBuildingComponent))
     {
         this.TurretBuildingComp = null;
     }
     else if (compCls == typeof(TurretShooterComponent))
     {
         this.TurretShooterComp = null;
     }
     else if (compCls == typeof(WalkerComponent))
     {
         this.WalkerComp = null;
     }
     else if (compCls == typeof(WallComponent))
     {
         this.WallComp = null;
     }
     else if (compCls == typeof(BuffComponent))
     {
         this.BuffComp = null;
     }
     else if (compCls == typeof(TrapComponent))
     {
         this.TrapComp = null;
     }
     else if (compCls == typeof(TrapViewComponent))
     {
         this.TrapViewComp = null;
     }
     else if (compCls == typeof(HousingComponent))
     {
         this.HousingComp = null;
     }
     else if (compCls == typeof(SpawnComponent))
     {
         this.SpawnComp = null;
     }
     return(base.Remove(compCls));
 }
コード例 #10
0
        protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls)
        {
            bool flag = false;

            if (comp is AreaTriggerComponent)
            {
                this.AreaTriggerComp = (AreaTriggerComponent)comp;
                flag = true;
            }
            if (comp is ArmoryComponent)
            {
                this.ArmoryComp = (ArmoryComponent)comp;
                flag            = true;
            }
            if (comp is AssetComponent)
            {
                this.AssetComp = (AssetComponent)comp;
                flag           = true;
            }
            if (comp is AttackerComponent)
            {
                this.AttackerComp = (AttackerComponent)comp;
                flag = true;
            }
            if (comp is BarracksComponent)
            {
                this.BarracksComp = (BarracksComponent)comp;
                flag = true;
            }
            if (comp is BoardItemComponent)
            {
                this.BoardItemComp = (BoardItemComponent)comp;
                flag = true;
            }
            if (comp is BuildingAnimationComponent)
            {
                this.BuildingAnimationComp = (BuildingAnimationComponent)comp;
                flag = true;
            }
            if (comp is BuildingComponent)
            {
                this.BuildingComp = (BuildingComponent)comp;
                flag = true;
            }
            if (comp is ChampionComponent)
            {
                this.ChampionComp = (ChampionComponent)comp;
                flag = true;
            }
            if (comp is CivilianComponent)
            {
                this.CivilianComp = (CivilianComponent)comp;
                flag = true;
            }
            if (comp is ClearableComponent)
            {
                this.ClearableComp = (ClearableComponent)comp;
                flag = true;
            }
            if (comp is DamageableComponent)
            {
                this.DamageableComp = (DamageableComponent)comp;
                flag = true;
            }
            if (comp is DefenderComponent)
            {
                this.DefenderComp = (DefenderComponent)comp;
                flag = true;
            }
            if (comp is DefenseLabComponent)
            {
                this.DefenseLabComp = (DefenseLabComponent)comp;
                flag = true;
            }
            if (comp is DroidComponent)
            {
                this.DroidComp = (DroidComponent)comp;
                flag           = true;
            }
            if (comp is DroidHutComponent)
            {
                this.DroidHutComp = (DroidHutComponent)comp;
                flag = true;
            }
            if (comp is SquadBuildingComponent)
            {
                this.SquadBuildingComp = (SquadBuildingComponent)comp;
                flag = true;
            }
            if (comp is NavigationCenterComponent)
            {
                this.NavigationCenterComp = (NavigationCenterComponent)comp;
                flag = true;
            }
            if (comp is FactoryComponent)
            {
                this.FactoryComp = (FactoryComponent)comp;
                flag             = true;
            }
            if (comp is CantinaComponent)
            {
                this.CantinaComp = (CantinaComponent)comp;
                flag             = true;
            }
            if (comp is FleetCommandComponent)
            {
                this.FleetCommandComp = (FleetCommandComponent)comp;
                flag = true;
            }
            if (comp is FollowerComponent)
            {
                this.FollowerComp = (FollowerComponent)comp;
                flag = true;
            }
            if (comp is GameObjectViewComponent)
            {
                this.GameObjectViewComp = (GameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is GeneratorComponent)
            {
                this.GeneratorComp = (GeneratorComponent)comp;
                flag = true;
            }
            if (comp is GeneratorViewComponent)
            {
                this.GeneratorViewComp = (GeneratorViewComponent)comp;
                flag = true;
            }
            if (comp is HealerComponent)
            {
                this.HealerComp = (HealerComponent)comp;
                flag            = true;
            }
            if (comp is TroopShieldComponent)
            {
                this.TroopShieldComp = (TroopShieldComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldViewComponent)
            {
                this.TroopShieldViewComp = (TroopShieldViewComponent)comp;
                flag = true;
            }
            if (comp is TroopShieldHealthComponent)
            {
                this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp;
                flag = true;
            }
            if (comp is HealthComponent)
            {
                this.HealthComp = (HealthComponent)comp;
                flag            = true;
            }
            if (comp is HealthViewComponent)
            {
                this.HealthViewComp = (HealthViewComponent)comp;
                flag = true;
            }
            if (comp is HQComponent)
            {
                this.HQComp = (HQComponent)comp;
                flag        = true;
            }
            if (comp is KillerComponent)
            {
                this.KillerComp = (KillerComponent)comp;
                flag            = true;
            }
            if (comp is LootComponent)
            {
                this.LootComp = (LootComponent)comp;
                flag          = true;
            }
            if (comp is MeterShaderComponent)
            {
                this.MeterShaderComp = (MeterShaderComponent)comp;
                flag = true;
            }
            if (comp is OffenseLabComponent)
            {
                this.OffenseLabComp = (OffenseLabComponent)comp;
                flag = true;
            }
            if (comp is PathingComponent)
            {
                this.PathingComp = (PathingComponent)comp;
                flag             = true;
            }
            if (comp is SecondaryTargetsComponent)
            {
                this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp;
                flag = true;
            }
            if (comp is ShieldBorderComponent)
            {
                this.ShieldBorderComp = (ShieldBorderComponent)comp;
                flag = true;
            }
            if (comp is ShieldGeneratorComponent)
            {
                this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp;
                flag = true;
            }
            if (comp is SizeComponent)
            {
                this.SizeComp = (SizeComponent)comp;
                flag          = true;
            }
            if (comp is ShooterComponent)
            {
                this.ShooterComp = (ShooterComponent)comp;
                flag             = true;
            }
            if (comp is StarportComponent)
            {
                this.StarportComp = (StarportComponent)comp;
                flag = true;
            }
            if (comp is StateComponent)
            {
                this.StateComp = (StateComponent)comp;
                flag           = true;
            }
            if (comp is StorageComponent)
            {
                this.StorageComp = (StorageComponent)comp;
                flag             = true;
            }
            if (comp is SupportComponent)
            {
                this.SupportComp = (SupportComponent)comp;
                flag             = true;
            }
            if (comp is SupportViewComponent)
            {
                this.SupportViewComp = (SupportViewComponent)comp;
                flag = true;
            }
            if (comp is TacticalCommandComponent)
            {
                this.TacticalCommandComp = (TacticalCommandComponent)comp;
                flag = true;
            }
            if (comp is ChampionPlatformComponent)
            {
                this.ChampionPlatformComp = (ChampionPlatformComponent)comp;
                flag = true;
            }
            if (comp is TeamComponent)
            {
                this.TeamComp = (TeamComponent)comp;
                flag          = true;
            }
            if (comp is TrackingComponent)
            {
                this.TrackingComp = (TrackingComponent)comp;
                flag = true;
            }
            if (comp is TrackingGameObjectViewComponent)
            {
                this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp;
                flag = true;
            }
            if (comp is TransformComponent)
            {
                this.TransformComp = (TransformComponent)comp;
                flag = true;
            }
            if (comp is TransportComponent)
            {
                this.TransportComp = (TransportComponent)comp;
                flag = true;
            }
            if (comp is TroopComponent)
            {
                this.TroopComp = (TroopComponent)comp;
                flag           = true;
            }
            if (comp is TurretBuildingComponent)
            {
                this.TurretBuildingComp = (TurretBuildingComponent)comp;
                flag = true;
            }
            if (comp is TurretShooterComponent)
            {
                this.TurretShooterComp = (TurretShooterComponent)comp;
                flag = true;
            }
            if (comp is WalkerComponent)
            {
                this.WalkerComp = (WalkerComponent)comp;
                flag            = true;
            }
            if (comp is WallComponent)
            {
                this.WallComp = (WallComponent)comp;
                flag          = true;
            }
            if (comp is BuffComponent)
            {
                this.BuffComp = (BuffComponent)comp;
                flag          = true;
            }
            if (comp is TrapComponent)
            {
                this.TrapComp = (TrapComponent)comp;
                flag          = true;
            }
            if (comp is TrapViewComponent)
            {
                this.TrapViewComp = (TrapViewComponent)comp;
                flag = true;
            }
            if (comp is HousingComponent)
            {
                this.HousingComp = (HousingComponent)comp;
                flag             = true;
            }
            if (comp is ScoutTowerComponent)
            {
                this.ScoutTowerComp = (ScoutTowerComponent)comp;
                flag = true;
            }
            if (comp is SpawnComponent)
            {
                this.SpawnComp = (SpawnComponent)comp;
                flag           = true;
            }
            if (!flag && compCls != null)
            {
                Service.Logger.Error("Invalid component add: " + compCls.Name);
            }
            return(base.AddComponentAndDispatchAddEvent(comp, compCls));
        }
コード例 #11
0
        public void RotateGameObject(SmartEntity entity, float dx, float dz, float dt)
        {
            GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp;
            TransformComponent      transformComp      = entity.TransformComp;

            if (entity.TroopComp != null && entity.TroopComp.TroopShooterVO.TargetSelf && transformComp.RotationInitialized)
            {
                return;
            }
            float                     num                     = transformComp.Rotation;
            bool                      flag                    = dx != 0f || dz != 0f;
            SmartEntity               smartEntity             = null;
            GameObjectViewComponent   gameObjectViewComponent = null;
            SecondaryTargetsComponent secondaryTargetsComp    = entity.SecondaryTargetsComp;
            ShooterComponent          shooterComp             = entity.ShooterComp;

            if (secondaryTargetsComp != null && shooterComp != null)
            {
                ShooterController shooterController = Service.Get <ShooterController>();
                smartEntity = shooterController.GetTroopTarget(secondaryTargetsComp, shooterComp);
                if (smartEntity != null && (gameObjectViewComponent = smartEntity.GameObjectViewComp) == null)
                {
                    smartEntity = shooterController.GetPrimaryTarget(shooterComp);
                    if (smartEntity != null)
                    {
                        gameObjectViewComponent = smartEntity.GameObjectViewComp;
                    }
                }
            }
            else
            {
                PathingComponent pathingComp = entity.PathingComp;
                if (pathingComp != null)
                {
                    smartEntity = pathingComp.Target;
                    if (smartEntity != null)
                    {
                        gameObjectViewComponent = smartEntity.GameObjectViewComp;
                    }
                }
            }
            bool flag2 = !transformComp.RotationInitialized;

            if (flag2 && smartEntity == null && (entity.DefenderComp != null || TroopController.IsEntityHealer(entity)))
            {
                gameObjectViewComp.MainGameObject.SetActive(true);
                transformComp.RotationInitialized = true;
            }
            else
            {
                bool flag3 = flag2 || entity.StateComp.CurState == EntityState.Attacking || entity.StateComp.CurState == EntityState.Turning;
                if (flag3 && gameObjectViewComponent != null)
                {
                    gameObjectViewComp.ComputeRotationToTarget(gameObjectViewComponent, ref num);
                    flag = false;
                    if (flag2)
                    {
                        gameObjectViewComp.MainGameObject.SetActive(true);
                        transformComp.Rotation            = num;
                        transformComp.RotationInitialized = true;
                    }
                }
            }
            if (flag)
            {
                num = Mathf.Atan2(dz, dx);
            }
            num = MathUtils.MinAngle(transformComp.Rotation, num);
            float num2       = (float)entity.WalkerComp.SpeedVO.RotationSpeed / 1000f;
            float smoothTime = 0.7853982f / num2;
            float num3       = (dt == 0f) ? transformComp.Rotation : Mathf.SmoothDampAngle(transformComp.Rotation, num, ref transformComp.RotationVelocity, smoothTime, num2, dt);

            num3 = MathUtils.WrapAngle(num3);
            gameObjectViewComp.Rotate(num3 + -1.57079637f);
            transformComp.Rotation = num3;
        }
コード例 #12
0
ファイル: Target.cs プロジェクト: Hengle/swc-decompiled
        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 = troopEntity.TroopComp.TroopType.IsHealer ? troopEntity.TransformComp : targetEntity.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);
        }
コード例 #13
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.Get <EventManager>().SendEvent(EventId.TroopCreated, smartEntity);
            if (isShooter)
            {
                smartEntity.ShooterComp.TargetingDelayed = (teamType == TeamType.Attacker);
                HealthType healthType = troopType.IsHealer ? HealthType.Healing : HealthType.Damaging;
                smartEntity.ShooterComp.AttackFSM = new AttackFSM(Service.Get <BattleController>(), smartEntity, smartEntity.StateComp, smartEntity.ShooterComp, smartEntity.TransformComp, healthType);
                if (troopType.IsHealer)
                {
                    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.Get <EntityViewManager>().LoadEntityAsset(smartEntity);
            }
            return(smartEntity);
        }