Exemple #1
0
    //process commands received from remote controller
    public void OnNetworkReceive(NetPeer peer, NetDataReader reader)
    {
        ControlMsg msg    = (ControlMsg)reader.GetInt();
        bool       turnOn = reader.GetInt() > 0;

        receivedMessageInfo.text = string.Format("received message: {0} {1}", msg, turnOn);

        switch (msg)
        {
        case ControlMsg.forward:
            if (turnOn)
            {
                localForwardBtn.OnPointerDown(null);
            }
            else
            {
                localForwardBtn.OnPointerUp(null);
            }
            break;

        case ControlMsg.backward:
            if (turnOn)
            {
                localBackwardBtn.OnPointerDown(null);
            }
            else
            {
                localBackwardBtn.OnPointerUp(null);
            }
            break;

        case ControlMsg.left:
            if (turnOn)
            {
                localLeftBtn.OnPointerDown(null);
            }
            else
            {
                localLeftBtn.OnPointerUp(null);
            }
            break;

        case ControlMsg.right:
            if (turnOn)
            {
                localRightBtn.OnPointerDown(null);
            }
            else
            {
                localRightBtn.OnPointerUp(null);
            }
            break;

        case ControlMsg.light:
            FlashLight.ToggleAndroidFlashlight();
            break;
        }
    }
Exemple #2
0
 public void OnToggleLightBtnClick()
 {
     FlashLight.ToggleAndroidFlashlight();
 }