/// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related _content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            GraphicsDevice gd = _graphics.GraphicsDevice;

            _batch           = new SpriteBatch(gd);
            _camera          = new cCamera2D(gd.Viewport);
            _camera.Position = new Vector2(500, 500);
            _animManager     = new cAnimationManager();
            base.Initialize();
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            KeyboardState ks  = Keyboard.GetState();
            cCamera2D     cam = PrimalDevistation.Instance.Camera;

#if !XBOX360
            MouseState ms = Mouse.GetState();


            Vector2 where, dir;
            where  = new Vector2(ms.X, ms.Y);
            where  = (where - cam.ZoomPoint) / cam.Zoom;
            where += cam.Position;

            if (ms.LeftButton == ButtonState.Pressed)
            {
                if (_lastMS.LeftButton != ButtonState.Pressed)
                {
                    _mouseDownMS = ms;
                }

                dir = new Vector2(ms.X - _lastMS.X, ms.Y - _lastMS.Y) / 10f;
                if (_currentTool == "explosion32")
                {
                    PrimalDevistation.Instance.Explode(32, where, dir, null, false);
                }
                else if (_currentTool == "explosion64")
                {
                    PrimalDevistation.Instance.Explode(64, where, dir, null, false);
                }
                else if (_currentTool == "explosion128")
                {
                    PrimalDevistation.Instance.Explode(128, where, dir, null, false);
                }
            }
            else
            {
                if (_currentTool == "wep" && _lastMS.LeftButton == ButtonState.Pressed)
                {
                    dir = new Vector2(ms.X - _mouseDownMS.X, ms.Y - _mouseDownMS.Y) / 20f;
                    PrimalDevistation.Instance.Weapons.SpawnWeapon(_spawnWeapon, where, dir, null);
                }
            }

            if (ms.ScrollWheelValue != _lastMS.ScrollWheelValue)
            {
                int wheelDiff = ms.ScrollWheelValue - _lastMS.ScrollWheelValue;
                cam.Zoom = cam.Zoom + (wheelDiff / 5000f);
                //cam.ZoomPoint = new Vector2(ms.X,ms.Y);
            }

            _lastMS = ms;
            _lastKS = ks;
#endif

            if (ks.IsKeyDown(Keys.Left))
            {
                cam.Move(-8f, 0f);
            }
            if (ks.IsKeyDown(Keys.Right))
            {
                cam.Move(8f, 0f);
            }
            if (ks.IsKeyDown(Keys.Up))
            {
                cam.Move(0f, -8f);
            }
            if (ks.IsKeyDown(Keys.Down))
            {
                cam.Move(0f, 8f);
            }
        }