private void SpawnChargeEmitter(SmartEntity owner)
        {
            ShooterComponent shooterComp = owner.ShooterComp;

            if (shooterComp == null)
            {
                return;
            }
            ProjectileTypeVO projectileType = shooterComp.ShooterVO.ProjectileType;

            if (string.IsNullOrEmpty(projectileType.ChargeAssetName))
            {
                return;
            }
            GameObjectViewComponent gameObjectViewComp = owner.GameObjectViewComp;

            if (gameObjectViewComp == null || gameObjectViewComp.GunLocators.Count == 0 || gameObjectViewComp.GunLocators[0].Count == 0)
            {
                return;
            }
            GameObject gameObject = gameObjectViewComp.GunLocators[0][0];

            if (gameObject == null)
            {
                return;
            }
            Vector3 position = gameObject.transform.position;

            this.StartDirectionalEmitter(owner, gameObject, position, Vector3.zero, projectileType.ChargeAssetName, projectileType.MuzzleFlashFadeTime);
        }
示例#2
0
        private void ApplyBuffFromBullet(Bullet bullet)
        {
            SmartEntity      target         = bullet.Target;
            ProjectileTypeVO projectileType = bullet.ProjectileType;

            if (target == null || target.TeamComp == null || projectileType == null)
            {
                return;
            }
            if (target.HealthComp == null || target.HealthComp.IsDead())
            {
                return;
            }
            string[] applyBuffs = projectileType.ApplyBuffs;
            if (applyBuffs == null || applyBuffs.Length == 0)
            {
                return;
            }
            ArmorType armorType = GameUtils.DeduceArmorType(target);

            if (armorType == ArmorType.Invalid)
            {
                return;
            }
            bool flag  = bullet.Owner == target;
            bool flag2 = !flag && bullet.OwnerTeam == target.TeamComp.TeamType;
            StaticDataController staticDataController = Service.StaticDataController;
            int i   = 0;
            int num = applyBuffs.Length;

            while (i < num)
            {
                BuffTypeVO buffTypeVO = staticDataController.Get <BuffTypeVO>(applyBuffs[i]);
                if (flag)
                {
                    if (buffTypeVO.ApplyToSelf)
                    {
                        goto IL_FC;
                    }
                }
                else if (flag2)
                {
                    if (buffTypeVO.ApplyToAllies)
                    {
                        goto IL_FC;
                    }
                }
                else if (buffTypeVO.ApplyToEnemies)
                {
                    goto IL_FC;
                }
IL_10D:
                i++;
                continue;
IL_FC:
                this.TryAddBuffStack(target, buffTypeVO, armorType, BuffVisualPriority.Default, bullet.Owner);
                goto IL_10D;
            }
        }
示例#3
0
 public static void AddProjectileAssets(ProjectileTypeVO ptVO, List <IAssetVO> assets, IDataController dc)
 {
     if (ptVO != null)
     {
         assets.Add(ptVO);
         ProjectileUtils.AddBuffProjectileAssets(ptVO.ApplyBuffs, assets, dc);
     }
 }
示例#4
0
        private void AddProjectileInFlight(ProjectileTypeVO vo)
        {
            if (!this.thereAreProjectilesInFlight)
            {
                this.events.RegisterObserver(this, EventId.ProjectileViewPathComplete, EventPriority.Default);
                this.events.RegisterObserver(this, EventId.ProjectileImpacted, EventPriority.Default);
                this.events.RegisterObserver(this, EventId.BattleEndProcessing, EventPriority.Default);
                this.thereAreProjectilesInFlight = true;
            }
            if (!this.projectilesInFlight.ContainsKey(vo))
            {
                this.projectilesInFlight.Add(vo, 1);
                return;
            }
            Dictionary <ProjectileTypeVO, int> dictionary = this.projectilesInFlight;

            dictionary[vo]++;
        }
