Exemplo n.º 1
0
    void Update()
    {
        if (!refresh)
        {
            return;
        }

        for (int i = 0; i < ButtonCount; i++)
        {
            prevButtonState[i] = buttonStates[i];
        }

#if UNITY_ANDROID
        if (plugin != null)
        {
            x1 = (float)plugin.Call <double>("getPressure");
            DebugText.show("Ps: " + x1, 2);
        }
        else
#endif
        {           // For game testing in Editor without controller
            float val = Input.GetAxis("Mouse ScrollWheel");
            x1 = Mathf.Clamp(val + x1, -1f, 1f);
        }
    }
Exemplo n.º 2
0
    public IEnumerator CountDown(float countdownSeconds = 10f)
    {
        remainingTime = countdownSeconds;
        while (remainingTime > 0)
        {
            DebugText.show("Time: " + remainingTime);
            yield return(new WaitForSeconds(1.0f));

            remainingTime--;
        }
        // toggle game mode
    }
Exemplo n.º 3
0
    // Call back invoked by the Java Plugin.
    public void BleStatus(String status = null)
    {
        if (status != null)
        {
            DebugText.show("Ble status: " + status);

            if (status.StartsWith("ready"))
            {
                refresh = true;
            }
            else
            {
                refresh = false;
            }
        }
    }
Exemplo n.º 4
0
    // Activate / deactivate different game items based on game mode
    void ActivateBonusGame(Game gameMode)
    {
        float  gameTime  = 10;
        string gameTitle = "";

        playerCamera.transform.position = originalPlayerPosition;

        switch (gameMode)
        {
        case Game.SyncBreath:
            playerBall.SetActive(true);
            syncBall.SetActive(true);
            fillBalloon.SetActive(false);
            shootBalloon.SetActive(false);
            gameTime  = BreathSyncGameTime;
            gameTitle = "Sync Breath";
            shooter.SetActive(false);

            break;

        case Game.FillBalloon:
            playerBall.SetActive(false);
            syncBall.SetActive(false);
            fillBalloon.SetActive(true);
            shootBalloon.SetActive(false);
            gameTime  = FillBalloonGameTime;
            gameTitle = "Fill Balloon";
            shooter.SetActive(false);

            break;

        case Game.ShootBallon:
            playerCamera.transform.Translate(new Vector3(0, 7, 0));
            playerBall.SetActive(false);
            syncBall.SetActive(false);
            fillBalloon.SetActive(false);
            shootBalloon.SetActive(true);
            gameTitle = "Shoot Balloon";
            gameTime  = FillBalloonGameTime;
            shooter.SetActive(true);
            break;
        }

        StartCoroutine(CountDown(gameTime));
        DebugText.show(gameTitle, 1);
    }
Exemplo n.º 5
0
    void Start()
    {
        if (_instance == null)
        {
            _instance = this;
        }

#if UNITY_ANDROID
        try {
            plugin = new AndroidJavaClass("com.chuart.breathgame.SensorPlugin").CallStatic <AndroidJavaObject>("getInstance");
            DebugText.show("Plugin loaded");
            plugin.Call("connectBLEController", "connect");
            DebugText.show("Waiting connection ..");
        } catch (Exception e) {
            DebugText.show("Error init Class");
        }
        if (debug)
        {
            refresh = true;
        }
 #else
        refresh = true;
 #endif
    }