Example #1
0
    void Update()
    {
        if (money.getMoney() <= 0 && clickteller >= 2)
        {
            PlayCrashSound();
            Destroy(GameObject.Find("LevelMetTriggers"));
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                GameObject clickedObject = hit.collider.transform.gameObject;
                if (clickedObject.GetComponent <S_GlitchFruit>() != null)
                {
                    Debug.Log("clicked glitchable object");
                    var script = clickedObject.GetComponent <S_GlitchFruit>();

                    //money.spendMoney (5); gebeurt in het glitchscript

                    ////////
                    clickteller++;

                    if (script.glitching)
                    {
                        script.StopGlitching();
                        var script2 = clickedObject.GetComponent <S_WireframeGlitch>();
                        script2.StopGlitching();

                        PlayGlitchFixSound();
                        money.spendMoney(3);
                    }

                    /*int random = Random.Range(0, 9);
                     *
                     * //money.spendMoney(++random);
                     *
                     * if (random >= 8) Destroy(clickedObject);
                     * else
                     * {
                     *  var script = clickedObject.GetComponent<S_GlitchFruit>();
                     *  script.StopGlitching();
                     *  var script3 = clickedObject.GetComponent<S_WireframeGlitch>();
                     *  script3.StopGlitching();
                     *
                     *  GetComponent<AudioSource>().Play();
                     * }*/
                }
            }
        }
    }
 public void TakeMoneyAway()
 {
     moneyScript.spendMoney(1);
 }