Example #1
0
        public Robot ChangeDirection(DirectionalMove move)
        {
            if (_direction == Direction.North)
            {
                if (move == DirectionalMove.Left)
                {
                    _direction = Direction.West;
                }

                if (move == DirectionalMove.Right)
                {
                    _direction = Direction.East;
                }
            }
            else if (_direction == Direction.South)
            {
                if (move == DirectionalMove.Left)
                {
                    _direction = Direction.East;
                }

                if (move == DirectionalMove.Right)
                {
                    _direction = Direction.West;
                }
            }
            else if (_direction == Direction.East)
            {
                if (move == DirectionalMove.Left)
                {
                    _direction = Direction.North;
                }

                if (move == DirectionalMove.Right)
                {
                    _direction = Direction.South;
                }
            }
            else if (_direction == Direction.West)
            {
                if (move == DirectionalMove.Left)
                {
                    _direction = Direction.South;
                }

                if (move == DirectionalMove.Right)
                {
                    _direction = Direction.North;
                }
            }
            else
            {
                throw new Exception("Direction unknown");
            }

            return(this);
        }
Example #2
0
        void Start()
        {
            // Player movement scripts
            click       = player.GetComponent <ClickToMove>();
            directional = player.GetComponent <DirectionalMove>();
            firstPerson = player.GetComponent <FirstPersonMove>();

            // Camera movement scripts
            topDown    = cam.GetComponent <CameraTopDown>();
            topDownPan = cam.GetComponent <CameraTopDownPan>();
            fps        = cam.GetComponent <CameraFirstPerson>();

            // Set variables for initial camera position and rotation
            camPos = cam.transform.position;
            camRot = cam.transform.rotation;
        }
Example #3
0
    internal SquareLocation Apply(DirectionalMove m)
    {
        if (m.Dir == Direction.DOWN)
        {
            Col = Col - (int)m.Num;
        }
        else if (m.Dir == Direction.UP)
        {
            Col = Col + (int)m.Num;
        }
        else if (m.Dir == Direction.LEFT)
        {
            Row = Row - (int)m.Num;
        }
        else // RIGHT
        {
            Row = Row + (int)m.Num;
        }

        return(this);
    }
        // Determine the type of message and return an appropriate object
        // base on a variety of metrics
        public static Message createMessage(string text)
        {
            Message message = null;

            string commandType = getCommandType(text);

            if (text.StartsWith(Command.getKeyword()))
            {
                message = new Command(text);
            }
            else if (text.StartsWith(Status.getKeyword()))
            {
                message = new Status(text);
            }
            else if (text.StartsWith(Ok.getKeyword()))
            {
                message = new Ok(text);
            }
            else if (text.StartsWith(Error.getKeyword()))
            {
                message = new Error(text);
            }
            else if (text.StartsWith(BatteryQuery.getKeyword()))
            {
                message = new BatteryQuery(text);
            }
            else if (text.StartsWith(SpeedQuery.getKeyword()))
            {
                message = new SpeedQuery(text);
            }
            else if (text.StartsWith(TimeQuery.getKeyword()))
            {
                message = new TimeQuery(text);
            }
            else if (text.StartsWith(Curve.getKeyword()))
            {
                message = new Curve(text);
            }
            else if (text.StartsWith(Flip.getKeyword()))
            {
                message = new Flip(text);
            }
            else if (text.StartsWith(Go.getKeyword()))
            {
                message = new Go(text);
            }
            else if (text.StartsWith(Jump.getKeyword()))
            {
                message = new Jump(text);
            }
            else if (text.StartsWith(Land.getKeyword()))
            {
                message = new Land(text);
            }
            else if (text.StartsWith(Takeoff.getKeyword()))
            {
                message = new Takeoff(text);
            }
            else if (Rotate.getKeywords().Any(keyword => text.StartsWith(keyword)))
            {
                message = new Rotate(text);
            }
            else if (DirectionalMove.getKeywords().Any(keyword => text.StartsWith(keyword)))
            {
                message = new DirectionalMove(text);
            }
            else
            {
                message = new DataResponse(text);
            }

            return(message);
        }