protected override void OnMessageReceived(string message)
        {
            RawInput raw = InputMessageParser.ParseMessage(message);

            if (raw == null)
            {
                return;
            }

            var optionalButton = InputMessageParser.ParseButton(raw);

            if (optionalButton is AllInputButtons button)
            {
                Debug.Log($"Received input {button.ToString()}");
                InputSender.Send(button);
            }
            else
            {
                var formattedMessage = $"{raw.controllerCommand} {raw.controllerValue}";
                if (settings.LogDebugInfo)
                {
                    Debug.Log($"Received message {formattedMessage}");
                }
                Events.Instance.Raise(new InputUpdate(formattedMessage));
            }
        }
Ejemplo n.º 2
0
    void Update()
    {
        Touch[] touches        = Input.touches;
        Touch   mainTouch      = new Touch();
        bool    existMainTouch = false;

        foreach (Touch touch in touches)
        {
            if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
            {
                mainTouch      = touch;
                existMainTouch = true;
                break;
            }
        }
        if (existMainTouch)
        {
            if (Physics.Raycast(Camera.main.ScreenPointToRay(mainTouch.position), out RaycastHit hit))
            {
                Vector3 pos = hit.point;
                pos.y = Const.FRUIT_SPAWN_Y;
                senderConstant.Send(pos);
                lastPos         = pos;
                willSendLastPos = true;
            }
        }
        else
        {
            if (willSendLastPos)
            {
                willSendLastPos = false;
                sender.Send(lastPos);
            }
        }
    }
Ejemplo n.º 3
0
 void Update()
 {
     if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
     {
         Vector3 pos = hit.point;
         pos.y = Const.FRUIT_SPAWN_Y;
         senderConstant.Send(pos);
         if (Input.GetMouseButtonDown(0))
         {
             sender.Send(pos);
         }
     }
 }
Ejemplo n.º 4
0
 public void SendButtonToController()
 {
     InputSender.Send(allInputButtons);
 }