public void TakeDamage(AttackData attack) { OnStruck(attack); stats.TakeDamage(attack.effectiveDamage); if (OnHealthChanged != null) { OnHealthChanged(stats.CurrHP, stats.MaxHP); } }
void OnTriggerEnter(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (friendly != enemy.Friendly) { enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } PlayAnim(col); //Debug.Log("Destroy due to hit non friend"); // Destroy(gameObject); } } else { PlayAnim(col); //Debug.Log("Destroy due to hit non stat char " + col.gameObject.name); // Destroy(gameObject); } } }
void OnCollisonStay(Collision col) { if (dmgTimer > 0.5f && !inUse) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (enemy.Friendly) { dmgTimer = 0f; enemy.TakeDamage(collideDmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(collideDmg); } } } } } }
private void OnTriggerEnter(Collider collision) { if (collision.transform.GetComponent <StatBlock>()) { StatBlock target = collision.transform.GetComponent <StatBlock>(); target.TakeDamage(); EndProjectile(); } }
void MeleeAttack() { Damage dmg = new Damage(Random.Range(weaponDmgMin, weaponDmgMax), 0f, true, false, false); dmg = stats.RealDamage(dmg); GameObject remy = GameObject.Find("remy"); StatBlock enemy = remy.GetComponent <StatBlock>(); if (enemy != null) { enemy.TakeDamage(dmg, remy); } }
void OnTriggerEnter(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); IAttackIgnored colProj = col.gameObject.GetComponent <IAttackIgnored>(); if (colProj == null) //check to see if we collided with another projectile. if so ignore { //Debug.Log("Col with non-proj, Proj is: " + friendly); if (enemy != null) { //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly); if (friendly != enemy.Friendly) { float dmgTaken = enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } if (dmg.callback != null) { dmg.callback.Callback(dmgTaken); } if (destroyable) { OnDeath(); PlayAnim(col); Destroy(gameObject); } } } else { if (destroyable) { OnDeath(); PlayAnim(col); Destroy(gameObject); } } } }
void OnTriggerEnter(Collider col) { if (col.gameObject.name.Equals("remy")) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); if (enemy != null) { enemy.TakeDamage(dmg, col.gameObject); } } speed = 0; Vector3 pos = col.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position); if (hit != null) { var hitInstance = Instantiate(hit, pos, Quaternion.identity); if (UseFirePointRotation) { hitInstance.transform.rotation = gameObject.transform.rotation * Quaternion.Euler(0, 180f, 0); } else { hitInstance.transform.LookAt(pos); } var hitPs = hitInstance.GetComponent <ParticleSystem>(); if (hitPs == null) { Destroy(hitInstance, hitPs.main.duration); } else { var hitPsParts = hitInstance.transform.GetChild(0).GetComponent <ParticleSystem>(); Destroy(hitInstance, hitPsParts.main.duration); } } Destroy(gameObject); }
protected override void OnTriggerStay(Collider col) { StatBlock enemy = col.gameObject.GetComponent <StatBlock>(); ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>(); if (enemy != null) { if (friendly != enemy.Friendly) { enemy.TakeDamage(dmg, col.gameObject); if (enemyControl != null) { enemyControl.OnHit(dmg); } Destroy(gameObject); } } else { Destroy(gameObject); } }