void ManagerInput_FireNewInput(object sender, MyEventArgs.NewInputEventArgs e)
 {
     if (e.Input == Input.Enter)
     {
         ManagerScreen.LoadNewScreen(new ScreenWorld(ManagerScreen));
     }
 }
Example #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _managerScreen = new ManagerScreen(Content);
            //_managerScreen.LoadNewScreen(new ScreenWorld(_managerScreen));
            _managerScreen.LoadNewScreen(new ScreenStart(_managerScreen));
        }
Example #3
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     ManagerContent.Initialize(Content);
     spriteBatch    = new SpriteBatch(GraphicsDevice);
     _managerScreen = new ManagerScreen(Content);
     _managerWindow = new ManagerWindow();
     _managerLists  = new ManagerLists();
     _managerLists.Initialize();
     //_managerScreen.LoadNewScreen(new ScreenWorld(_managerScreen));
     _managerScreen.LoadNewScreen(new ScreenStart(_managerScreen), false);
     // TODO: use this.Content to load your game content here
 }
        void ManagerInput_FireNewInput(object sender, MyEventArgs.NewInputEventArgs e)
        {
            var sprite = GetComponent <Sprite>();

            if (sprite == null)
            {
                return;
            }

            var collision = GetComponent <Collision>();

            var x = 0f;
            var y = 0f;

            var camera = GetComponent <Camera>();

            if (camera == null)
            {
                return;
            }
            var       animation = GetComponent <Animation>();
            Equipment equipment;

            if (!camera.CameraInTransition())
            {
                switch (e.Input)
                {
                case Input.Up:
                    y = -1.5f;
                    break;

                case Input.Down:
                    y = 1.5f;
                    break;

                case Input.Left:
                    x = -1.5f;
                    break;

                case Input.Right:
                    x = 1.5f;
                    break;

                case Input.A:
                    if (animation.CurrentState == State.Walking)
                    {
                        animation.StopAnimation();
                    }
                    equipment = GetComponent <Equipment>();
                    equipment.FireItem(ItemSlot.A);
                    break;

                case Input.S:
                    if (animation.CurrentState == State.Walking)
                    {
                        animation.StopAnimation();
                    }
                    //ManagerEvents.AddEvents(new List<IGameEvent> {new GameEventMessage("I just started a new event with my s button")});
                    equipment = GetComponent <Equipment>();
                    equipment.FireItem(ItemSlot.B);
                    break;

                case Input.Start:
                    if (!ManagerEvents.Active)
                    {
                        _managerScreen.LoadNewScreen(
                            new ScreenMainMenu(_managerScreen,
                                               GetComponent <Stats>(),
                                               GetComponent <Equipment>()));
                    }
                    break;

                case Input.Select:
                    camera = GetComponent <Camera>();
                    if (camera != null)
                    {
                        _managerScreen.LoadNewScreen(new ScreenOverworldMap(_managerScreen, _managerPlayer,
                                                                            camera.CameraTilePositon));
                    }
                    break;

                default:
                    return;
                }
            }

            if (collision == null ||
                !collision.CheckCollisionWithTiles(new Rectangle((int)(sprite.Position.X + x),
                                                                 (int)(sprite.Position.Y + y), sprite.Width, sprite.Height)) && !collision.CheckCollisionWithEntities(
                    new Rectangle((int)(sprite.Position.X + x), (int)(sprite.Position.Y + y), sprite.Width, sprite.Height)))
            {
                sprite.Move(x, y);
            }
            else if (x != 0 || y != 0)
            {
                Direction direction;
                if (x > 0)
                {
                    direction = Direction.Right;
                }
                else if (x < 0)
                {
                    direction = Direction.Left;
                }
                else if (y > 0)
                {
                    direction = Direction.Down;
                }
                else
                {
                    direction = Direction.Up;
                }
                animation.PlayAnimation(State.Pushing, direction);
            }
            else
            {
                animation.PlayAnimation(State.Standing, animation.CurrentDirection);
            }

            Vector2 position;

            if (!camera.GetPosition(sprite.Position, out position))
            {
                camera.MoveCamera(animation.CurrentDirection);
                UpdateMap(camera, animation.CurrentDirection);
            }
        }