示例#5
0
        public Path(BoardCell fromCell, BoardCell toCell, BoardCell targetAt, int maxLength, PathTroopParams troopParams, PathBoardParams boardParams)
        {
            this.pathCells     = new BoardCellDynamicArray(64);
            this.scratchCells  = new BoardCellDynamicArray(64);
            this.turns         = new BoardCellDynamicArray(64);
            this.turnDistances = new List <int>(64);
            BoardController boardController = Service.BoardController;

            this.board                 = boardController.Board;
            this.pathingManager        = Service.PathingManager;
            this.startCell             = fromCell;
            this.destCell              = toCell;
            this.targetCell            = targetAt;
            this.NoWall                = (boardParams.IgnoreWall || troopParams.CrushesWalls);
            this.crushesWalls          = troopParams.CrushesWalls;
            this.destructible          = boardParams.Destructible;
            this.isHealer              = troopParams.IsHealer;
            this.TroopWidth            = troopParams.TroopWidth;
            this.damagePerSecond       = troopParams.DPS;
            this.maxShooterRange       = troopParams.MaxRange;
            this.targetInRangeModifier = troopParams.TargetInRangeModifier;
            if (this.isHealer && this.maxShooterRange > troopParams.SupportRange)
            {
                this.maxShooterRange = troopParams.SupportRange;
            }
            this.minShooterRange    = troopParams.MinRange;
            this.maxSpeed           = troopParams.MaxSpeed;
            this.heristicMultiplier = (int)troopParams.PathSearchWidth;
            this.maxPathLength      = ((!this.isHealer) ? maxLength : -1);
            this.melee                        = troopParams.IsMelee;
            this.overWalls                    = troopParams.IsOverWall;
            this.projectileType               = troopParams.ProjectileType;
            this.isTargetShield               = troopParams.IsTargetShield;
            this.openCells                    = new HeapPriorityQueue(boardController.GetPriorityQueueSize());
            this.curPathingCell               = this.pathingManager.GetPathingCell();
            this.curPathingCell.Cell          = this.startCell;
            this.startCell.PathInfo           = this.curPathingCell;
            this.curPathingCell.InRange       = this.InRangeOfTarget(this.startCell);
            this.curPathingCell.RemainingCost = this.HeuristicDiagonal(this.startCell, this.destCell);
            this.curPathingCell.PathLength    = 0;
            this.curPathingCell.PastCost      = 0;
            this.curPathingCell.InClosedSet   = true;
        }
示例#6
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);
        }
示例#7
0
        private void RemoveProjectileInFlight(ProjectileTypeVO vo)
        {
            if (!this.projectilesInFlight.ContainsKey(vo))
            {
                return;
            }
            Dictionary <ProjectileTypeVO, int> dictionary;

            (dictionary = this.projectilesInFlight)[vo] = dictionary[vo] - 1;
            if (this.projectilesInFlight[vo] == 0)
            {
                this.projectilesInFlight.Remove(vo);
            }
            if (this.projectilesInFlight.Keys.Count == 0)
            {
                this.events.UnregisterObserver(this, EventId.ProjectileViewPathComplete);
                this.events.UnregisterObserver(this, EventId.ProjectileImpacted);
                this.thereAreProjectilesInFlight = false;
            }
        }
示例#8
0
 private static void AddProjectileAssetNames(ProjectileTypeVO ptVO, List <string> assetNames)
 {
     if (!string.IsNullOrEmpty(ptVO.BulletAssetName))
     {
         assetNames.Add(ptVO.BulletAssetName);
     }
     if (!string.IsNullOrEmpty(ptVO.GroundBulletAssetName))
     {
         assetNames.Add(ptVO.GroundBulletAssetName);
     }
     if (!string.IsNullOrEmpty(ptVO.ChargeAssetName))
     {
         assetNames.Add(ptVO.ChargeAssetName);
     }
     if (!string.IsNullOrEmpty(ptVO.MuzzleFlashAssetName))
     {
         assetNames.Add(ptVO.MuzzleFlashAssetName);
     }
     if (!string.IsNullOrEmpty(ptVO.HitSparkAssetName))
     {
         assetNames.Add(ptVO.HitSparkAssetName);
     }
 }
示例#9
0
        public static bool AreAllBulletAssetsLoaded(Bullet bullet, HashSet <IAssetVO> loadedAssets)
        {
            ProjectileTypeVO projectileType = bullet.ProjectileType;

            if (projectileType != null && !loadedAssets.Contains(projectileType))
            {
                return(false);
            }
            if (bullet.AppliedBuffs != null)
            {
                int i     = 0;
                int count = bullet.AppliedBuffs.Count;
                while (i < count)
                {
                    BuffTypeVO buffType = bullet.AppliedBuffs[i].BuffType;
                    if (buffType != null && !loadedAssets.Contains(buffType))
                    {
                        return(false);
                    }
                    i++;
                }
            }
            return(true);
        }
