示例#1
0
        public InGameState(Game g)
        {
            this.g      = g;
            spriteBatch = new SpriteBatch(g.GraphicsDevice);

            keyboard       = new KeyboardHandler();
            mouse          = new MouseHandler();
            player         = new PC();
            player.texture = g.Content.Load <Texture2D>("TestSprite");
            player.camera  = new Camera(g.GraphicsDevice);
            player.movementState.Change("idle");
            //create a builder for frame shit sometime

            //endof create a builder for frame shit sometime


            scroller = new TileScroller();

            currentMap = g.Content.Load <MapData>("Maps/TestMap");
            scroller.loadMap(g.Content, currentMap);


            keyboard.AddKeyEvent(Keys.W, KeyboardHandler.KeyEventType.OnKeyDown, () => {
                player.directionFlags.N     = true;
                player.directionFlags.CLICK = false;
                player.movementState.Change("move");
            });

            keyboard.AddKeyEvent(Keys.W, KeyboardHandler.KeyEventType.OnKeyUp, () => {
                player.directionFlags.N = false;
            });

            keyboard.AddKeyEvent(Keys.A, KeyboardHandler.KeyEventType.OnKeyDown, () => {
                player.directionFlags.W     = true;
                player.directionFlags.CLICK = false;
                player.movementState.Change("move");
            });

            keyboard.AddKeyEvent(Keys.A, KeyboardHandler.KeyEventType.OnKeyUp, () => {
                player.directionFlags.W = false;
            });

            keyboard.AddKeyEvent(Keys.S, KeyboardHandler.KeyEventType.OnKeyDown, () =>
            {
                player.directionFlags.S     = true;
                player.directionFlags.CLICK = false;
                player.movementState.Change("move");
            });

            keyboard.AddKeyEvent(Keys.S, KeyboardHandler.KeyEventType.OnKeyUp, () =>
            {
                player.directionFlags.S = false;
            });

            keyboard.AddKeyEvent(Keys.D, KeyboardHandler.KeyEventType.OnKeyDown, () =>
            {
                player.directionFlags.E     = true;
                player.directionFlags.CLICK = false;
                player.movementState.Change("move");
            });

            keyboard.AddKeyEvent(Keys.D, KeyboardHandler.KeyEventType.OnKeyUp, () =>
            {
                player.directionFlags.E = false;
            });

            keyboard.AddKeyEvent(Keys.OemTilde, KeyboardHandler.KeyEventType.OnKeyPress, () =>
            {
                MemoryManager.DebugMode = !MemoryManager.DebugMode;
            });

            keyboard.AddKeyEvent(Keys.LeftShift, KeyboardHandler.KeyEventType.OnKeyDown, () =>
            {
                player.isRunning = true;
            });

            keyboard.AddKeyEvent(Keys.LeftShift, KeyboardHandler.KeyEventType.OnKeyPress, () =>
            {
                player.isRunning = false;
            });

            keyboard.AddKeyComboDownEvent(new Input.KeyCombo {
                Keys.LeftShift, Keys.E
            }, () =>
            {
                Console.WriteLine("SHIFT E");
            });

            keyboard.AddKeyEvent(Keys.E, KeyboardHandler.KeyEventType.OnKeyDown, () =>
            {
                Console.WriteLine("E");
            });

            keyboard.AddKeyEvent(Keys.LeftShift, KeyboardHandler.KeyEventType.OnKeyDown, () =>
            {
                Console.WriteLine("SHIFT");
            });

            mouse.AddMouseEvent(MouseHandler.MouseEventType.OnMouseMove, () =>
            {
                //SetFaceDirection();
            });

            mouse.AddButtonEvent(MouseHandler.ButtonType.RightButton, MouseHandler.ButtonEventType.OnButtonDown, () =>
            {
                //player.directionFlags.CLICK = true;
            });

            mouse.AddButtonEvent(MouseHandler.ButtonType.RightButton, MouseHandler.ButtonEventType.OnButtonUp, () =>
            {
                //player.directionFlags.CLICK = false;
            });

            mouse.AddButtonEvent(MouseHandler.ButtonType.LeftButton, MouseHandler.ButtonEventType.OnButtonDownDelay, () =>
            {
            }, 200);

            mouse.AddButtonEvent(MouseHandler.ButtonType.LeftButton, MouseHandler.ButtonEventType.OnButtonClick, () =>
            {
            });

            mouse.AddButtonEvent(MouseHandler.ButtonType.LeftButton, MouseHandler.ButtonEventType.OnButtonDragging, () =>
            {
            });
        }