Ejemplo n.º 1
0
        private void CustomActivity()
        {
            if (IsBeingPlaced == false)
            {
#if DEBUG
                if (DebugVariables.TurretsAimAtMouse)
                {
                    RotateToAimMouse();
                }
#endif

                if (targetEnemy != null && (targetEnemy.IsDead || !RangeCircleInstance.CollideAgainst(targetEnemy.CircleInstance)))
                {
                    targetEnemy = null;
                }

                if (targetEnemy == null && _potentialTargetList.Count > 0)
                {
                    ChooseTarget();
                }

                if (targetEnemy != null)
                {
                    RotateToAim();
                    SetAnimationFromAimRotation();
                    PerformFiringActivity();
                }
            }
        }
Ejemplo n.º 2
0
        private void CustomActivity()
        {
            if (IsBeingPlaced)
            {
                CurrentState = VariableState.InvalidLocation;
            }
            else
            {
#if DEBUG
                if (DebugVariables.TurretsAimAtMouse)
                {
                    RotateToAimMouse();
                }
#endif

                if (targetEnemy != null && (targetEnemy.IsDead || targetEnemy.HasReachedGoal || !RangeCircleInstance.CollideAgainst(targetEnemy.Collision) || MinimumRangeCircleInstance.CollideAgainst(targetEnemy.Collision)))
                {
                    targetEnemy = null;
                }

                if (targetEnemy == null && _potentialTargetList != null && _potentialTargetList.Count > 0)
                {
                    ChooseTarget();
                }

                if (targetEnemy != null)
                {
                    RotateToAim();
                    PerformFiringActivity();
                }
            }
        }
Ejemplo n.º 3
0
        private void CustomDestroy()
        {
            if (FiringSound != null && !FiringSound.IsDisposed)
            {
                FiringSound.Stop(true);
                FiringSound.Dispose();
            }

            AfterIsBeingPlacedSet = null;
            targetEnemy           = null;
        }
Ejemplo n.º 4
0
        private void ChooseTarget()
        {
            var       offScreenX         = -Camera.Main.OrthogonalWidth / 2;
            var       bestTargetProgress = 0.0;
            BaseEnemy newTarget          = null;

            foreach (var pt in _potentialTargetList)
            {
                if (pt.IsDead)
                {
                    continue;
                }
                if (pt.HasReachedGoal)
                {
                    continue;
                }
                if (pt.X < offScreenX)
                {
                    continue;
                }
                if (pt.IsFlying && this is BombardingTower)
                {
                    continue;
                }
                if (!pt.CollideAgainst(RangeCircleInstance))
                {
                    continue;
                }
                if (pt.CollideAgainst(MinimumRangeCircleInstance))
                {
                    continue;
                }

                var ptProgress = pt.GetProgress();
                if (ptProgress < bestTargetProgress)
                {
                    continue;
                }

                bestTargetProgress = ptProgress;
                newTarget          = pt;
            }

            if (newTarget != null)
            {
                targetEnemy = newTarget;
            }
        }
        public void HandleImpact(BaseEnemy enemy = null)
        {
#if DEBUG
            if (DebugVariables.SlowTimeForShots)
            {
                FlatRedBall.TimeManager.TimeFactor = 1;
            }
#endif
            PlayHitTargetSound();
            CurrentState = VariableState.Impact;
            UpdateAnimation();
            CustomHandleImpact(enemy);
            if (!(this is CannonProjectile))
            {
                CanStillDoDamage = false;
            }
            Velocity = Vector3.Zero;
        }
Ejemplo n.º 6
0
        private void PerformFiringActivity()
        {
            if (TimeManager.SecondsSince(LastFiredTime) > SecondsBetweenFiring)
            {
                var newProjectile = CreateNewProjectile();
                newProjectile.DamageInflicted        = AttackDamage;
                newProjectile.StatusEffectSeconds    = StatusEffectSeconds;
                newProjectile.StatusDamageMultiplier = StatusDamageMultiplier;
                newProjectile.Speed            = ProjectileSpeed;
                newProjectile.Position         = GetProjectilePositioning();
                newProjectile.Altitude         = ProjectileAltitude;
                newProjectile.AltitudeVelocity = CalculateAltitudeVelocity(newProjectile);

                var projectileAngle = GetAimAngle(newProjectile.Position);

                var direction = new Vector3(
                    (float)-Math.Cos(projectileAngle),
                    (float)-Math.Sin(projectileAngle), 0);
                direction.Normalize();

                newProjectile.Velocity = direction * newProjectile.Speed;

                newProjectile.RotationZ = (float)Math.Atan2(-newProjectile.XVelocity,
                                                            newProjectile.YVelocity + newProjectile.AltitudeVelocity);

                PlayFireSound();

                LastFiredTime = TimeManager.CurrentTime;
                OnFire?.Invoke();
#if DEBUG
                if (DebugVariables.SlowTimeForShots)
                {
                    FlatRedBall.TimeManager.TimeFactor = 0.01;
                }
#endif
                targetEnemy = null;
            }
        }
Ejemplo n.º 7
0
        private void ChooseTarget()
        {
            BaseEnemy newTarget = null;

            foreach (BaseEnemy pt in _potentialTargetList)
            {
                if (pt.IsDead)
                {
                    continue;
                }
                if (!pt.CircleInstance.CollideAgainst(RangeCircleInstance))
                {
                    continue;
                }
                newTarget = pt;
                break;
            }

            if (newTarget != null)
            {
                targetEnemy = newTarget;
            }
        }
 protected virtual void CustomHandleImpact(BaseEnemy enemy = null)
 {
 }