Пример #1
0
        public override void Update(float TimeEllapsed)
        {
            if (AttackType == AttackTypes.None)
            {
                if (Position.X <= 104)
                {
                    Speed.X = SpeedX * TimeEllapsed;
                }
                else if (Position.X >= 920)
                {
                    Speed.X = -SpeedX * TimeEllapsed;
                }

                --AttackTypeTimer;
                if (AttackTypeTimer <= 0)
                {
                    UpdateAttackTypeTimer();
                }
            }
            else if (AttackType == AttackTypes.Missiles)
            {
                --MissilesTimer;
                if (MissilesTimer <= 0)
                {
                    UpdateMissilesTimer();
                }

                ++MissilesPhaseTimer;

                if (MissilesPhaseTimer >= 150)
                {
                    MissilesPhaseTimer = 0;
                    AttackType         = AttackTypes.None;
                }
                if (Position.X <= 507)
                {
                    Speed.X = SpeedX * TimeEllapsed;
                }
                else if (Position.X >= 518)
                {
                    Speed.X = -SpeedX * TimeEllapsed;
                }
                else
                {
                    Position.X = 512;
                    Speed.X    = 0;
                }
            }
            else if (AttackType == AttackTypes.Laser)
            {
                LaserPhaseTimer += 1;
                if (LaserPhaseTimer < 90)
                {
                    new LaserParticle(new Vector2(Position.X - 20 + SuperTank2.Randomizer.Next(40), Position.Y + 118), SuperTank2.Randomizer.Next(360) * SuperTank2.DegToRad, SuperTank2.Randomizer.NextDouble() * 5).AddParticule();
                }
                else if (LaserPhaseTimer == 90)
                {
                    ActiveLaser = new LaserWeapon(new Vector2(Position.X, Position.Y + 111));
                    EnemyAttack.AddEnemyAttack(ActiveLaser);
                }
                else if (ActiveLaser.Lifetime <= 0)
                {
                    LaserPhaseTimer = 0;
                    AttackType      = AttackTypes.None;
                }
                Vehicule Near        = null;
                float    DistanceMin = float.MaxValue;
                for (int V = 0; V < Vehicule.ArrayVehicule.Length; V++)
                {
                    float Distance = Vector2.Distance(Position, Vehicule.ArrayVehicule[V].Position);
                    if (Distance < DistanceMin)
                    {
                        DistanceMin = Distance;
                        Near        = Vehicule.ArrayVehicule[V];
                    }
                }
                if (Position.X <= Near.Position.X - Speed.X)
                {
                    if (LaserPhaseTimer < 90)
                    {
                        Speed.X = SpeedX * 0.6f * TimeEllapsed;
                    }
                    else
                    {
                        Speed.X = SpeedX * 0.2f * TimeEllapsed;
                    }
                }
                else if (Position.X >= Near.Position.X + Speed.X)
                {
                    if (LaserPhaseTimer < 90)
                    {
                        Speed.X = -SpeedX * 0.6f * TimeEllapsed;
                    }
                    else
                    {
                        Speed.X = -SpeedX * 0.2f * TimeEllapsed;
                    }
                }
                else
                {
                    Position.X = Near.Position.X;
                    Speed.X    = 0;
                }
            }

            Position += Speed;

            UpdateTransformationMatrix();

            if (ActiveLaser != null)
            {
                ActiveLaser.Position.X = Position.X;
            }

            if (Resist <= 0)
            {
                if (Destroy > 0)
                {
                    Destroy--;
                    new FlameParticle(new Vector2(Position.X + SuperTank2.Randomizer.Next(300) - 150, Position.Y + SuperTank2.Randomizer.Next(100) - 50), Vector2.Zero).AddParticule();
                }
                else
                {
                    IsAlive = false;
                }
            }
        }
Пример #2
0
        public override void Update(float TimeEllapsed)
        {
            TimerAttack -= TimeEllapsed;
            if (TimerAttack <= 0)
            {
                int BombHP     = 0;
                int BombDamage = 0;
                if (SuperTank2.Difficulty == DifficultyChoices.Normal)
                {
                    BombHP     = 10;
                    BombDamage = 8;
                }
                else if (SuperTank2.Difficulty == DifficultyChoices.Hard)
                {
                    BombHP     = 20;
                    BombDamage = 16;
                }
                else if (SuperTank2.Difficulty == DifficultyChoices.Expert)
                {
                    BombHP = 30;
                    BombHP = 24;
                }
                TimerAttack = 30;

                EnemyAttack.AddEnemyAttack(new BossBomb(new Vector2(Position.X, Position.Y + 35), new Vector2(0, 6), BombHP, BombDamage));
            }

            if (ComingDown)
            {
                Vector2 NextPosition = ArrayBossPath[CurrentPathIndex + 1];

                FollowPath(NextPosition, TimeEllapsed);

                if (Position == NextPosition)
                {
                    ++CurrentPathIndex;
                    if (CurrentPathIndex + 1 == ArrayBossPath.Length)
                    {
                        ComingDown       = false;
                        CurrentPathIndex = 0;
                    }
                }
            }
            else
            {
                Vector2 NextPosition = ArrayBossPath2[CurrentPathIndex + 1];

                FollowPath(NextPosition, TimeEllapsed);

                if (Position == NextPosition)
                {
                    ++CurrentPathIndex;
                    if (CurrentPathIndex + 1 == ArrayBossPath2.Length)
                    {
                        CurrentPathIndex = 0;
                    }
                }
            }

            UpdateTransformationMatrix();

            int ParticleCount = 50;

            for (int i = 0; i < ParticleCount; i++)
            {
                new Propulsor(new Vector2(Position.X - 65, Position.Y + 33), (80 + SuperTank2.Randomizer.Next(20)) * SuperTank2.DegToRad, 5 + SuperTank2.Randomizer.NextDouble() * 4).AddParticule();
                new Propulsor(new Vector2(Position.X + 65, Position.Y + 33), (80 + SuperTank2.Randomizer.Next(20)) * SuperTank2.DegToRad, 5 + SuperTank2.Randomizer.NextDouble() * 4).AddParticule();
            }
            if (Resist <= 0)
            {
                if (Destroy > 0)
                {
                    Destroy--;
                    Explosion.AddExplosion(new BossExplosion(new Vector2(Position.X + SuperTank2.Randomizer.Next(300) - 150, Position.Y + SuperTank2.Randomizer.Next(100) - 50), sprBossExplosion, SuperTank2.Randomizer.Next(360) * SuperTank2.DegToRad, 5 + SuperTank2.Randomizer.NextDouble() * 4));
                }
                else
                {
                    IsAlive = false;
                }
            }
        }