Example #1
0
    // Update is called once per frame
    void Update()
    {
        if ((PlayerPrefs.GetInt("Blinking") == 0) && (PlayerPrefs.GetInt("BtnClr") == btnValue))
        {
            StopAllCoroutines();
            StartCoroutine("Blink");
            PlayerPrefs.SetInt("Blinking", 1);
        }

        if (Input.touchCount == 1)
        {
            Vector3 wp       = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
            Vector2 touchPos = new Vector2(wp.x, wp.y);
            if (GetComponent <BoxCollider2D>() == Physics2D.OverlapPoint(touchPos))
            {
                if (!statusChanged)
                {
                    Debug.Log("TOUCH!");
                    tone.Play();
                    BlinkOn();
                    PlayerPrefs.SetInt("Timer", 1);
                    Debug.Log("CLICK!!!" + btnValue);
                    PlayerPrefs.SetInt("BtnVl", btnValue);
                    mainS.GetSequence();
                    statusChanged = true;
                }
            }
        }
        if (Input.touchCount == 0)
        {
            BlinkOff();
            statusChanged = false;
        }
    }