コード例 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        LinkController controller = other.GetComponent <LinkController>();

        if (controller != null && collectible)
        {
            controller.ChangeKeyCount(1);

            Destroy(gameObject);

            controller.PlaySound(collected);
        }
    }
コード例 #2
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        if (state == "locked")
        {
            LinkController controller = other.gameObject.GetComponent <LinkController>();
            Inventory      inventory  = other.gameObject.GetComponent <Inventory>();

            if (controller != null)
            {
                if (inventory.keys > 0)
                {
                    controller.ChangeKeyCount(-1);
                    setState("door");
                    PlaySound(open);
                    if (hasPartner)
                    {
                        partnerController.setState("door");
                    }
                }
            }
        }
    }