Пример #1
0
        public Direction MoveOrRotate(Direction currentDirection)
        {
            Direction nextDirection;

            if (NextAction.Equals(KeyActionType.MoveDown))
            {
                nextDirection = Direction.Down;
            }
            else if (NextAction.Equals(KeyActionType.MoveUp))
            {
                nextDirection = Direction.Up;
            }
            else if (NextAction.Equals(KeyActionType.MoveLeft))
            {
                nextDirection = Direction.Left;
            }
            else if (NextAction.Equals(KeyActionType.MoveRight))
            {
                nextDirection = Direction.Right;
            }
            else
            {
                return(currentDirection);
            }

            return(nextDirection == currentDirection?Move(currentDirection, nextDirection) : Rotate(currentDirection, nextDirection));
        }
Пример #2
0
 public virtual Direction DoAction(Direction currentDirection)
 {
     if (CanDoAction() && NextAction != null)
     {
         return(NextAction.Equals(KeyActionType.Shoot) ? Shoot(currentDirection) : MoveOrRotate(currentDirection));
     }
     else if (NextAction is null && Owner is Enemy)
     {
         SetRandomizedCooldown();
     }
     return(currentDirection);
 }