예제 #1
0
 /* Use this for initialization */
 void ViewSetup()
 {
     // Get Connected Sphero
     m_Spheros = SpheroProvider.GetSharedProvider().GetConnectedSpheros();
     SpheroDeviceMessenger.SharedInstance.NotificationReceived += ReceiveNotificationMessage;
     if (m_Spheros.Length == 0)
     {
         Application.LoadLevel("SpheroConnectionScene");
     }
 }
 /* Use this to initialize the view */
 private void ViewSetup()
 {
     m_SpheroProvider = SpheroProvider.GetSharedProvider();
             #if UNITY_ANDROID
     SetupAndroid();
             #elif UNITY_IPHONE
     SetupIOS();
             #else
     // Display that it doesn't work with these platforms?
             #endif
 }
예제 #3
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = SpheroProvider.GetSharedProvider().GetSphero(message.RobotID);

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
            Application.LoadLevel("NoSpheroConnectedScene");
        }
    }
예제 #4
0
 /* This is called when the application returns from or enters background */
 void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         SpheroProvider.GetSharedProvider().DisconnectSpheros();
         // Initialize the device messenger which sets up the callback
         SpheroDeviceMessenger.SharedInstance.NotificationReceived -= ReceiveNotificationMessage;
     }
     else
     {
         ViewSetup();
     }
 }
 /* This is called when the application returns from background or entered from NoSpheroConnectionScene */
 void OnApplicationPause(bool pause)
 {
     if (pause)
     {
         // Initialize the device messenger which sets up the callback
         SpheroProvider.GetSharedProvider().DisconnectSpheros();
         ARUNBridge._ARUNBridgeQuitVisionEngine();
     }
     else
     {
         ViewSetup();
     }
 }
예제 #6
0
    void touchManager()
    {
        if (Input.GetMouseButtonUp(0))
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hitInfo))
            {
                string objectHitName = hitInfo.transform.gameObject.name;
                switch (objectHitName)
                {
                case "btnInfo":
                    switch (currentPage)
                    {
                    case Page.PLAY:
                        InfoGame();
                        break;

                    case Page.INFO:
                        UnInfoGame();
                        break;

                    default:
                        currentPage = Page.PLAY;
                        break;
                    }
                    break;

                case "btnRank":
                    UnInfoGame();
                    SceneManager.LoadScene("Settings-c#");
                    break;

                case "retryButtonPause":
                    UnInfoGame();
                    SceneManager.LoadScene("Menu-c#");
                    break;

                case "menuButtonPause":
                    UnInfoGame();
                    SceneManager.LoadScene("Menu-c#");
                    break;

                case "btnExit":
                    UnInfoGame();
                    Application.Quit();
                    SpheroProvider.GetSharedProvider().DisconnectSpheros();
                    break;
                }
            }
        }
    }
예제 #7
0
    /*
     * Callback to receive connection notifications
     */
    private void ReceiveNotificationMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs)
    {
        // Event handler that listens for disconnects. An example of when one would be received is when Sphero
        // goes to sleep.
        SpheroDeviceNotification message = (SpheroDeviceNotification)eventArgs.Message;
        Sphero notifiedSphero            = SpheroProvider.GetSharedProvider().GetSphero(message.RobotID);

        if (message.NotificationType == SpheroDeviceNotification.SpheroNotificationType.DISCONNECTED)
        {
            notifiedSphero.ConnectionState = Sphero.Connection_State.Disconnected;
            streaming = false;
            Application.LoadLevel("NoSpheroConnectedScene");
        }
    }
예제 #8
0
 /* Use this for initialization */
 void ViewSetup()
 {
     // Get Connected Spheros
     m_Spheros = SpheroProvider.GetSharedProvider().GetConnectedSpheros();
     SpheroDeviceMessenger.SharedInstance.NotificationReceived += ReceiveNotificationMessage;
     if (m_Spheros.Length == 0)
     {
         Application.LoadLevel("SpheroConnectionScene");
     }
     foreach (Sphero sphero in m_Spheros)
     {
         sphero.SetRGBLED(BLUE.r, BLUE.g, BLUE.b);
     }
 }
예제 #9
0
    /* This is called when the application returns from background or entered from NoSpheroConnectionScene */
    void OnApplicationPause(bool pause)
    {
#if !UNITY_EDITOR
        if (pause)
        {
            ARUNBridge._ARUNBridgePauseVisionEngine();
        }
        else
        {
            ARUNBridge._ARUNBridgeStartVisionEngine();
            SpheroProvider.GetSharedProvider().Connect(0);
            StartCoroutine(DelaySpheroConnection());
        }
#endif
    }
예제 #10
0
    // Update is called once per frame
    void Update()
    {
        if (!streaming &&
            SpheroProvider.GetSharedProvider().GetConnectedSpheros().Length > 0)
        {
            // Setup streaming for the first time once a Sphero is connected.
            //// Register the event handler call back with the SpheroDeviceMessenger
            SpheroDeviceMessenger.SharedInstance.AsyncDataReceived += ReceiveAsyncMessage;
            //// Get the currently connected Sphero
            Sphero[] spheros =
                SpheroProvider.GetSharedProvider().GetConnectedSpheros();
            m_Sphero = spheros[0];
            //// Enable data streaming for controller app. This method turns off stabilization (disables the wheel motors),
            //// turn on the back LED (negative x axis reference), and sets data streaming at 20 samples/sec (400/20),
            //// a single sample per packet sent, and turns on accelerometer, quaternion, and IMU (attitude) sampling.
            m_Sphero.EnableControllerStreaming(20, 1,
                                               SpheroDataStreamingMask.AccelerometerFilteredAll |
                                               SpheroDataStreamingMask.QuaternionAll |
                                               SpheroDataStreamingMask.IMUAnglesFilteredAll);

            streaming = true;
        }
    }
예제 #11
0
    void Start()
    {
        ARUNController controller = ARUNController.Instance;

        if (controller != null)
        {
            controller.OnVisionUpdate += OnVisionUpdate;
        }
        else
        {
            //Debug.LogWarning("AureController.Instance not set");
        }
#if !UNITY_EDITOR
        // Get first connected Sphero
        Sphero[] spheros = SpheroProvider.GetSharedProvider().GetConnectedSpheros();
        if (spheros.Length > 0)
        {
            sphero = spheros[0];
            sphero.AddDataStreamingMask((ulong)kVisionMask);
            SpheroDeviceMessenger.SharedInstance.AsyncDataReceived += ReceiveAsyncMessage;
        }
#endif
    }