Пример #1
0
    void OnTriggerEnter2D(Collider2D c)
    {
        Lightable l = c.gameObject.GetComponent <Lightable>();

        if (l)
        {
            lightables.Add(l);
            if (lightOn)
            {
                l.Light(this);
            }
        }
    }
Пример #2
0
    void Light()
    {
        isLightOn = true;
        lightEffect.SetActive(true);
        int layerMask = 1 << LayerMask.NameToLayer("Interactable");

        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, lightAOE, layerMask);
        Instantiate(lightAnimation, transform.position, Quaternion.identity, transform);
        foreach (Collider2D col in colliders)
        {
            Lightable l = col.GetComponent <Lightable>();
            if (l)
            {
                l.Light();
            }
        }
    }