コード例 #1
0
ファイル: DD_SpikeTrap.cs プロジェクト: DDriggs00/Team-Faucet
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.tag == "Player")
     {
         LH_Health playerHP = collision.gameObject.GetComponent <LH_Health>();
         playerHP.doDamage(mDamage);
         // Debug.Log("Player damaged");
     }
 }
コード例 #2
0
ファイル: Enemy.cs プロジェクト: DDriggs00/Team-Faucet
    //Upon colliding the Player, respond by dealing damage to the Player and dying
    //This functions as a very basic fighting mechanic
    private void OnTriggerEnter2D(Collider2D collision)
    {
        uint damage = (uint)(int)mPlayerDamage;

        if (collision.tag == "Player")
        {
            LH_Health playerHP = collision.gameObject.GetComponent <LH_Health> ();
            FindObjectOfType <ZG_AudioManager>().playDynamicSound("enemyTakeDamage1");
            playerHP.doDamage(damage);
            Destroy(gameObject);
        }
    }