コード例 #1
0
ファイル: Monster.cs プロジェクト: patricknboyd/reborn-mars
        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()));
            }

        }
コード例 #2
0
ファイル: Monster.cs プロジェクト: patricknboyd/reborn-mars
        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;
                }
            }

        }