コード例 #1
0
    public void OnTriggerExit2D(Collider2D collider2D)
    {
        if (collider2D.tag == "Danger")
        {
            nearDangerObject = false;
            dangerObject     = null;
        }

        else if ((collider2D.tag == "GemsObject") || (collider2D.tag == "Key") || (collider2D.tag == "Book"))
        {
            if (collider2D.tag == "Key" && key)
            {
                StartCoroutine(WaitAndResetTexts());
            }
            else
            {
                ResetTexts();
                dialogText.GetComponent <DialogTextScript>().paper.SetActive(false);
            }
            nearGemsObject = false;
            activeObject   = null;
        }

        else if (collider2D.tag == "Dealer")
        {
            dealer = null;
        }

        else if (collider2D.tag == "Door")
        {
            coordObject = null;
            ResetTexts();
        }
    }
コード例 #2
0
    public void OnTriggerEnter2D(Collider2D collider2D)
    {
        if (collider2D.tag == "Door")
        {
            coordObject = collider2D.gameObject.GetComponent <Coord_Script>();
        }

        else if (collider2D.tag == "Bullet")
        {
            health -= collider2D.gameObject.GetComponent <DangerObjectScript>().damage;
            Destroy(collider2D.gameObject);
        }
        else if (collider2D.tag == "Danger")
        {
            nearDangerObject = true;
            dangerObject     = collider2D.gameObject.GetComponent <DangerObjectScript>();
        }

        else if ((collider2D.tag == "GemsObject") || (collider2D.tag == "Key") || (collider2D.tag == "Book"))
        {
            activeObject = collider2D.GetComponent <ActiveObject>();
            if (activeObject != null)
            {
                nearGemsObject = true;
            }
        }
        else if (collider2D.tag == "Dealer")
        {
            dealer = collider2D.gameObject.GetComponent <Dealer_Script>();
        }
    }