예제 #1
0
        public void FireCheck(Game1 game)
        {
            #region Shooting
            #region Controller
            GamePadState gamepadStateCurr = GamePad.GetState(PlayerIndex.One);
            if (gamepadStateCurr.IsButtonDown(Buttons.RightTrigger))
            {
                if (i_FireRate == 7)
                {
                    i_FireRate = 0;
                    //FireBullet
                    for (int i = 0; i < i_BulletMax; i++)
                    {
                        if (bullets[i].Alive == false)
                        {
                            bullets[i].ResetBullet();
                            if (game.gameState == State.Tutorial)
                            {
                                Tutorial tutorial = (Tutorial)loadedLevel;
                                tutorial.tutBulletCounter++;
                            }
                            v_TurretDirection = ship.TurretDirection;
                            bullets[i].Fire(ship, v_TurretDirection);
                            game.soundBank.PlayCue("lazer");
                            break;
                        }
                    }
                }
                else
                {
                    i_FireRate++;
                }
            }
            else if (Mouse.GetState().LeftButton == ButtonState.Released && gamepadStateCurr.IsButtonDown(Buttons.RightTrigger) == false)
            {
                i_FireRate = 7;
            }
            #endregion
            #region Mouse
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                if (i_FireRate == 7)
                {
                    i_FireRate = 0;
                    //FireBullet
                    for (int i = 0; i < i_BulletMax; i++)
                    {
                        if (bullets[i].Alive == false)
                        {
                            if (game.gameState == State.Tutorial)
                            {
                                Tutorial tutorial = (Tutorial)loadedLevel;
                                tutorial.tutBulletCounter++;
                            }
                            v_TurretDirection = ship.TurretDirection;
                            bullets[i].Position = new Vector2(0, 0);
                            bullets[i].Fire(ship, v_TurretDirection);
                            game.soundBank.PlayCue("lazer");
                            break;
                        }
                    }
                }
                else
                {
                    i_FireRate++;
                }
            }
            else if (Mouse.GetState().LeftButton == ButtonState.Released && gamepadStateCurr.IsButtonDown(Buttons.RightTrigger) == false)
            {
                i_FireRate = 7;
            }
            #endregion
            #endregion
            #region Tethering
            #region Controller
            if (gamepadStateCurr.IsButtonDown(Buttons.LeftTrigger))
            {
                switch (tetherState)
                {
                    case TetherState.shooting:
                        if (game.lastLTrigger == false)
                        {
                            game.soundBank.PlayCue("tetherFire");
                        }
                        //FireBullet
                        for (int i = 0; i < i_BulletMax; i++)
                        {
                            if (tethers[i].Alive == false)
                            {
                                v_TurretDirection = ship.TurretDirection;
                                tethers[i].Fire(ship, v_TurretDirection);
                                break;
                            }
                        }
                        break;

                    case TetherState.tethered:
                        if (game.lastLTrigger == false)
                        {
                            if (ship.IsPhoton)
                            {
                                Photons[ship.TetheredParticleID].IsTethered = false;
                                Photons[ship.TetheredParticleID].Color = Color.White;
                            }
                            else
                            {
                                Chlor[ship.TetheredParticleID].IsTethered = false;
                                Chlor[ship.TetheredParticleID].Color = Color.White;
                            }
                            tetherState = TetherState.detethered;
                            game.soundBank.PlayCue("deTether");
                        }
                        break;

                    case TetherState.detethered:
                        if (game.lastLTrigger == false)
                        {
                            tetherState = TetherState.shooting;
                        }
                        break;
                }

                game.lastLTrigger = true;
            }
            else
            {
                game.lastLTrigger = false;
            }
            #endregion
            #region Mouse
            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                switch (tetherState)
                {
                    case TetherState.shooting:
                        if (game.lastRMouse == false)
                        {
                            game.soundBank.PlayCue("tetherFire");
                        }
                        //FireBullet
                        for (int i = 0; i < i_BulletMax; i++)
                        {
                            if (tethers[i].Alive == false)
                            {
                                v_TurretDirection = ship.TurretDirection;
                                tethers[i].Fire(ship, v_TurretDirection);
                                break;
                            }
                        }
                        break;

                    case TetherState.tethered:

                        if (game.lastRMouse == false)
                        {
                            if (ship.IsPhoton)
                            {
                                Photons[ship.TetheredParticleID].IsTethered = false;
                                Photons[ship.TetheredParticleID].Color = Color.White;
                            }
                            else
                            {
                                Chlor[ship.TetheredParticleID].IsTethered = false;
                                Chlor[ship.TetheredParticleID].Color = Color.White;
                            }
                            tetherState = TetherState.detethered;
                            game.soundBank.PlayCue("deTether");
                        }
                        break;

                    case TetherState.detethered:
                        if (game.lastRMouse == false)
                        {
                            tetherState = TetherState.shooting;
                        }
                        break;
                }

                game.lastRMouse = true;
            }
            else
            {
                game.lastRMouse = false;
            }
            #endregion
            #endregion
        }
예제 #2
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;
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public void COLLISION(Particle particleA, Particle particleB, bool fusion, Game1 game)
        {
            if (particleA.Rectangle.Intersects(particleB.Rectangle))
            {

                if (IntersectPixels(particleB.RectanglePosTransform,
                                    particleB.Texture.Width,
                                    particleB.Texture.Height,
                                    particleB.TextureData,
                                    particleA.RectanglePosTransform,
                                    particleA.Texture.Width,
                                    particleA.Texture.Height,
                                    particleA.TextureData))
                {
                    if (fusion == true)
                    {
                        ship.Tethering = false;
                        tetherState = TetherState.detethered;
                        particleA.ParticleState = Particle.PState.Colliding;
                        particleB.ParticleState = Particle.PState.Colliding;
                        game.soundBank.PlayCue("fusion");
                        particleA.FusionPosition = new Vector2((particleA.Position.X + ((particleB.Position.X - particleA.Position.X) / 2)), (particleA.Position.Y + ((particleB.Position.Y - particleA.Position.Y) / 2)));
                        particleB.FusionPosition = new Vector2((particleB.Position.X + ((particleA.Position.X - particleB.Position.X) / 2)), (particleB.Position.Y + ((particleA.Position.Y - particleB.Position.Y) / 2)));
                    }
                    else if (fusion == false)
                    {
                        Vector2 impactSpeed;
                        Vector2 impulse;
                        float resultantImpulse;

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

                        particleB.Velocity += impulse;
                        particleA.Velocity -= impulse;
                    }
                }
            }
        }
예제 #4
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);
        }