示例#10
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);
            }
        }
示例#11
0
 public void InitWithTargetPositionAndTravelTime(uint travelTime, Vector3 spawnWorldLocation, int targetBoardX, int targetBoardZ, TeamType ownerTeam, Entity attacker, HealthFragment healthFrag, ProjectileTypeVO projectileType, List <Buff> appliedBuffs, FactionType faction)
 {
     this.InitWithEverything(travelTime, 0, 0, spawnWorldLocation, null, targetBoardX, targetBoardZ, ownerTeam, attacker, healthFrag, projectileType, null);
     this.OwnerFaction = faction;
     this.AppliedBuffs = appliedBuffs;
     this.SetDefaultTargetWorldLocation(0f);
 }
        public Bullet SpawnProjectileForDeath(Vector3 spawnWorldLocation, SmartEntity attacker, ProjectileTypeVO deathProjectileType, uint deathProjectileDelay, int deathProjectileDistance, int deathProjectileDamage, out bool useRotation, ref int rotateDegrees)
        {
            useRotation = false;
            TransformComponent transformComp = attacker.TransformComp;
            int num  = transformComp.CenterGridX();
            int num2 = transformComp.CenterGridZ();

            if (spawnWorldLocation.y < 0f)
            {
                spawnWorldLocation = new Vector3(Units.BoardToWorldX(num), 0f, Units.BoardToWorldZ(num2));
            }
            Vector3 vector = spawnWorldLocation;

            if (deathProjectileDistance > 0)
            {
                this.ChooseTargetLocationForDeathProjectile(attacker, deathProjectileDistance, ref num, ref num2, out rotateDegrees);
                useRotation = true;
                Vector3 point = Vector3.right * (float)deathProjectileDistance;
                vector += Quaternion.Euler(0f, (float)rotateDegrees, 0f) * point;
            }
            HealthFragment healthFrag = new HealthFragment(attacker, HealthType.Damaging, deathProjectileDamage);
            TeamType       teamType   = attacker.TeamComp.TeamType;
            Bullet         bullet     = new Bullet();

            bullet.InitWithTargetPositionAndTravelTime(deathProjectileDelay, spawnWorldLocation, num, num2, teamType, attacker, healthFrag, deathProjectileType, null, FactionType.Invalid);
            bullet.SetTargetWorldLocation(vector);
            bullet.FlashTarget = (deathProjectileType.ApplyBuffs == null || deathProjectileType.ApplyBuffs.Length == 0);
            this.SpawnProjectileInternal(bullet, true, false);
            return(bullet);
        }
        public Bullet SpawnProjectileForTarget(uint travelTime, int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, Target target, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, bool allowSplash, List <Buff> appliedBuffs, FactionType faction, GameObject gunLocator)
        {
            Bullet newProjectileForTarget = this.GetNewProjectileForTarget(travelTime, spawnBoardX, spawnBoardZ, spawnWorldLocation, target, ownerTeam, attacker, projectileType, payload, appliedBuffs, faction, gunLocator);

            if (newProjectileForTarget != null)
            {
                this.SpawnProjectileInternal(newProjectileForTarget, allowSplash, false);
            }
            return(newProjectileForTarget);
        }
        public Bullet SpawnProjectileForTargetPosition(uint travelTime, Vector3 spawnWorldLocation, int targetBoardX, int targetBoardZ, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, List <Buff> appliedBuffs, FactionType faction, bool preventProjectileView)
        {
            Bullet bullet = new Bullet();

            bullet.InitWithTargetPositionAndTravelTime(travelTime, spawnWorldLocation, targetBoardX, targetBoardZ, ownerTeam, attacker, payload, projectileType, appliedBuffs, faction);
            this.SpawnProjectileInternal(bullet, true, preventProjectileView);
            return(bullet);
        }
        private Bullet GetNewProjectileForTarget(uint travelTime, int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, Target target, TeamType teamType, Entity attacker, ProjectileTypeVO projectileType, HealthFragment healthFrag, List <Buff> appliedBuffs, FactionType faction, GameObject gunLocator)
        {
            Bullet bullet = new Bullet();

            if (!bullet.InitWithTarget(spawnBoardX, spawnBoardZ, spawnWorldLocation, target, teamType, attacker, healthFrag, projectileType, appliedBuffs, faction, gunLocator))
            {
                return(null);
            }
            if (travelTime > 0u)
            {
                bullet.SetTravelTime(travelTime);
            }
            else
            {
                this.SetProjectileTravelTime(bullet, bullet.TargetBoardX, bullet.TargetBoardZ);
            }
            return(bullet);
        }
 public Bullet SpawnProjectileForTargetPosition(uint travelTime, Vector3 spawnWorldLocation, int targetBoardX, int targetBoardZ, HealthFragment payload, TeamType ownerTeam, Entity attacker, ProjectileTypeVO projectileType, List <Buff> appliedBuffs, FactionType faction)
 {
     return(this.SpawnProjectileForTargetPosition(travelTime, spawnWorldLocation, targetBoardX, targetBoardZ, payload, ownerTeam, attacker, projectileType, appliedBuffs, faction, false));
 }
