Пример #1
0
    // Use this for initialization
    private void Awake()
    {
        hasConnected = false;
        sendToZowi   = 0;

        BluetoothAdapter.enableBluetooth();//Force Enabling Bluetooth

        //Check if instance already exists
        if (instance == null)
        {
            //if not, set instance to this
            instance = this;
        }

        //If instance already exists and it's not this:
        else if (instance != this)
        {
            //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);


        device = new BluetoothDevice();
        //if (BluetoothAdapter.isBluetoothEnabled())
        //{
        //    connect();
        //}
        //else
        if (!BluetoothAdapter.isBluetoothEnabled())
        {
            BluetoothAdapter.enableBluetooth(); //you can by this force enabling Bluetooth without asking the user
            //statusText.text = "Status : Please enable your Bluetooth";

            //BluetoothAdapter.OnBluetoothStateChanged += HandleOnBluetoothStateChanged;
            BluetoothAdapter.listenToBluetoothState(); // if you want to listen to the following two events  OnBluetoothOFF or OnBluetoothON

            BluetoothAdapter.askEnableBluetooth();     //Ask user to enable Bluetooth
        }
    }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        GameObject moveBackground = GameObject.Find("MoveBackground");
        GameObject helpBackground = GameObject.Find("HelpBackground");

        switch (PlayerPrefs.GetInt("fontSizeIndex"))
        {
        case 0:
            moveBackground.transform.localScale                = new Vector2(1.0f, 1.0f);
            helpBackground.transform.localScale                = new Vector2(1.0f, 1.0f);
            help.GetComponent <RectTransform>().sizeDelta      = new Vector2(200.0f, 145);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(375, 145);
            break;

        case 1:
            moveBackground.transform.localScale                = new Vector2(1.0f, 1.2f);
            helpBackground.transform.localScale                = new Vector2(1.3f, 1.2f);
            help.GetComponent <RectTransform>().sizeDelta      = new Vector2(250.0f, 190);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(375, 190);
            break;

        case 2:
            moveBackground.transform.localScale                = new Vector2(1.0f, 1.5f);
            helpBackground.transform.localScale                = new Vector2(1.5f, 1.5f);
            help.GetComponent <RectTransform>().sizeDelta      = new Vector2(300.0f, 210);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(375, 210);
            break;
        }
        showMoves.fontSize      = PlayerPrefs.GetInt("fontSize");
        help.fontSize           = PlayerPrefs.GetInt("fontSize") - 5;
        loopState               = false;
        loopsFromSlider         = 2;
        howManyTimesToLoop.text = "Times To Loop : " + loopsFromSlider;
        countLoops              = 0;
        saveStartLocation       = -1;
        countTillLineSkip       = 0;
        growthSwitch            = true;
        shrinkSwitch            = true;

        turned      = false;
        facingRight = true;

        spinOrRoll = false;

        jumpSwitch = true;
        jumpReset  = false;

        startFormat = "<b><color=#00ff00ff>";
        endFormat   = "</color></b>";
        movementLengthCollection = 0;
        shrinkCount = 0;

        spinCount = 0;
        jumpCount = 0;

        buttonCount = 0;
        if (PlayerPrefs.GetInt("Scan") == 1)
        {
            StartCoroutine(scanner());
        }
        if (PlayerPrefs.GetInt("Voice") == 1)
        {
            narration.Play();
        }
        GameStatusEventHandler.gameWasStarted("challenge");

        zowiController = GameObject.FindObjectOfType <ZowiController>();
        growText       = GameObject.Find("Grow").GetComponentInChildren <Text>();
        shrinkText     = GameObject.Find("Shrink").GetComponentInChildren <Text>();
        zowiController = GameObject.FindObjectOfType <ZowiController>();
        if (zowiController.device.IsConnected)
        {
            zowiController.home();
            growText.text   = "Dance";
            shrinkText.text = "Swing";
        }
        else
        {
            growText.text   = "Grow";
            shrinkText.text = "Shrink";
        }
        transmittingBackground.SetActive(false);
        transmittingToZowi = false;

        //switch (ZowiController.time)
        //{
        //    case 1500:
        //        zowiCommandWaitTime = 3f;
        //        break;
        //    case 1000:
        //        zowiCommandWaitTime = 2f;
        //        break;
        //    case 500:
        //        zowiCommandWaitTime = 1f;
        //        break;
        //    default:
        //        zowiCommandWaitTime = 2f;
        //        Debug.Log("Can't get control time");
        //        break;
        //}
    }
