Beispiel #1
0
 public void BulletMovement(Ship ship)
 {
     if (vPosition.X < 0 || vPosition.X > 4096 || vPosition.Y < 0 || vPosition.Y > 2304)
     {
         b_alive = false;
     }
 }
Beispiel #2
0
 public void Fire(Ship ship, Vector2 direction)
 {
     vPosition = (ship.Position + Vector2.Transform(new Vector2(0, 20), Matrix.CreateRotationZ((float)ship.NextRotation)));
     b_alive = true;
     v_direction = direction;
     v_ShipVelocity = ship.Velocity;
     vVelocity.X = (v_direction.X * f_BulletSpeed) + v_ShipVelocity.X;
     vVelocity.Y = (-v_direction.Y * f_BulletSpeed) + v_ShipVelocity.Y;
 }
Beispiel #3
0
 public void EDGECOLLISION(Ship thing, Rectangle bounds, Game1 game)
 {
     if (thing.Position.Y < bounds.Y)
     {
         thing.Position += new Vector2(0, bounds.Y - thing.Position.Y);
         thing.Velocity *= new Vector2(1, -f_EdgeDamper);
         game.soundBank.PlayCue("sideBump");
     }
     else if (thing.Position.Y > bounds.Y + bounds.Height)
     {
         thing.Position -= new Vector2(0, thing.Position.Y - (bounds.Y + bounds.Height));
         thing.Velocity *= new Vector2(1, -f_EdgeDamper);
         game.soundBank.PlayCue("sideBump");
     }
     if (thing.Position.X < bounds.X)
     {
         thing.Position += new Vector2(bounds.X - thing.Position.X, 0);
         thing.Velocity *= new Vector2(-f_EdgeDamper, 1);
         game.soundBank.PlayCue("sideBump");
     }
     else if (thing.Position.X > bounds.X + bounds.Width)
     {
         thing.Position -= new Vector2(thing.Position.X - (bounds.X + bounds.Width), 0);
         thing.Velocity *= new Vector2(-f_EdgeDamper, 1);
         game.soundBank.PlayCue("sideBump");
     }
 }
Beispiel #4
0
        public void COLLISION(Ship ship, Enemy enemy, Game1 game)
        {
            if (ship.Rectangle.Intersects(enemy.Rectangle))
            {

                if (IntersectPixels(enemy.RectanglePosTransform,
                                    enemy.Texture.Width,
                                    enemy.Texture.Height,
                                    enemy.TextureData,
                                    ship.RotationTransform,
                                    ship.Texture.Width,
                                    ship.Texture.Height,
                                    ship.TextureData))
                {

                    i_VibrateCounter++; //add to vibration amount

                    enemy.EnemyCollisionPosition = enemy.Position;// -new Vector2(enemy.Texture.Width / 2, enemy.Texture.Height / 2);
                    ship.ShipShield -= 25;
                    if (ship.ShipShield < 0)
                    {
                        //You are Dead
                        game.soundBank.PlayCue("shipExplode");
                        dead = true;
                    }
                    if (ship.ShipShield == 75)
                    {
                        game.soundBank.PlayCue("75percent");
                    }
                    else if (ship.ShipShield == 50)
                    {
                        game.soundBank.PlayCue("50percent");
                    }
                    else if (ship.ShipShield == 25)
                    {
                        game.soundBank.PlayCue("25percent");
                    }
                    else if (ship.ShipShield == 0)
                    {
                        ship.ShipShield = -1;
                        game.soundBank.PlayCue("shieldsdown");
                    }
                    else
                        enemy.EnemyCollision = true;
                    ship.Hit = true;
                    enemy.Alive = false;
                    game.soundBank.PlayCue("enemyDie");
                    game.vibrate = 20;

                    if (enemy.closestParticle != null)
                    {
                        enemy.closestParticle.BeingAttacked = false;
                        enemy.closestParticle.Attacker = null;
                        if (enemy.closestParticle.IsTethered == false)
                        {
                            enemy.closestParticle.Color = Color.White;
                        }
                    }
                }
            }
        }
