Beispiel #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (!mapEditor.EditMode)
            {
                GameWorld.Update(gameTime);
            }

            KeyboardState kb = Keyboard.GetState();

            if (kb.IsKeyDown(Keys.Right))
            {
                if (camera.Position.X < GameWorld.WorldWidth - this.Window.ClientBounds.Width)
                {
                    camera.Position = new Vector2(camera.Position.X + 15, camera.Position.Y);
                }
            }
            if (kb.IsKeyDown(Keys.Left))
            {
                camera.Position = new Vector2(camera.Position.X - 15, camera.Position.Y);
                if (camera.Position.X < 0)
                {
                    camera.Position = Vector2.Zero;
                }
            }
            if (kb.IsKeyDown(Keys.Z))
            {
                if (camera.Zoom < 1)
                {
                    camera.Zoom += 0.005f;
                }
            }

            if (kb.IsKeyDown(Keys.X))
            {
                if (camera.Zoom > 0.3)
                {
                    camera.Zoom -= 0.005f;
                }
            }
            if (kb.IsKeyDown(Keys.P))
            {
                camera.Zoom = 1;
            }

            foreach (int key in factory.Objects.Keys)
            {
                factory.Objects[key].sprite.Update(gameTime);
            }

            MouseState msState = Mouse.GetState();

            mapEditor.Update(gameTime, camera);
            client.Update(gameTime);

            base.Update(gameTime);
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (!mapEditor.EditMode)
            {
                GameWorld.Update(gameTime);
            }

            KeyboardState kb = Keyboard.GetState();

            /*if (kb.IsKeyDown(Keys.Right))
             * {
             *  if (camera.Position.X < GameWorld.WorldWidth - this.Window.ClientBounds.Width)
             *  {
             *      camera.Position = new Vector2(camera.Position.X + 15, camera.Position.Y);
             *  }
             *  camera.OriginalPosition = new Vector2(camera.Position.X, camera.OriginalPosition.Y);
             * }
             * if (kb.IsKeyDown(Keys.Left))
             * {
             *  camera.Position = new Vector2(camera.Position.X - 15, camera.Position.Y);
             *  if (camera.Position.X < 0)
             *      camera.Position = Vector2.Zero;
             *
             *  camera.OriginalPosition = new Vector2(camera.Position.X, camera.OriginalPosition.Y);
             * }
             * if (kb.IsKeyDown(Keys.Z))
             * {
             *  if (camera.Zoom < 1)
             *      camera.Zoom += 0.005f;
             * }
             *
             * if (kb.IsKeyDown(Keys.X))
             * {
             *  if (camera.Zoom > 0.3)
             *      camera.Zoom -= 0.005f;
             * }
             * if (kb.IsKeyDown(Keys.P))
             *  camera.Zoom = .5f;
             */

            foreach (int key in factory.Objects.Keys)
            {
                factory.Objects[key].sprite.Update(gameTime);
            }



            SunManager.Instance.Update(gameTime);
            SpriteHelper.Instance.Update(gameTime);
            PlaneManager.Instance.Update(gameTime);
            cloudManager.Update(gameTime);

            mapEditor.Update(gameTime, camera);

            client.Update(gameTime);
            camera.Update(gameTime);
            //funky
            if (ScreenConfiguration == 2)
            {
                if (MapLoaded)
                {
                    int cats = 0;
                    foreach (int key in factory.Objects.Keys)
                    {
                        if (factory.Objects[key].typeid == (int)GameObjectTypes.CAT)
                        {
                            cats++;
                        }
                    }
                    if (cats == 0)
                    {
                        Random rand = new Random();
                        client.SendMessage("action=endgame;map=" + rand.Next(1, 5));
                    }
                }
            }
            base.Update(gameTime);
        }