Пример #3
0
    // Use this for initialization
    void Start()
    {
        moveBackground = GameObject.Find("MoveBackground");
        switch (PlayerPrefs.GetInt("fontSizeIndex"))
        {
        case 0:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.0f);
            break;

        case 1:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.2f);
            break;

        case 2:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.5f);
            break;
        }
        showMoves.fontSize = PlayerPrefs.GetInt("fontSize");
        tutorialCount      = 0;

        loopState               = false;
        loopsFromSlider         = 2;
        howManyTimesToLoop.text = "Times To Loop : " + loopsFromSlider;
        countLoops              = 0;
        saveStartLocation       = -1;
        countTillLineSkip       = 0;
        growthSwitch            = true;
        shrinkSwitch            = true;

        turned      = false;
        facingRight = true;

        spinOrRoll = false;

        jumpSwitch = true;
        jumpReset  = false;

        startFormat = "<b><color=#00ff00ff>";
        endFormat   = "</color></b>";
        movementLengthCollection = 0;

        buttonChoosen = false;
        buttonCount   = 0;
        playSound(15);
        StartCoroutine(buttonFlash());

        zowiController = GameObject.FindObjectOfType <ZowiController>();
        growText       = GameObject.Find("Grow").GetComponentInChildren <Text>();
        shrinkText     = GameObject.Find("Shrink").GetComponentInChildren <Text>();
        zowiController = GameObject.FindObjectOfType <ZowiController>();
        if (zowiController && zowiController.device.IsConnected)
        {
            zowiController.home();
            growText.text   = "Dance";
            shrinkText.text = "Swing";
        }
        else
        {
            growText.text   = "Grow";
            shrinkText.text = "Shrink";
        }
        transmittingBackground.SetActive(false);
        transmittingToZowi = false;

        //switch (ZowiController.time)
        //{
        //    case 1500:
        //        zowiCommandWaitTime = 3f;
        //        break;
        //    case 1000:
        //        zowiCommandWaitTime = 2f;
        //        break;
        //    case 500:
        //        zowiCommandWaitTime = 1f;
        //        break;
        //    default:
        //        zowiCommandWaitTime = 2f;
        //        Debug.Log("Can't get control time");
        //        break;
        //}
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        moveBackground = GameObject.Find("MoveBackground");
        switch (PlayerPrefs.GetInt("fontSizeIndex"))
        {
        case 0:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.0f);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(504, 145);
            break;

        case 1:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.2f);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(504, 190);
            break;

        case 2:
            moveBackground.transform.localScale = new Vector2(1.0f, 1.5f);
            showMoves.GetComponent <RectTransform>().sizeDelta = new Vector2(504, 210);
            break;
        }
        showMoves.fontSize      = PlayerPrefs.GetInt("fontSize");
        loopState               = false;
        loopsFromSlider         = 2;
        howManyTimesToLoop.text = "Times To Loop : " + loopsFromSlider;
        countLoops              = 0;
        saveStartLocation       = -1;
        countTillLineSkip       = 0;
        growthSwitch            = true;
        shrinkSwitch            = true;

        turned      = false;
        facingRight = true;

        spinOrRoll = false;

        jumpSwitch = true;
        jumpReset  = false;

        startFormat = "<b><color=#00ff00ff>";
        endFormat   = "</color></b>";
        movementLengthCollection = 0;

        buttonCount = 0;
        if (PlayerPrefs.GetInt("Scan") == 1)
        {
            StartCoroutine(scanner());
        }
        GameStatusEventHandler.gameWasStarted("freeplay");

        growText       = GameObject.Find("Grow").GetComponentInChildren <Text>();
        shrinkText     = GameObject.Find("Shrink").GetComponentInChildren <Text>();
        zowiController = GameObject.FindObjectOfType <ZowiController>();
        if (zowiController && zowiController.device.IsConnected)
        {
            zowiController.home();
            growText.text   = "Dance";
            shrinkText.text = "Swing";
        }
        else
        {
            zowiFaceMenuButton.SetActive(false);     //comment out for weekly update
            zowiControlsMenuButton.SetActive(false); //comment out for weekly update
            growText.text   = "Grow";
            shrinkText.text = "Shrink";
        }
        transmittingBackground.SetActive(false);
        transmittingToZowi = false;
    }