void OnTriggerEnter(Collider other) { if (modifiers.dot) { if (other.gameObject.tag.Equals("Enemy")) { HealthControl collidedHealth = other.gameObject.GetComponent <HealthControl>(); collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } }
void enemyCollision(GameObject collidedObject) { if (collidedObject.tag.Equals("Player")) { HealthControl collidedHealth = collidedObject.GetComponent <HealthControl>(); collidedHealth.takeDamage(modifiers.damage); if (modifiers.dot) { collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } }
public override void fire(SpellMod modifiers, Transform firePoint, Camera mainCam) { GameObject temp = Instantiate(projectile, mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)) - mainCam.transform.forward.normalized * 10, firePoint.rotation); RaycastHit[] hits; ISpellCollision spellCollision = temp.GetComponent <ISpellCollision>(); temp.GetComponent <Rigidbody>().velocity = mainCam.transform.forward.normalized * 500; hits = Physics.SphereCastAll(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), 0.5f, mainCam.transform.forward); Debug.DrawRay(mainCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, mainCam.nearClipPlane)), mainCam.transform.forward); if (hits.Length > 0) { hits = raycastSort(hits, firePoint.position); foreach (RaycastHit hit in hits) { if (hit.collider.tag == "Enemy") { HealthControl collidedHealth = hit.collider.GetComponent <HealthControl>(); collidedHealth.takeDamage(modifiers.damage * modifiers.damagePercent); if (modifiers.dot) { collidedHealth.applyDot(modifiers.dotTick, modifiers.dotLength); } } else if (hit.collider.tag == "EnemyAttack") { Destroy(hit.collider.gameObject); } else if (hit.collider.gameObject.layer == 0) { //modifiers.range = (hit.point - temp.transform.position).magnitude / 250; return; } } spellCollision.setModifiers(modifiers); } }