// Update is called once per frame
    void Update()
    {
        //if (!TimesUp)
        //{
        //    timer -= Time.deltaTime;
        //}
        //else
        //{
        //    Debug.Log("Times Up");

        //    mario.Die();
        //}

        if (Input.GetKeyDown(KeyCode.T))
        {
            GameObject[] gos = FindObjectsOfType <GameObject>();

            for (int i = 0; i < gos.Length; i++)
            {
                IHealth health = gos[i].GetComponent <IHealth>();
                if (health != null)
                {
                    health.Die();
                }
            }
        }
    }
Exemplo n.º 2
0
    ///<summary>
    /// Deal damage.
    ///</summary>
    ///<returns>
    /// True if target dies, otherwise false.
    ///</returns>
    public bool Loss(int value)
    {
        bool retVal = false;

        current.val -= value;
        if (current.val < 0)
        {
            retVal      = true;
            current.val = 0;
            IHealth iHealth = GetComponent <IHealth> ();
            if (iHealth != null)
            {
                iHealth.Die();
            }
            else
            {
                Debug.Log("NULL IHealth");
            }
        }
        return(retVal);
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collided)
    {
        if (collided.gameObject.tag == "Player")
        {
            IHealth healthC = collided.gameObject.transform.root.GetComponent <IHealth>();
            switch (typeOfKillbox)
            {
            case KillType.InstantKill:
                healthC.Die();
                break;

            case KillType.DamageOverTime:
                if (!entityHealthTimer.ContainsKey(healthC))
                {
                    healthC.TakeDamage(damageTickValue);
                    entityHealthTimer.Add(healthC, damageTickTime);
                }
                break;
            }
        }
    }