public void onHitTarget(Vector3 targetPos, Vector3 normal, GameObject go) { Damagable dam = go.GetComponent <Damagable>(); if (dam) { dam.damage(damagePerHit, targetPos, damagableType, knockBackForce); } Rigidbody rb = go.GetComponent <Rigidbody>(); if (rb) { Vector3 vec = targetPos - transform.position; // - targetPos; rb.AddForce(vec.normalized * rigidBodyForce); } if (hitEffectGO) { GameObject ngo = (GameObject)Instantiate(hitEffectGO, targetPos + normal * .1f, Quaternion.FromToRotation(Vector3.up, normal)); if (ngo && go) { ngo.transform.parent = go.transform; } } }
public virtual void handleAttack() { if (explodeOnAttack) { CameraShake cs = (CameraShake)GameObject.FindObjectOfType(typeof(CameraShake)); if (cs) { cs.shake(); } m_damagable.killSelf(); } if (m_animator) { m_animator.SetBool("Attack", true); } if (m_agent && m_agent.isOnNavMesh) { m_agent.Stop(); } Damagable dam = m_target.GetComponent <Damagable>(); if (dam) { dam.damage(attackDamage, Damagable.DamagableType.MELEE); } m_attackTime = attackTime; }
public void onHitTarget(Damagable dam) { dam.damage(damagePerHit, transform.position, damagableType); if (explodeOnContact) { removeMe(); } }
public static void damageArea(Vector3 pos, float aoe, float dmg, int layer, int value, Damagable.DamagableType damagableType) { Collider[] col = Physics.OverlapSphere(pos, aoe, value); for (int i = 0; i < col.Length; i++) { Damagable dam = col[i].GetComponent <Damagable>(); if (dam && col[i].gameObject.layer != layer) { dam.damage(dmg, dam.transform.position, damagableType); } } }