Example #1
0
        protected virtual bool CanMoveInDirection(MoveTestResult testResult)
        {
            switch (Movement)
            {
                case MonsterMovementType.Walk:
                    return testResult.Tile.IsWalkable;

                case MonsterMovementType.Fly:
                    return testResult.Tile.IsFlyable;

                case MonsterMovementType.Swim:
                    return testResult.Tile.IsSwimmable;

                default:
                    throw new ArgumentException(string.Format(ErrorMessages.UnrecognizedEnumValue, Movement.ToString()));
            }

        }
Example #2
0
        public virtual void Move(MoveDirection dir)
        {
            MapState state = Game.Current.Dungeon.CurrentMapState;
            IMap map = state.Map;

            MoveTestResult moveTest = state.MoveTest(Position, dir);

            if (moveTest.IsMoveValid && CanMoveInDirection(moveTest))
            {
                if (moveTest.Monster != null)
                {
                    var attackResult = Attack(moveTest.Monster);
                    OutputAttackResult(attackResult, moveTest.Monster);
                }
                else
                {
                    Position = moveTest.NewPosition;
                }
            }

        }