Exemple #1
0
    void OnTriggerStay2D(Collider2D col)
    {
        if (col.gameObject.layer.Equals(15)) // Fire layer
        {
            BoxCollider2D     bcFire    = col.gameObject.GetComponent <BoxCollider2D>();
            List <Collider2D> colliders = new List <Collider2D>();
            bcFire.GetContacts(colliders);
            foreach (Collider2D thing in colliders)
            {
                if (thing.gameObject.layer.Equals(16)) // Extinguisher Smoke Layer
                {
                    col.gameObject.GetComponent <FireController>().DescreaseFire(10f);
                }
                else if (thing.gameObject.layer.Equals(9)) // If it's the player
                {
                    // Debug.Log("Here!");
                    DamagePlayer(0.05f);
                }
                // Debug.Log("Object: " + thing.gameObject.name);
            }
        }

        if (col.gameObject.layer.Equals(17)) // Repairable layer
        {
            BreakableController bkc = col.gameObject.GetComponent <BreakableController>();
            // Repair Handler
            if (Input.GetKeyDown(KeyCode.R))
            {
                if (bkc.GetBroken())
                {
                    bkc.Repair();
                    keyR.SetActive(false);
                    isRepairingItem = false;
                }
            }

            if (bkc.isBroken)
            {
                // Show Key
                Vector3 offset = new Vector3(0f, 2f, 0f);
                keyR.transform.position = col.gameObject.transform.position + offset;
                keyR.SetActive(true);
            }
        }
    }
 public void Start()
 {
     Instance = this;
 }