Ejemplo n.º 1
0
        public override void think(GameTime gt)
        {
            base.think(gt);
            double currentTime = gt.TotalGameTime.TotalMilliseconds;

            if (!paperdeployed && (Ent.rand.NextDouble() < 0.003))
            {
                paperdeployed = true;
                Ent e = new EntPaperPlane();
                entities.add(e);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Z) || (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed))
            {
                if (!specialFired && Epc.CanFire)
                {
                    specialFired = true;

                    for (double i = 0; i < 2 * Math.PI; i += Math.PI / 20)
                    {
                        // create bullet and fire it;
                        EntBullet Ebullet = new EntBullet(Epc, i);
                        entities.add(Ebullet);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void think(GameTime gt)
        {
            base.think(gt);
            double currentTime = gt.TotalGameTime.TotalMilliseconds;

            if (!paperdeployed && (Ent.rand.NextDouble() < 0.003))
            {
                paperdeployed = true;
                Ent e = new EntPaperPlane();
                entities.add(e);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Z) || (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed))
            {
                if (!specialFired && Epc.CanFire)
                {
                    specialFired = true;

                    for (double i = 0; i < 2 * Math.PI; i += Math.PI / 7)
                    {
                        for (double j = 0; j < 2 * Math.PI; j += Math.PI / 7)
                        {
                            // create bullet and fire it;
                            Quaternion r = Quaternion.CreateFromYawPitchRoll((float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f);
                            EntBullet Ebullet = new EntBullet(Epc, Quaternion.CreateFromYawPitchRoll((float)i, (float)j, 0) * r);
                            entities.add(Ebullet);
                        }

                    }
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void think(GameTime gt)
        {
            double currentTime = gt.TotalGameTime.TotalMilliseconds;
            if (lastFired == 0)
            {
                lastFired = gt.TotalGameTime.TotalMilliseconds;
            }

            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) || Keyboard.GetState().IsKeyDown(Keys.Escape))
                doNextScreen = true;

            if (Keyboard.GetState().IsKeyDown(Keys.W))
                Epc.velocity += Vector3.Transform(Vector3.UnitZ * -0.2f, Epc.Orientation);
            if (Keyboard.GetState().IsKeyDown(Keys.S))
                Epc.velocity += Vector3.Transform(Vector3.UnitZ * 0.2f, Epc.Orientation);
            if (Keyboard.GetState().IsKeyDown(Keys.A))
                Epc.velocity += Vector3.Transform(Vector3.UnitX * -0.2f, Epc.Orientation);
            if (Keyboard.GetState().IsKeyDown(Keys.D))
                Epc.velocity += Vector3.Transform(Vector3.UnitX * 0.2f, Epc.Orientation);

            if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Length() > 0.25f) {
                Vector2 d = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left;
                Epc.velocity += new Vector3(d.X * 0.25f, 0, d.Y * 0.25f);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.I))
                Epc.orientation = Epc.orientation * Quaternion.CreateFromAxisAngle(Vector3.UnitX, 0.02f);

            if (Keyboard.GetState().IsKeyDown(Keys.K))
                Epc.orientation = Epc.orientation * Quaternion.CreateFromAxisAngle(Vector3.UnitX, -0.02f);

            if (Keyboard.GetState().IsKeyDown(Keys.J))
                Epc.orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 0.02f) * Epc.orientation;

            if (Keyboard.GetState().IsKeyDown(Keys.L))
                Epc.orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, -0.02f) * Epc.orientation;

            if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Right.Length() > 0.25f)
            {
                Vector2 d = GamePad.GetState(PlayerIndex.One).ThumbSticks.Right;
                Epc.orientation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, d.X * -0.02f) * Epc.orientation * Quaternion.CreateFromAxisAngle(Vector3.UnitX, -0.02f);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Space) || (GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200 && Epc.CanFire)
                {
                    lastFired = currentTime;
                    // create bullet and fire it;
                    EntBullet Ebullet = new EntBullet(Epc, Epc.orientation);
                    Ebullet.position +=  Vector3.Transform(-Vector3.UnitZ * 2, Epc.orientation);
                    entities.add(Ebullet);
                }
            }

            entities.thinkAll();
            entities.collisionAll();

            entities.cam = Matrix.CreateTranslation(-Epc.position) * Matrix.CreateFromQuaternion(Quaternion.Inverse(Epc.orientation)) * Matrix.CreateTranslation(Vector3.UnitZ * 0);

            int numballoons = 0;
            int numsets = 0;
            int numairballoons = 0;
            foreach (Ent e in entities.Ents)
            {
                if (e is EntBalloon) numballoons++;
                if (e is EntAirBalloon) numairballoons++;
                if (e is EntBalloonSet) numsets++;
            }

            if (!endShown)
            {
                if (numballoons == 0)
                {
                    EntText e = new EntText("YOU WIN", Color.White);
                    entities.add(e);
                    endShown = true;
                }
                if (Epc.lives == 0)
                {
                    EntText e = new EntText("GAME OVER", Color.Red);
                    entities.add(e);
                    endShown = true;
                }
            }

            if (((float)numballoons / (float)startballoons <= 0.9) && hab1)
            {
                hab1 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
            if (((float)numballoons / (float)startballoons <= 0.6) && hab2)
            {
                hab2 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
            if (((float)numballoons / (float)startballoons <= 0.3) && hab3)
            {
                hab3 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
        }
Ejemplo n.º 4
0
        public override void think(GameTime gt)
        {
            base.think(gt);
            foreach (Ent e in entities.Ents)
            {
                if (e is EntText)
                    entities.queueRemove(e);
            }
            entities.dequeAll();

            Epc.lives = float.PositiveInfinity;
            //hab1 = hab2 = hab3 = true;

            double currentTime = gt.TotalGameTime.TotalMilliseconds;

            if (Keyboard.GetState().IsKeyDown(Keys.Z) || (GamePad.GetState(PlayerIndex.One).Buttons.B == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    for (double i = 0; i < 2 * Math.PI; i += Math.PI / 7)
                    {
                        for (double j = 0; j < 2 * Math.PI; j += Math.PI / 7)
                        {
                            // create bullet and fire it;
                            Quaternion r = Quaternion.CreateFromYawPitchRoll((float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f, (float)Ent.rand.NextDouble() - 0.5f);
                            EntBullet Ebullet = new EntBullet(Epc, Quaternion.CreateFromYawPitchRoll((float)i, (float)j, 0) * r);
                            entities.add(Ebullet);
                        }

                    }
                }

            }

            if (entities.Ents.Count < 100)
            {
                if (Ent.rand.NextDouble() < 0.01)
                {
                    double angle = Ent.rand.NextDouble() * Math.PI * 2;

                    EntBalloonSet Eballoonset = new EntBalloonSet(Vector3.One * -EntBalloonSet.defaultSprite.Width);
                    Eballoonset.velocity = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * 0.1f;
                    entities.add(Eballoonset);
                }

                if (Ent.rand.NextDouble() < 0.01)
                {
                    EntAirBalloon e = new EntAirBalloon();
                    entities.add(e);
                }
            }

            /*
            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {

                EntBalloon Eballoon = new EntBalloon();
                entities.add(Eballoon);

                Eballoon.position = Epc.position;
                Eballoon.velocity = Vector2.Zero;

            }

            if (Keyboard.GetState().IsKeyDown(Keys.O))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    EntBalloonSet Eballoonset = new EntBalloonSet(Epc.position);
                    entities.add(Eballoonset);
                }
            }
            */
            if (Keyboard.GetState().IsKeyDown(Keys.H) || (GamePad.GetState(PlayerIndex.One).Buttons.X == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;

                    EntAirBalloon e = new EntAirBalloon();
                    entities.add(e);

                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.G) || (GamePad.GetState(PlayerIndex.One).Buttons.Y == ButtonState.Pressed))
            {
                if ((currentTime - lastFired) > 200)
                {
                    lastFired = currentTime;
                    EntPaperPlane e = new EntPaperPlane();
                    entities.add(e);

                }
            }
        }
Ejemplo n.º 5
0
        public virtual void think(GameTime gt)
        {
            double currentTime = gt.TotalGameTime.TotalMilliseconds;
            if (lastFired == 0)
            {
                lastFired = gt.TotalGameTime.TotalMilliseconds;
            }

            // Allows the game to exit
            if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) || Keyboard.GetState().IsKeyDown(Keys.Escape))
                doNextScreen = true;

            if (Keyboard.GetState().IsKeyDown(Keys.Up))
                Epc.velocity += new Vector2(0, -2);
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
                Epc.velocity += new Vector2(0, 2);
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
                Epc.velocity += new Vector2(-2, 0);
            if (Keyboard.GetState().IsKeyDown(Keys.Right))
                Epc.velocity += new Vector2(2, 0);

            if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Length() > 0.25f)
                Epc.velocity += GamePad.GetState(PlayerIndex.One).ThumbSticks.Left * 2;

            if ((GamePad.GetState(PlayerIndex.One).Buttons.A == ButtonState.Pressed) || Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                if ((currentTime - lastFired) > 200 && Epc.CanFire)
                {
                    lastFired = currentTime;
                    // create bullet and fire it;
                    EntBullet Ebullet = new EntBullet(Epc, Epc.direction);
                    entities.add(Ebullet);
                }
            }

            entities.thinkAll();
            entities.collisionAll();

            int numballoons = 0;
            int numsets = 0;
            int numairballoons = 0;
            foreach (Ent e in entities.Ents)
            {
                if (e is EntBalloon) numballoons++;
                if (e is EntAirBalloon) numairballoons++;
                if (e is EntBalloonSet) numsets++;
            }

            if (!endShown)
            {
                if (numballoons == 0)
                {
                    EntText e = new EntText("YOU WIN", Color.White);
                    entities.add(e);
                    endShown = true;
                }
                if (Epc.lives == 0)
                {
                    EntText e = new EntText("GAME OVER", Color.Red);
                    entities.add(e);
                    endShown = true;
                }
            }

            if (((float)numballoons / (float)startballoons <= 0.9) && hab1)
            {
                hab1 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
            if (((float)numballoons / (float)startballoons <= 0.6) && hab2)
            {
                hab2 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
            if (((float)numballoons / (float)startballoons <= 0.3) && hab3)
            {
                hab3 = false;
                EntAirBalloon e = new EntAirBalloon();
                entities.add(e);
            }
        }