void OnCollisionEnter(Collision hit)
    {
        DamageGiver dg = hit.collider.GetComponent <DamageGiver> ();

        if (dg)
        {
            Destroy(dg);
        }
    }
示例#2
0
    public void TryTakeDamage(DamageGiver dg)
    {
//		Debug.Log ("dg.rig:" + dg.GetComponent<Rigidbody> ().velocity);
        if (directional)
        {
//			Vector3 dirToDamageGiver = (dg.transform.position - this.transform.position).normalized;
//			Vector3 dirToDamageGiver = dg.GetComponent<Rigidbody>().velocity;
            Vector3 dirToDamageGiver = Camera.main.transform.position - transform.position;
            if (!DirectionValid(dirToDamageGiver))
            {
                return;
            }
        }
        TakeDamage(dg.damageAmount);
        DamageFx(dg);
    }
示例#3
0
 public void DamageFx(DamageGiver dg)
 {
     FX.inst.SmallExplosionDamageEffect(dg.transform.position);
 }