예제 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name.Equals("FloorShortBarrierTransparent") || collision.name.Equals("FloorLongBarrierTransparent"))
        {
            PublicSettingsManagerScript.Score      += 1;
            PublicSettingsManagerScript.ScoreString = "Score: " + PublicSettingsManagerScript.Score.ToString();
            PublicSettingsManagerScript.CheckLevel();
        }

        if (collision.gameObject.transform.parent)
        {
            Destroy(collision.gameObject.transform.parent.gameObject);
        }
        else
        {
            Destroy(collision.gameObject);
        }
    }
예제 #2
0
    public void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name.Equals("FloorShortBarrierTransparent") || collision.name.Equals("FloorLongBarrierTransparent"))
        {
            //game over!!!
            Instantiate(explosion, transform.position, transform.rotation);
            if (PublicSettingsManagerScript.settingsModel != null)
            {
                PublicSettingsManagerScript.settingsModel.Exploded = true;
            }
            Destroy(this.gameObject);
        }
        else if (collision.name.Equals("Coin64by64Transparent"))
        {
            GameObject selfGameObject = GameObject.FindGameObjectWithTag("Coin");
            if (selfGameObject != null)
            {
                SpriteRenderer render = selfGameObject.GetComponent <SpriteRenderer>();
                render.enabled = false;

                float height    = Camera.main.orthographicSize * 2;
                float minWidth  = Camera.main.orthographicSize * -1;
                float maxWidth  = Camera.main.orthographicSize;
                float minheight = height * Camera.main.aspect * -1;
                float maxHeight = height * Camera.main.aspect;

                float x = UnityEngine.Random.Range((float)minWidth + (float)0.64, (float)maxWidth - (float)0.64);
                float y = UnityEngine.Random.Range((float)minheight + (float)0.64, (float)maxHeight - (float)0.64);

                selfGameObject.transform.SetPositionAndRotation(new Vector3(x, y, 0), Quaternion.identity);
                render.enabled = true;
                CoinDisappearScript.UpdateStartTime();

                PublicSettingsManagerScript.Score      += 2;
                PublicSettingsManagerScript.ScoreString = "Score: " + PublicSettingsManagerScript.Score.ToString();
                PublicSettingsManagerScript.CheckLevel();
            }
        }
    }