private void OnTriggerEnter(Collider other) { Debug.Log("Sword Hit!\nDamage: " + damage + ". slowAmount: " + slowAmount + ". duration: " + duration + ". element: " + element + ".\nTag: " + other.tag); if (other.CompareTag("Player")) { BuffHandler playerBuffHandler = other.GetComponent <BuffHandler>(); StatHandler statHandler = other.GetComponent <StatHandler>(); Buff debuff; switch (element) { case ElementEnum.fire: debuff = new Burn(statHandler, new Stat(duration), damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.ice: debuff = new Slow(statHandler, new Stat(duration), new ScalingStatModificator(slowAmount)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.lightning: debuff = new Stun(statHandler, new Stat(duration)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; } } }
void OnTriggerEnter(Collider other) { /* Debug.Log("Hit" + other.gameObject.name); * if (other.gameObject.layer != LayerMask.NameToLayer("Player")) * { * other.gameObject.GetComponent<Rigidbody>().AddForce((other.transform.position - transform.position).normalized * SwordForceMultiplier); * }*/ // Damage if enemy if (other.gameObject.layer == LayerMask.NameToLayer("Enemy")) { other.gameObject.transform.position += (other.gameObject.transform.position - transform.parent.position).normalized * SwordForceEnemyMultiplier; StatHandler sh = other.gameObject.GetComponent <StatHandler>(); if (sh != null) { sh.TakeDamage(damage); } else { // Debug.Log("F"); } // Debug.Log("Damage" + other.gameObject.name); } }
private void OnCollisionEnter(Collision collision) { Physics.IgnoreLayerCollision(12, 8); GameObject other = collision.gameObject; if (other != null) { if (other.CompareTag("Player")) { BuffHandler playerBuffHandler = other.GetComponent <BuffHandler>(); StatHandler statHandler = other.GetComponent <StatHandler>(); Buff debuff; switch (element) { case ElementEnum.fire: debuff = new Burn(statHandler, new Stat(duration), damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.ice: debuff = new Slow(statHandler, new Stat(duration), new ScalingStatModificator(slowAmount)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.lightning: debuff = new Stun(statHandler, new Stat(duration)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; } Destroy(gameObject); } Destroy(gameObject); } else if (other.gameObject.CompareTag("Untagged")) { // Debug.Log("Projectile collide with ELSE: " + other.gameObject.name); Destroy(gameObject); } else { // Debug.Log("Projectile collide with: " + other.gameObject.name); } }
private void TestUnitHasHealth() { StatHandler health = GetComponent <StatHandler>(); if (health == null) { return; } health.TakeDamage(10); }
private void OnTriggerEnter(Collider other) { //Debug.Log("Enter"); StatHandler otherStats = other.GetComponent <StatHandler>(); if (otherStats) { otherStats.TakeDamage(10f); Debug.Log(otherStats.Health); } }
void OnCollisionEnter(Collision other) { Debug.Log("Something fell out of the map"); if (other.gameObject.CompareTag("Player")) { StatHandler statHandler = other.gameObject.GetComponent <StatHandler>(); statHandler.TakeDamage(9999); } else { GameObject.Destroy(other.gameObject); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { BuffHandler playerBuffHandler = other.GetComponent <BuffHandler>(); StatHandler statHandler = other.GetComponent <StatHandler>(); Buff debuff; switch (element) { case ElementEnum.fire: debuff = new Burn(statHandler, new Stat(duration), damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.ice: debuff = new Slow(statHandler, new Stat(duration), new ScalingStatModificator(slowAmount)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; case ElementEnum.lightning: debuff = new Stun(statHandler, new Stat(duration)); statHandler.TakeDamage(damage); playerBuffHandler.AddBuff(debuff); break; } } else if (other.CompareTag("Projectile")) { Debug.Log("SHIELD ENTER PROJECTILE: " + other.gameObject.transform); Destroy(other.gameObject); } }