Пример #1
0
        public void Draw(MapEngine map)
        {
            animation.Y = (int)direction;

            var pos = map.Transform(Pos);

            _actorManager.Draw(_charSetName, animation.SourceRect, animation.DrawRect(pos));
        }
Пример #2
0
        public void MoveRight(MapEngine map, float deltaTime)
        {
            direction = Direction.Right;

            var dest = Pos;

            dest.X += deltaTime * speedX;

            if (!map.IsCollision(dest.ToVector(), direction))
            {
                Pos.X += deltaTime * speedX;
            }

            if (Pos.X > map.Width)
            {
                Pos.X = map.Width;
            }
        }
Пример #3
0
        public void MoveLeft(MapEngine map, float deltaTime)
        {
            direction = Direction.Left;

            var dest = Pos;

            dest.X -= deltaTime * speedX;

            if (!map.IsCollision(dest.ToVector(), direction))
            {
                Pos.X -= deltaTime * speedX;
            }

            if (Pos.X < 0)
            {
                Pos.X = 0;
            }
        }
Пример #4
0
        public void MoveDown(MapEngine map, float deltaTime)
        {
            direction = Direction.Down;

            var dest = Pos;

            dest.Y += deltaTime * speedY;

            if (!map.IsCollision(dest.ToVector(), direction))
            {
                Pos.Y += deltaTime * speedY;
            }

            if (Pos.Y > map.Height)
            {
                Pos.Y = map.Height;
            }
        }
Пример #5
0
        public void MoveUp(MapEngine map, float deltaTime)
        {
            direction = Direction.Up;

            var dest = Pos;

            dest.Y -= deltaTime * speedY;

            if (!map.IsCollision(dest.ToVector(), direction))
            {
                Pos.Y -= deltaTime * speedY;
            }

            if (Pos.Y < 0)
            {
                Pos.Y = 0;
            }
        }
Пример #6
0
        public WorldState(
            IDataStore dataStore, IEventService eventService, ISongManager songManager, IGraphics graphics, IBattleManager battleManager, IActorManager actorManager,
            IEnemyManager enemyManager, IIconManager iconManager, IInputManager inputManager, ITilesetManager tilesetManager,
            IDialogManager dialogManager)
        {
            _inputManager  = inputManager;
            _dialogManager = dialogManager;
            _eventService  = eventService;
            _graphics      = graphics;
            _songManager   = songManager;

            Party = new Party
            {
                Actors = new List <Actor> {
                    new Actor("gus", "gus")
                    {
                        Name = "Gus", Hp = 40, MaxHp = 58, Mp = 2, MaxMp = 8, Limit = 23
                    },
                    new Actor("fitz", "fitz")
                    {
                        Name = "Fitz", Hp = 32, MaxHp = 52, Mp = 5, MaxMp = 12, Limit = 17
                    },
                    new Actor("sorah", "sorah")
                    {
                        Name = "Sorah", Hp = 102, MaxHp = 252, Mp = 8, MaxMp = 12, Limit = 37
                    },
                    new Actor("sheba", "sheba")
                    {
                        Name = "Sheba", Hp = 44, MaxHp = 52, Mp = 8, MaxMp = 12, Limit = 5
                    }
                }
            };

            Map                    = new MapEngine(dataStore, _eventService, iconManager, tilesetManager, $"../../../../Data/Game/map/", mapName);
            gamePlayer             = new GamePlayer(Party.Actors[0].CharSet, inputManager, actorManager, Map.Start);
            gamePlayer.WalkOnTile += new GamePlayer.MoveEventHandler(OnWalkOnTile);
            gamePlayer.Action     += new GamePlayer.PlayerEventHandler(OnAction);

            _npcManager = new NPCManager(actorManager, _dialogManager, _graphics);
        }
Пример #7
0
        public void Update(MapEngine map)
        {
            switch (Movement)
            {
            case Movement.Walking:

                if (Pos == _destination || (_destination.X == 0 && _destination.Y == 0) || _step > 100)
                {
                    _destination = NextDestination();
                }

                var oldPos = Pos;

                // move towards destination
                if (Pos.X > _destination.X && Pos.X > 0 && !map.IsCollision(Pos, Direction.Left))
                {
                    Pos.X--;
                }
                else if (Pos.X < _destination.X && Pos.X < map.Width && !map.IsCollision(Pos, Direction.Right))
                {
                    Pos.X++;
                }

                if (Pos.Y > _destination.Y && Pos.Y > 0 && !map.IsCollision(Pos, Direction.Up))
                {
                    Pos.Y--;
                }
                else if (Pos.Y < _destination.Y && Pos.Y < map.Height && !map.IsCollision(Pos, Direction.Down))
                {
                    Pos.Y++;
                }

                _step++;

                Animation.Step();

                break;
            }
        }
Пример #8
0
        public void Update(MapEngine map, float deltaTime)
        {
            // save old position
            var oldPos = (Pos / new VectorF(map.TileWidth, map.TileHeight)).ToVector();

            // running
            if (_inputManager.IsPressedInput((int)Input.FaceButtonLeft))
            {
                speedX = speedY = 300;
            }
            else
            {
                speedX = speedY = 150;
            }

            // animate
            if (_inputManager.IsPressedKey((int)Keys.Up) || _inputManager.IsPressedKey((int)Keys.Down) || _inputManager.IsPressedKey((int)Keys.Left) || _inputManager.IsPressedKey((int)Keys.Right))
            {
                animation.Step();
                IsMoving = true;
                step    += deltaTime;
                if (_inputManager.IsPressedInput((int)Input.FaceButtonLeft))
                {
                    step += deltaTime;
                }
            }
            else
            {
                animation.frame = 1;
                IsMoving        = false;
            }

            // move player
            if (_inputManager.IsPressedKey((int)Keys.Up))
            {
                MoveUp(map, deltaTime);
            }

            if (_inputManager.IsPressedKey((int)Keys.Down))
            {
                MoveDown(map, deltaTime);
            }

            if (_inputManager.IsPressedKey((int)Keys.Left))
            {
                MoveLeft(map, deltaTime);
            }

            if (_inputManager.IsPressedKey((int)Keys.Right))
            {
                MoveRight(map, deltaTime);
            }

            if (_inputManager.AnyPressedKey((int)Keys.Up, (int)Keys.Down, (int)Keys.Left, (int)Keys.Right))
            {
                map.UpdateCamera(Pos.ToVector());
            }

            // check walkon event
            var newPos = (Pos / new VectorF(map.TileWidth, map.TileHeight)).ToVector();

            if (newPos != oldPos)
            {
                WalkOnTile(new MoveEventArgs(oldPos, newPos));
            }

            // action button pressed
            if (_inputManager.IsPressedInput((int)Input.FaceButtonDown))
            {
                Action();
            }
        }