示例#1
0
        private ActionReport MoveAround(Phase phase)
        {
            if (base.Attributes.PossibleMovementUnitWithOneUniversalMovement == null)
            {
                throw new InvalidOperationException("This being cannot move, as he has no movement.");
            }
            int newX = Position.X;
            int newY = Position.Y;

            // movement can be easily improved
            switch (random.Next(1, 4))
            {
            case 1: newX = base.Position.X + base.Attributes.PossibleMovementUnitWithOneUniversalMovement.Value; break;

            case 2: newX = base.Position.X - base.Attributes.PossibleMovementUnitWithOneUniversalMovement.Value; break;

            case 3: newY = base.Position.Y + base.Attributes.PossibleMovementUnitWithOneUniversalMovement.Value; break;

            case 4: newY = base.Position.Y - base.Attributes.PossibleMovementUnitWithOneUniversalMovement.Value; break;

            default: throw new InvalidOperationException("Not Expected!");
            }

            Point wantedPoint = new Point(newX, newY);

            if (phase.CanIMoveInThePointPlace(this, wantedPoint))
            {
                this.Position = wantedPoint;
            }

            return(new ActionReport());
        }