//is not fired we need an event to fire this protected override void fire(DamagableEntity target) { GameObject _projectile = Instantiate(projectile,spawnLocation.position,spawnLocation.rotation)as GameObject; TargetedProjectile projectileScript = _projectile.GetComponent<TargetedProjectile>(); projectileScript.target = target; projectileScript.myDamage = attackDmg; }
void Fire() { if (!canFire) { return; } ps.Play(); canFire = false; Invoke("Reload", 1f / fireRate); Ray ray = new Ray(this.transform.position, this.transform.forward); RaycastHit rayCastHit; Physics.Raycast(ray.origin, ray.direction, out rayCastHit, 10f); if (rayCastHit.collider == null) { return; } DamagableEntity target = rayCastHit.collider.gameObject.GetComponent <DamagableEntity>(); if (target == null) { return; } Debug.Log("HIT ENTITY!"); target.TakeDamage(damage); }
public void dealDamage(GameObject reciever) { isHit = true; DamagableEntity rec = reciever.GetComponent <DamagableEntity>(); rec.incomingDmg = attdmg; rec.damage(); }
protected void attackIfEnemy(BaseUnit otherUnit, DamagableEntity otherUnitDamage) { if (!checkTeam (otherUnit))//checks if its not on your team { //attack (otherUnitDamage);//passes it to the attack function attack(otherUnitDamage); } }
//clases underneath this can still impiment attack so be weary public override void attack(DamagableEntity target) { if(canFire) { //print (this +"fired"); fire(target); StartCoroutine(waitOnCooldown()); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Enemy" && type == "sword") { print("enemy"); } if (other.gameObject.tag == "Enemy" && type == "sword" && isSwinging && Time.time - startTime2 > 0.5) { DamagableEntity enemy = other.gameObject.GetComponent <DamagableEntity>(); enemy.incomingDmg = sworddmg; enemy.damage(); print("hit"); startTime2 = Time.time; } }
public abstract void attack(DamagableEntity enemy);
protected abstract void fire(DamagableEntity target);
protected override void fire(DamagableEntity enemy) { enemy.takeDmg(attackDmg);//the meles implimentation of attack }