示例#1
0
 public CpuGuyDecorator(Guy.Guy guy, SpriteFont font)
 {
     Guy              = guy;
     _font            = font;
     _controlPatterns = new CircularArray <CpuKeyboardControls>(
         CpuKeyboardControlsFactory.RunningCelebration(),
         CpuKeyboardControlsFactory.RunBackAndForth(),
         CpuKeyboardControlsFactory.Cannonball(),
         CpuKeyboardControlsFactory.JumpAndSquat());
     KeyboardEventRegistry.OnKeyDown(Keys.Left, OnLeft);
     KeyboardEventRegistry.OnKeyDown(Keys.Right, OnRight);
 }
示例#2
0
        private static void keepGuyOnCamera(Guy.Guy guy, Camera camera)
        {
            //Make the level wrap around, horizontally.
            var cameraRect = camera.GetVisibleArea();

            if (guy.Physics.Right < cameraRect.Left)
            {
                guy.Physics.Position.X = cameraRect.Right;
            }
            if (guy.Physics.Left > cameraRect.Right + 1)
            {
                //Wrap from the right to the left.
                guy.Physics.Position.X = cameraRect.Left - guy.Physics.Width;
            }
        }
示例#3
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            //
            var cb = Window.ClientBounds;

            _guy = GuyFactory.Create(
                GraphicsDevice,
                Content,
                new DebugLogger(),
                new Vector2(0, 0));
            //
            _font            = Content.Load <SpriteFont>("Consolas");
            _cpuGuyDecorator = new CpuGuyDecorator(_guy, _font);
        }