Beispiel #1
0
 public void COLLISION(Enemy enemy, Bullet bullet, Game1 game)
 {
     if (bullet.Rectangle.Intersects(enemy.Rectangle))
     {
         if (IntersectPixels(enemy.RectanglePosTransform,
                             enemy.Texture.Width,
                             enemy.Texture.Height,
                             enemy.TextureData,
                             bullet.RectanglePosTransform,
                             bullet.Texture.Width,
                             bullet.Texture.Height,
                             bullet.TextureData))
         {
             bullet.Alive = false;
             enemy.EnemyShot(bullet, game);
         }
     }
 }
Beispiel #2
0
        public void InitalizeLevel(Level level, Game1 game)
        {
            loadedLevel = level;

            f_Fusions = 0;
            i_ShieldPulseCounter = 0;
            i_shipAlpha = 0.5f;
            i_PulseRate = 60;

            enemies = new Enemy[loadedLevel.levelData.i_MaxNumberEnemies];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberEnemies; j++)
            {
                enemies[j] = new Enemy(game, loadedLevel);
                enemies[j].LoadTexture(game.Content);
                enemies[j].Rectangle = new Rectangle(((int)enemies[j].Position.X - (enemies[j].Texture.Width / 2)), ((int)enemies[j].Position.Y - (enemies[j].Texture.Height / 2)), enemies[j].Texture.Width, enemies[j].Texture.Height);
                enemies[j].TextureData = new Color[enemies[j].Texture.Width * enemies[j].Texture.Height];
                enemies[j].Texture.GetData(enemies[j].TextureData);
                enemies[j].ShieldSpark = new ShieldSparkParticleSystem(game, 3);
                game.Components.Add(enemies[j].ShieldSpark);
                enemies[j].ParticleKill = new ParticleKillParticleSystem(game, 4);
                game.Components.Add(enemies[j].ParticleKill);
            }

            Fused = new Particle[loadedLevel.levelData.i_MaxNumberFused];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberFused; j++)
            {
                Fused[j] = new Particle(loadedLevel.levelBounds);
                Fused[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Fused[j].Fusion);
                Fused[j].LoadTex(t_Fused);
            }

            Photons = new Particle[loadedLevel.levelData.i_MaxNumberPhotons];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberPhotons; j++)
            {
                Photons[j] = new Particle(loadedLevel.levelBounds);
                Photons[j].LoadTex(t_Photon);
                Photons[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Photons[j].Fusion);
            }
            Chlor = new Particle[loadedLevel.levelData.i_MaxNumberChloro];
            for (int j = 0; j < loadedLevel.levelData.i_MaxNumberChloro; j++)
            {
                Chlor[j] = new Particle(loadedLevel.levelBounds);
                Chlor[j].LoadTex(t_Chlor);
                Chlor[j].Fusion = new FusionParticleSystem(game, 20);
                game.Components.Add(Chlor[j].Fusion);
            }

            bullets = new Bullet[i_BulletMax];
            tethers = new Bullet[i_BulletMax];
            for (int j = 0; j < i_BulletMax; j++)
            {
                bullets[j] = new Bullet(t_Bullet);
                tethers[j] = new Bullet(t_Tether);
            }
            stupidline = new Bullet[i_StupidLineMax];
            for (int j = 0; j < i_StupidLineMax; j++)
            {
                stupidline[j] = new Bullet(t_Tether);
            }

            ship = new Ship(500, 350, t_Ship);
            ship.Turret = game.Content.Load<Texture2D>("Ship//turret");
            tetherState = TetherState.shooting;

            offset = ship.OffsetUpdate(offset);
            engineSmoke = new EngineParticleSystem(game, 9);
            game.Components.Add(engineSmoke);
            shipExplosion = new ExplosionParticleSystem(game, 9);
            game.Components.Add(shipExplosion);
        }
Beispiel #3
0
        public void COLLISION(Bullet tether, Particle particle, int ID, bool isAPhoton, Game1 game)
        {
            if (tetherState == TetherState.shooting)
            {
                if (tether.Rectangle.Intersects(particle.Rectangle))
                {
                    if (IntersectPixels(particle.RectanglePosTransform,
                                        particle.Texture.Width,
                                        particle.Texture.Height,
                                        particle.TextureData,
                                        tether.RectanglePosTransform,
                                        tether.Texture.Width,
                                        tether.Texture.Height,
                                        tether.TextureData))
                    {
                        if (particle.ParticleState == Particle.PState.Alive && particle.BeingAttacked == false)
                        {
                            particle.Color = Color.Aqua;
                            ship.TetheredParticleID = ID;
                            ship.IsPhoton = isAPhoton;
                            ship.Tethering = true;
                            particle.IsTethered = true;
                            tether.Alive = false;
                            tetherState = TetherState.tethered;
                            game.soundBank.PlayCue("tethered");

                            if (particle.Attacker != null)
                            {
                                particle.Attacker.i_KillingCounter = 0;
                                particle.Attacker.f_colour = 1.0f;
                                particle.Attacker.attacking = false;
                                particle.Attacker.f_Rotation = 0;
                            }
                            particle.BeingAttacked = false;
                            particle.Attacker = null;
                            if (particle.IsTethered == false)
                            {
                                particle.Color = Color.White;
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public void EnemyShot(Bullet bullet, Game1 game)
        {
            i_Health -= bullet.i_BulletDamage;
            game.soundBank.PlayCue("enemyDie");
            EnemyCollisionPosition = Position;// -new Vector2(enemy.Texture.Width / 2, enemy.Texture.Height / 2);
            EnemyCollision = true;

            if (i_Health <= 0)
            {
                i_Health = 0;
                Alive = false;

                if (EnemyType == EnemyData.Type.Destroyer)
                {
                    game.f_EnemiesBigKilled++;
                }
                else if (EnemyType == EnemyData.Type.Normal)
                {
                    game.f_EnemiesSmallKilled++;
                }

                if (closestParticle != null)
                {
                    closestParticle.BeingAttacked = false;
                    closestParticle.Attacker = null;
                    if (closestParticle.IsTethered == false)
                    {
                        closestParticle.Color = Color.White;
                    }
                }
            }
        }