Esempio n. 1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.GetComponent <PJ_Base>())
        {
            PJ_Base p = col.GetComponent <PJ_Base>();
            if (p.mProjD.rOwner != null)
            {
                if (p.mProjD.rOwner == gameObject)
                {
                    return;
                }
            }

            // If an enemy grenade hit us, just make its velocity stop, and it explodes.
            if (col.GetComponent <PJ_EN_PGrenade>())
            {
                col.GetComponent <PJ_EN_PGrenade>().FEnter_Landed();
                return;
            }
            // Note, will have to change a bit for the needler.
            if (!_invinsible)
            {
                cHpShlds.FTakeDamage(p.mProjD._damage, p.mProjD._DAM_TYPE);
            }
            p.FDeath();
        }

        if (col.GetComponent <EX_Gren>())
        {
            EX_Gren p = col.GetComponent <EX_Gren>();
            if (!_invinsible)
            {
                cHpShlds.FTakeDamage(p._dam, p._DAM_TYPE);
            }
        }

        if (cHpShlds.mHealth.mAmt <= 0f)
        {
            Instantiate(PF_Particles, transform.position, transform.rotation);
            Destroy(gameObject);
            UnityEngine.SceneManagement.SceneManager.LoadScene("SN_MN_Main");
        }
    }
Esempio n. 2
0
    public void OnTriggerEnter2D(Collider2D col)
    {
        if (col.GetComponent <PJ_Base>())
        {
            PJ_Base p = col.GetComponent <PJ_Base>();
            if (p.mProjD.rOwner != null)
            {
                if (p.mProjD.rOwner == gameObject)
                {
                    return;
                }
            }

            // If an enemy grenade hit us, just make its velocity stop, and it explodes.
            if (col.GetComponent <PJ_Gren>())
            {
                Debug.Log("Hit by some grenade");
                col.GetComponent <PJ_Gren>().FHandleHitObj();
                return;
            }

            cHpShlds.FTakeDamage(p.mProjD._damage, p.mProjD._DAM_TYPE);
            FEnemySpecificHandleDamTaken();
            p.FDeath();
        }

        if (col.GetComponent <EX_Gren>() != null)
        {
            Debug.Log("Enemy Inside grenade explosion");
            EX_Gren p = col.GetComponent <EX_Gren>();
            cHpShlds.FTakeDamage(p._dam, p._DAM_TYPE);
            FEnemySpecificHandleDamTaken();
        }

        // At the end of getting potentially hit by things, check if we're dead.
        if (cHpShlds.mHealth.mAmt <= 0f)
        {
            Debug.Log("Dead");
            KillOurselves();
        }
    }