예제 #1
0
    protected override void Execute()
    {
        if (ExplosionSound != null)
        {
            ExplosionSound.PlayEffect();
        }
        Vector2 dir;

        Vector2 velocity = GetComponent <Rigidbody2D>().velocity;

        for (int i = 0; i < NumOfParticles; i++)
        {
            dir = Random.insideUnitCircle;
            Projectile ep = Instantiate(ExplosionParticles) as Projectile;
            ep.Owner = Owner;

            //edit properties of new projectiles
            Damage[] dmg = ep.GetComponents <Damage>();
            if (dmg != null && dmg.Length > 0)
            {
                for (int j = 0; j < dmg.Length; j++)
                {
                    dmg[j].DamageOwner = DamageOwner;
                }
            }

            Rigidbody2D rbody    = ep.GetComponent <Rigidbody2D>();
            float       lifetime = ParticleLifetime + Random.Range(-1.0f, 1.0f);
            ep.gameObject.layer = LayerMask.NameToLayer("ExplosionParticle");
            rbody.AddForce(dir * ExplosionForce * 100);
            rbody.velocity       += velocity * 0.7f;
            ep.transform.position = transform.position;
            Destroy(ep.gameObject, lifetime);
        }
    }
예제 #2
0
        public override void Die(CVGameTime gameTime)
        {
            //soundDestroyed.Play();
            ExplosionSound.Play();

            base.Die(gameTime);
        }
예제 #3
0
 void Awake()
 {
     if (ExplosionSound.instance == null)
     {
         ExplosionSound.instance = this;
     }
 }
예제 #4
0
        public override void Die(CVGameTime gameTime)
        {
            ExplosionSound.Play();
            var item = new PlayerItem(_contentManager, WorldPosition, CurrentStage, _itemType);

            CurrentStage.ActiveEnemies.Add(item);

            base.Die(gameTime);
        }
예제 #5
0
 protected virtual void Die(Warhead warhead)
 {
     if (ExplosionType != null)
     {
         Explosion explosion = (Explosion)Activator.CreateInstance(ExplosionType, new object[] { World, Position, this is A10 ? ExplosionHeight.Air : ExplosionHeight.Ground });
         World.AddExplosion(explosion);
     }
     if (ExplosionSound != null)
     {
         ExplosionSound.Play();
     }
 }
예제 #6
0
 protected virtual void MakeExplosion()
 {
     if (ExplosionType != null)
     {
         Explosion explosion = (Explosion)Activator.CreateInstance(ExplosionType, new object[] { World, Position, TargetEntity != null && TargetEntity is A10 ? ExplosionHeight.Air : ExplosionHeight.Ground });
         World.AddExplosion(explosion);
     }
     if (ExplosionSound != null)
     {
         ExplosionSound.Play();
     }
 }
예제 #7
0
 static public void PlayExplosionSound()
 {
     ExplosionSound.Play();
 }
예제 #8
0
        public static void Shoot()
        {
            Program.IsPlayerShootNow = true;

            Coordinates currentBarrelCoords = new Coordinates(barrelCoords.Row - 1, barrelCoords.Col);

            for (int i = 0; i < 25; i++)
            {
                Thread.Sleep(PlayerShootSpeed);

                currentBarrelCoords.Row -= 1;

                #region [Check if some of the tower is hit]
                for (int j = 1; j <= 4; j++)
                {
                    int index = 0;

                    switch (j)
                    {
                    case 1: index = Towers.Tower1Coords.IndexOf(currentBarrelCoords); break;

                    case 2: index = Towers.Tower2Coords.IndexOf(currentBarrelCoords); break;

                    case 3: index = Towers.Tower3Coords.IndexOf(currentBarrelCoords); break;

                    default: index = -1; break;
                    }

                    if (index != -1)
                    {
                        switch (j)
                        {
                        case 1: Towers.Tower1Coords[index] = new Coordinates(); break;

                        case 2: Towers.Tower2Coords[index] = new Coordinates(); break;

                        case 3: Towers.Tower3Coords[index] = new Coordinates(); break;
                        }

                        Console.SetCursorPosition(currentBarrelCoords.Col, currentBarrelCoords.Row);
                        Console.Write(" ");
                        Console.SetCursorPosition(currentBarrelCoords.Col, currentBarrelCoords.Row + 1);
                        Console.Write(" ");

                        Program.IsPlayerShootNow = false;
                        Towers.IsHitTower        = true;

                        return;
                    }
                }
                #endregion

                #region [Check if some of the invaders are hit]
                for (int j = 3; j >= 1; j--)
                {
                    List <Coordinates[]> currentInvaders;

                    switch (j)
                    {
                    case 3: currentInvaders = Invaders.InvaderCoords3; break;

                    case 2: currentInvaders = Invaders.InvaderCoords2; break;

                    case 1: currentInvaders = Invaders.InvaderCoords1; break;

                    default: return;
                    }

                    for (int k = 0; k < currentInvaders.Count; k++)
                    {
                        if (currentInvaders[k] != null && currentInvaders[k].Contains(currentBarrelCoords))
                        {
                            Field.Score += 10;
                            if (j == 2)
                            {
                                Field.Score += 15;
                            }
                            else if (j == 1)
                            {
                                Field.Score += 40;
                            }
                            Field.IsChangedScore = true;

                            currentInvaders.Remove(currentInvaders[k]);

                            if (DestroySound != null)
                            {
                                DestroySound.Play();
                            }

                            Program.IsPlayerShootNow = false;

                            return;
                        }
                    }
                }

                #endregion

                #region [Check if flying saucer is hit]

                if (FlyingSaucer.AlienCoords.Contains(currentBarrelCoords))
                {
                    if (ExplosionSound != null)
                    {
                        ExplosionSound.Play();
                    }
                    Field.Score             += FlyingSaucer.Score;
                    FlyingSaucer.IsExits     = false;
                    FlyingSaucer.AlienCoords = new List <ObjectProperties.Coordinates>();
                }

                #endregion

                #region [Check if boss is hit]

                if (Boss.BossTime && Boss.BossCoords.Contains(currentBarrelCoords))
                {
                    Program.IsPlayerShootNow = false;
                    Boss.Hitted--;
                    Field.Score += 50;
                    return;
                }

                #endregion

                Console.ForegroundColor = ConsoleColor.White;
                Console.SetCursorPosition(currentBarrelCoords.Col, currentBarrelCoords.Row);
                Console.Write("|");

                Console.SetCursorPosition(currentBarrelCoords.Col, currentBarrelCoords.Row + 1);
                Console.Write(" ");
            }

            Program.IsPlayerShootNow = false;
        }