Beispiel #1
0
        void Update()
        {
            if (isGameOver || localHumanColor == PlayerColor.None)
            {
                return;
            }

            int direction = -1;

            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                direction = 3;
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                direction = 2;
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                direction = 1;
            }
            else if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                direction = 0;
            }


            if (direction == -1)
            {
                return;
            }

            GameCommand outMsg = new GameCommand(localHumanColor, (short)direction);

            sendServerMsg(outMsg, (short)SnakeProtocol.MsgType.playerCommands);
        }