Beispiel #5
0
        public void COLLISION(Ship ship, Particle particle)
        {
            if (particle.IsTethered == true)
            {
                if (ship.BoundSphere.Intersects(new BoundingSphere(new Vector3(particle.Position, 0), (particle.Texture.Width / 2))))
                {
                    particle.Velocity *= -0.5f;
                }
            }
            else
            {
                if (ship.Rectangle.Intersects(particle.Rectangle))
                {
                    if (IntersectPixels(particle.RectanglePosTransform,
                                        particle.Texture.Width,
                                        particle.Texture.Height,
                                        particle.TextureData,
                                        ship.RotationTransform,
                                        ship.Texture.Width,
                                        ship.Texture.Height,
                                        ship.TextureData))
                    {
                        if (particle.BeingAttacked == false)
                        {
                            i_VibrateCounter++;

                            Vector2 impactSpeed;
                            Vector2 impulse;
                            float resultantImpulse;

                            impactSpeed = particle.Velocity - ship.Velocity;
                            impulse = Vector2.Normalize(particle.Position - ship.Position);
                            resultantImpulse = Vector2.Dot(impulse, impactSpeed);
                            if (resultantImpulse < 0)
                            {
                                resultantImpulse *= -1;
                            }
                            impulse = impulse * (float)Math.Sqrt(resultantImpulse);

                            particle.Velocity += impulse;
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void LEVELCOLLISION(Ship item, Game1 game)
        {
            if (item.Rectangle.Intersects(loadedLevel.levelData.levelLeft) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelRight) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelTop) ||
                item.Rectangle.Intersects(loadedLevel.levelData.levelBottom))
            {

                if (IntersectPixels(item.RotationTransform,
                                    item.Texture.Width,
                                    item.Texture.Height,
                                    item.TextureData,
                                    Matrix.Identity,
                                    loadedLevel.t_LevelBounds.Width,
                                    loadedLevel.t_LevelBounds.Height,
                                    loadedLevel.levelBoundsData))
                {

                    i_VibrateCounter++;

                    if (item.Position.Y < loadedLevel.levelData.levelTop.Height)
                    {
                        item.Position += new Vector2(0, 5);
                        item.Velocity *= new Vector2(1, -f_EdgeDamper);
                    }
                    else if (item.Position.Y > loadedLevel.levelData.levelTop.Height + loadedLevel.levelData.levelBottom.Y)
                    {
                        item.Position -= new Vector2(0, item.Position.Y - (loadedLevel.levelData.levelTop.Height + loadedLevel.levelData.levelBottom.Y));
                        item.Velocity *= new Vector2(1, -f_EdgeDamper);
                    }
                    if (item.Position.X < loadedLevel.levelData.levelTop.X)
                    {
                        item.Position += new Vector2(loadedLevel.levelData.levelTop.X - item.Position.X, 0);
                        item.Velocity *= new Vector2(-f_EdgeDamper, 1);
                    }
                    else if (item.Position.X > loadedLevel.levelData.levelTop.X + loadedLevel.levelData.levelRight.X)
                    {
                        item.Position -= new Vector2(item.Position.X - (loadedLevel.levelData.levelTop.X + loadedLevel.levelData.levelRight.X), 0);
                        item.Velocity *= new Vector2(-f_EdgeDamper, 1);
                    }

                }
            }
        }
Beispiel #7
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 #8
0
 public void MoveTowardsPlayer(Ship ship)
 {
     //vVelocity.X = (((ship.Position.X - vPosition.X) / Vector2.Distance(vPosition, ship.Position)) * ed_EnemyData.f_Speed);
     //vVelocity.Y = (((ship.Position.Y - vPosition.Y) / Vector2.Distance(vPosition, ship.Position)) * ed_EnemyData.f_Speed);
 }
Beispiel #9
0
        public void EnemyMovement(Ship ship, Engine engine)
        {
            if (ed_EnemyData.t_Type == EnemyData.Type.Normal)
            {
                MoveTowardsPlayer(ship);
            }
            else if (ed_EnemyData.t_Type == EnemyData.Type.Destroyer)
            {
                if (attacking == false)
                {
                    float currentDistance = 99999;
                    for (int i = 0; i < engine.Photons.Length; i++)
                    {
                        float distance = Vector2.Distance(engine.Photons[i].Position, Position);
                        if ((distance < currentDistance) && engine.Photons[i].BeingAttacked == false && engine.Photons[i].ParticleState == Particle.PState.Alive && engine.Photons[i].IsTethered == false)
                        {
                            currentDistance = distance;
                            closestParticle = engine.Photons[i];
                        }
                    }
                    for (int i = 0; i < engine.Chlor.Length; i++)
                    {
                        float distance = Vector2.Distance(engine.Chlor[i].Position, Position);
                        if (distance < currentDistance && engine.Chlor[i].BeingAttacked == false && engine.Chlor[i].ParticleState == Particle.PState.Alive && engine.Chlor[i].IsTethered == false)
                        {
                            currentDistance = distance;
                            closestParticle = engine.Chlor[i];
                        }
                    }

                    if (closestParticle != null)
                    {
                        vVelocity.X = (((closestParticle.Position.X - vPosition.X) / Vector2.Distance(vPosition, closestParticle.Position)) * ed_EnemyData.f_Speed);
                        vVelocity.Y = (((closestParticle.Position.Y - vPosition.Y) / Vector2.Distance(vPosition, closestParticle.Position)) * ed_EnemyData.f_Speed);
                    }
                    else
                    {
                        MoveTowardsPlayer(ship);
                    }
                }
                else if (attacking == true)
                {

                    vVelocity.X = (((closestParticle.Position.X - vPosition.X) / Vector2.Distance(vPosition, closestParticle.Position)) * ed_EnemyData.f_Speed);
                    vVelocity.Y = (((closestParticle.Position.Y - vPosition.Y) / Vector2.Distance(vPosition, closestParticle.Position)) * ed_EnemyData.f_Speed);

                    if (i_KillingCounter < 250)
                    {
                        f_Rotation += 0.15f;
                        i_KillingCounter++;
                        f_colour -= 0.004f;
                        closestParticle.Color = new Color(1.0f, f_colour, f_colour, 1.0f);
                    }
                    else
                    {
                        f_Rotation = 0;
                        i_KillingCounter = 0;
                        f_colour = 1.0f;
                        p_ParticleKilled = closestParticle;
                        ParticleKillPosition = closestParticle.Position + new Vector2((closestParticle.Texture.Width / 2), (closestParticle.Texture.Height / 2));
                        closestParticle.ParticleState = Particle.PState.Dead;
                        attacking = false;
                        IsParticleKill = true;
                    }
                }
            }
        }