Пример #1
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            attackCooldown += deltaTime;
            target          = CollisionManager.CollidesWithBuilding(this);

            if (target == null)
            {
                if (Direction == EnemyDirection.ToLeft)
                {
                    X -= movingSpeed / 100 * deltaTime;
                }
                else if (Direction == EnemyDirection.ToRight)
                {
                    X += movingSpeed / 100 * deltaTime;
                }
            }
            else
            {
                if (attackCooldown >= 1000f / attackSpeed)
                {
                    target.InflictDamage(attackPower);
                    attackCooldown = 0;
                    if (attackSound != null)
                    {
                        SoundManager.PlayClip(attackSound);
                    }
                }
            }
        }
Пример #2
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            attackCooldown += deltaTime;
            target          = CollisionManager.CollidesWithBuilding(rangeBox);

            if (target == null)
            {
                if (Direction == EnemyDirection.ToLeft)
                {
                    X -= movingSpeed / 100 * deltaTime;
                }
                else if (Direction == EnemyDirection.ToRight)
                {
                    X += movingSpeed / 100 * deltaTime;
                }
                MosCraciun(false);
            }
            else
            {
                MosCraciun(true);
                if ((attackCooldown >= 1000f / attackSpeed) ||
                    (burstFire && (currentBurstProjectile < burstFireAmmount)) && (attackCooldown >= 1000f / burstFireSpeed))
                {
                    if (burstFire)
                    {
                        ++currentBurstProjectile;
                        if (attackCooldown >= 1000f / attackSpeed)
                        {
                            currentBurstProjectile = 1;
                        }
                    }

                    double projectileX;
                    float  projectileDirection = (float)((GameManager.RNG.NextDouble() - .5f) * Math.PI / precision);
                    if (direction == EnemyDirection.ToLeft)
                    {
                        projectileX          = X;
                        projectileDirection += (float)Math.PI;
                    }
                    else
                    {
                        projectileX = X + Width;
                        //projectileDirection = 0;
                    }
                    EnemyProjectile p = new EnemyProjectile(content, projectileX, Y + Height / 2, projectileDirection, attackPower, laserAssetName);
                    attackCooldown = 0;
                    if (attackSound != null)
                    {
                        SoundManager.PlayClip(attackSound);
                    }
                }
            }
        }
Пример #3
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            Building target = CollisionManager.CollidesWithForcefield(this);

            if (target == null)
            {
                target = CollisionManager.CollidesWithBuilding(this);
            }

            if (target != null)
            {
                target.InflictDamage(attackPower);
                Alive = false;
            }
        }
Пример #4
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);
            altitudeVariation += deltaTime;

            attackCooldown += deltaTime;

            if (target != null && !target.Alive)
            {
                target = null;
            }

            if (target == null)
            {
                target = CollisionManager.CollidesWithTurret(detectionBox);
            }

            if (target == null)
            {
                target = CollisionManager.CollidesWithForcefield(detectionBox);
            }

            if (target == null)
            {
                target = CollisionManager.CollidesWithBuilding(detectionBox);
            }

            else
            {
                if (attackCooldown >= 1000f / attackSpeed)
                {
                    double          projectileX         = X + Width / 2;
                    double          projectileY         = Y + Height;
                    float           projectileDirection = (float)Math.PI / 2;
                    EnemyProjectile p1 = new EnemyProjectile(content, projectileX, projectileY, projectileDirection, attackPower, "ufoprojectile");
                    EnemyProjectile p2 = new EnemyProjectile(content, projectileX - 15, projectileY, projectileDirection, attackPower, "ufoprojectile");
                    EnemyProjectile p3 = new EnemyProjectile(content, projectileX - 30, projectileY, projectileDirection, attackPower, "ufoprojectile");
                    EnemyProjectile p4 = new EnemyProjectile(content, projectileX + 15, projectileY, projectileDirection, attackPower, "ufoprojectile");
                    EnemyProjectile p5 = new EnemyProjectile(content, projectileX + 30, projectileY, projectileDirection, attackPower, "ufoprojectile");
                    attackCooldown = 0;
                    if (attackSound != null)
                    {
                        SoundManager.PlayClip(attackSound);
                    }
                }
            }

            if (direction == EnemyDirection.ToLeft)
            {
                X -= movingSpeed / 100 * deltaTime;

                if (X + Width < 0)
                {
                    direction = EnemyDirection.ToRight;
                }
            }
            else
            {
                X += movingSpeed / 100 * deltaTime;

                if (X > Game.GAME_WIDTH)
                {
                    direction = EnemyDirection.ToLeft;
                }
            }
            Y = Y - altitudeVariationModifier * Math.Sin(altitudeVariation / 300) * deltaTime * 6 / 100;
        }
Пример #5
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            attackCooldown += deltaTime;

            target = CollisionManager.CollidesWithBuilding(rangeBox);

            if (target == null)
            {
                if (Direction == EnemyDirection.ToLeft)
                {
                    X -= movingSpeed / 100 * deltaTime;
                }
                else if (Direction == EnemyDirection.ToRight)
                {
                    X += movingSpeed / 100 * deltaTime;
                }
                EnableAnimation = true;

                beam = null;
            }
            else
            {
                bool forceField = typeof(Forcefield).IsInstanceOfType(target);

                if (beam == null)
                {
                    int beamX;
                    int beamY = Math.Max((int)Y + Height / 2, (int)target.Y + target.Height / 2);
                    int beamTargetX;

                    if (direction == EnemyDirection.ToLeft)
                    {
                        if (forceField)
                        {
                            beamX       = (int)target.X + target.Width;
                            beamTargetX = (int)X;
                        }
                        else
                        {
                            beamX       = (int)X;
                            beamTargetX = (int)target.X + target.Width;
                        }
                    }
                    else
                    {
                        if (forceField)
                        {
                            beamX       = (int)target.X;
                            beamTargetX = (int)X + Width;
                        }
                        else
                        {
                            beamX       = (int)X + Width;
                            beamTargetX = (int)target.X;
                        }
                    }

                    beam = new Electrobeam(content, beamX, beamY, beamTargetX, forceField);
                }

                if (attackCooldown >= 1000f / attackSpeed)
                {
                    target.InflictDamage(attackPower);

                    if (forceField)
                    {
                        healthBar.ColorScheme = HealthBar.HealthBarColoring.Forcefield;
                        healthBar.Health     += attackPower / 2;
                    }
                    else
                    {
                        healthBar.ColorScheme = HealthBar.HealthBarColoring.Normal;
                    }

                    if (healthBar.Health > healthBar.MaxHealth + healthBar.MaxHealth / 2)
                    {
                        healthBar.Health = healthBar.MaxHealth + healthBar.MaxHealth / 2;
                    }

                    attackCooldown = 0;
                }

                EnableAnimation = false;
            }

            if (beam != null)
            {
                beam.Update(deltaTime);
            }
        }