示例#17
0
 public bool InitWithTarget(int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, Target target, TeamType ownerTeam, Entity attacker, HealthFragment healthFrag, ProjectileTypeVO projectileTypeVO, List <Buff> appliedBuffs, FactionType faction, GameObject gunLocator)
 {
     if (target == null)
     {
         return(false);
     }
     this.OwnerFaction = faction;
     this.AppliedBuffs = appliedBuffs;
     this.InitWithEverything(0u, spawnBoardX, spawnBoardZ, spawnWorldLocation, target.TargetEntity, target.TargetBoardX, target.TargetBoardZ, ownerTeam, attacker, healthFrag, projectileTypeVO, gunLocator);
     if (this.ProjectileType.IsBeam)
     {
         this.SetupBeam();
     }
     else
     {
         this.SetTargetWorldLocation(target.TargetWorldLocation);
     }
     return(true);
 }
示例#18
0
 public void AddSplash(ProjectileTypeVO splashVO)
 {
     this.SplashVO = splashVO;
 }
        private ProjectileView SpawnProjectile(Bullet bullet, bool isOnGround)
        {
            if (!ProjectileUtils.AreAllBulletAssetsLoaded(bullet, this.loadedAssets))
            {
                this.LoadBulletAssets(bullet);
                if (bullet.ProjectileType != null)
                {
                    Service.Get <StaRTSLogger>().Warn("Loading assets on demand for projectile " + bullet.ProjectileType.Uid);
                }
            }
            bool             isDeflection   = bullet.IsDeflection;
            ProjectileTypeVO projectileType = bullet.ProjectileType;
            GameObject       gunLocator     = bullet.GunLocator;
            Vector3          vector;

            if (!isDeflection && gunLocator != null)
            {
                vector = gunLocator.transform.position;
            }
            else
            {
                vector = bullet.SpawnWorldLocation;
            }
            Vector3 targetWorldLocation = bullet.TargetWorldLocation;

            if (isOnGround)
            {
                vector.y = 0f;
                targetWorldLocation.y = 0f;
            }
            else if (projectileType.IsBeam || (bullet.Owner != null && bullet.Target != null && bullet.Target.ShieldBorderComp != null))
            {
                targetWorldLocation.y = vector.y;
            }
            ProjectileView projectileView = (this.projectilePool.Count > 0) ? this.projectilePool.Pop() : new ProjectileView();

            projectileView.Init(projectileType, bullet, isOnGround);
            if (!isDeflection && !string.IsNullOrEmpty(projectileType.MuzzleFlashAssetName))
            {
                this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, projectileType.MuzzleFlashAssetName, projectileType.MuzzleFlashFadeTime);
                int num = 0;
                if (bullet.AppliedBuffs != null)
                {
                    num = bullet.AppliedBuffs.Count;
                }
                FactionType ownerFaction = bullet.OwnerFaction;
                for (int i = 0; i < num; i++)
                {
                    string muzzleAssetNameBasedOnFaction = bullet.AppliedBuffs[i].BuffType.GetMuzzleAssetNameBasedOnFaction(ownerFaction);
                    if (!string.IsNullOrEmpty(muzzleAssetNameBasedOnFaction))
                    {
                        this.StartDirectionalEmitter(bullet.Owner, gunLocator, vector, targetWorldLocation, muzzleAssetNameBasedOnFaction, projectileType.MuzzleFlashFadeTime);
                    }
                }
            }
            GameObject     gameObject      = null;
            float          num2            = bullet.TravelTime / 1000f;
            GameObject     gameObject2     = null;
            ParticleSystem particleSystem  = null;
            string         bulletAssetName = projectileType.GetBulletAssetName(isOnGround);
            EmitterPool    emitter         = this.GetEmitter(bulletAssetName);

            if (emitter != null)
            {
                float num3 = num2;
                float delayPostEmitterStop = 0f;
                if (projectileType.IsBeam)
                {
                    num3 = num2 * (float)(projectileType.BeamEmitterLength - projectileType.BeamInitialZeroes) / (float)(projectileType.BeamLifeLength - projectileType.BeamInitialZeroes);
                    delayPostEmitterStop = num2 - num3;
                }
                if (emitter is MultipleEmittersPool)
                {
                    MultipleEmittersPool multipleEmittersPool = (MultipleEmittersPool)emitter;
                    gameObject = multipleEmittersPool.GetEmitterRoot();
                    if (gameObject != null)
                    {
                        multipleEmittersPool.StopEmissionAndReturnToPool(gameObject, num3, delayPostEmitterStop);
                    }
                }
                else if (emitter is SingleEmitterPool)
                {
                    SingleEmitterPool singleEmitterPool = (SingleEmitterPool)emitter;
                    particleSystem = singleEmitterPool.GetEmitter();
                    if (particleSystem != null)
                    {
                        singleEmitterPool.StopEmissionAndReturnToPool(particleSystem, num3, delayPostEmitterStop);
                    }
                }
                if (this.meshes.ContainsKey(bulletAssetName))
                {
                    gameObject2 = this.meshes[bulletAssetName].GetMesh();
                }
            }
            Transform targetTransform = this.GetTargetTransform(bullet, vector, targetWorldLocation);

            if (gameObject2 != null && particleSystem != null)
            {
                projectileView.InitWithMeshAndEmitter(num2, vector, targetWorldLocation, gameObject2, particleSystem, targetTransform);
            }
            else if (gameObject2 != null && gameObject == null)
            {
                projectileView.InitWithMesh(num2, vector, targetWorldLocation, gameObject2, targetTransform);
            }
            else if (particleSystem != null)
            {
                projectileView.InitWithEmitter(num2, vector, targetWorldLocation, particleSystem, targetTransform);
            }
            else if (gameObject != null)
            {
                projectileView.InitWithEmitters(num2, vector, targetWorldLocation, gameObject, gameObject2, targetTransform);
            }
            else
            {
                projectileView.InitWithoutBullet(num2, vector, targetWorldLocation, targetTransform);
            }
            this.activeProjectiles.Add(projectileView);
            if (!isOnGround && !string.IsNullOrEmpty(projectileType.GroundBulletAssetName))
            {
                this.SpawnProjectile(bullet, true);
            }
            return(projectileView);
        }
示例#20
0
 public void Init(ProjectileTypeVO projectileType, Bullet bullet, bool isOnGround)
 {
     this.ProjectileType = projectileType;
     this.Bullet         = bullet;
     this.IsOnGround     = isOnGround;
 }
示例#21
0
 private void InitWithEverything(uint travelTime, int spawnBoardX, int spawnBoardZ, Vector3 spawnWorldLocation, SmartEntity target, int targetBoardX, int targetBoardZ, TeamType ownerTeam, Entity attacker, HealthFragment healthFrag, ProjectileTypeVO projectileType, GameObject gunLocator)
 {
     this.IsDeflection = false;
     this.SetTravelTime(travelTime);
     this.SpawnBoardX        = spawnBoardX;
     this.SpawnBoardZ        = spawnBoardZ;
     this.SpawnWorldLocation = spawnWorldLocation;
     this.GunLocator         = gunLocator;
     this.SetTarget(target);
     this.TargetBoardX   = targetBoardX;
     this.TargetBoardZ   = targetBoardZ;
     this.OwnerTeam      = ownerTeam;
     this.Owner          = (SmartEntity)attacker;
     this.HealthFrag     = healthFrag;
     this.ProjectileType = projectileType;
 }