// Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (IsDistanceBetweenTwoVectorInsideDistance(Camera.main.ScreenToWorldPoint(Input.mousePosition), this.transform.position))
            {
                //audioSource = gameObject.GetComponents<AudioSource> ();
                //audioSource [0].Play ();
                Destroy(gameObject);
                this.audioSource = GameObject.Find("GameManagement").GetComponents <AudioSource> ();
                this.audioSource[0].Play();

                GameManagementSingleton singleton = GameManagementSingleton.Instance;
                singleton.IncreaseCoinPoint(10);
            }
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        //以下、点数表示
        GameManagementSingleton singleton = GameManagementSingleton.Instance;

        PointText.GetComponent <Text> ().text = "Point:" + singleton.GetCoinPoint();
        singleton.CurrentTime += Time.deltaTime;
        CurrentTimeText.GetComponent <Text> ().text = "Time:" + (int)singleton.CurrentTime;
        MaxPointText.GetComponent <Text> ().text    = "MaxPoint:" + singleton.MaxCoinPoint;

        if ((int)singleton.CurrentTime == 300)
        {
            SceneManager.LoadScene("EndGame");
        }


        this.AnimalSpouningCount++;
        if (this.AnimalSpouningCount >= this.MaxAnimalSpouningCount)
        {
            this.SpounAnimalRandamUpdate();
            this.AnimalSpouningCount = 0;
        }
        this.BombSouningCount++;
        if (this.BombSouningCount >= this.MaxBombSpouningCount)
        {
            this.SpounBombRandomUpdate();
            this.BombSouningCount = 0;
        }



        if (Input.GetMouseButtonDown(0))
        {
            var tapPoint    = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            var collition2d = Physics2D.OverlapPoint(tapPoint);
            if (collition2d)
            {
                var hitObject = Physics2D.Raycast(tapPoint, -Vector2.up);
                if (hitObject)
                {
                    Debug.Log("hit object is " + hitObject.collider.gameObject.name);
                    string kind = this.CheckGameObjectAnimalOrBomb(hitObject.collider.gameObject);
                    if (kind == "Animal")
                    {
                        audioSource = gameObject.GetComponents <AudioSource> ();
                        audioSource [0].Play();
                        GenerateCoin(hitObject.collider.gameObject.transform.position);
                        GenerateCoin(hitObject.collider.gameObject.transform.position);
                        GenerateCoin(hitObject.collider.gameObject.transform.position);
                        GenerateCoin(hitObject.collider.gameObject.transform.position);
                        GenerateCoin(hitObject.collider.gameObject.transform.position);
                        singleton = GameManagementSingleton.Instance;
                        singleton.IncreaseCoinPoint(10);
                    }
                    else if (kind == "Bombs")
                    {
                        audioSource = gameObject.GetComponents <AudioSource> ();
                        audioSource [1].Play();
                        singleton = GameManagementSingleton.Instance;
                        singleton.SetCoinPoint(0);
                    }
                    else if (kind == "coin")
                    {
                        audioSource = gameObject.GetComponents <AudioSource> ();
                        audioSource [0].Play();
                    }


                    Destroy(hitObject.collider.gameObject);
                }
            }
        }
    }