public void OnTriggerStay2D(Collider2D collision) { if (fire_timer > 5.0f && spread_fire) { if (collision.GetComponent <ItemSurface>()) { ItemSurface surface = collision.GetComponent <ItemSurface>(); if (surface.fire == null) { GameObject new_fire = Instantiate(fire_prefab, collision.transform.position, collision.transform.rotation) as GameObject; new_fire.name = "Fire"; new_fire.transform.parent = surface.transform; new_fire.GetComponent <FireScript>().fire_timer = 0.0f; surface.fire = new_fire; } } } if (fire_timer > 5.1f) { spread_fire = false; } }
public void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.GetComponent <ItemSurface>()) { colliding = true; } if (player.action == true && current_cooldown <= 0.0f) { current_cooldown = pickup_cooldown; if (collision.gameObject.GetComponent <ItemSurface>()) { ItemSurface surface = collision.gameObject.GetComponent <ItemSurface>(); if (surface.fire == null) { if (surface.current_item == null && pickup_object != null) { //if you want to place down an item to an empty surface if (surface.AddItem(pickup_object)) { pickup_object = null; audio.clip = player.drop; audio.Play(); } } else { if (pickup_object) { if (!pickup_object.GetComponent <FireExstinguisher>()) { if (surface.Interact(pickup_object)) { //if interact returns true you take the item instead of interacting with it pickup_object = surface.current_item; surface.current_item = null; audio.clip = player.pickup; audio.Play(); } } } else { if (surface.Interact(pickup_object)) { //if interact returns true you take the item instead of interacting with it pickup_object = surface.current_item; surface.current_item = null; audio.clip = player.pickup; audio.Play(); } } } } } else { Debug.Log(collision.gameObject.name); } } }