public virtual void OnTriggerEnter2D(Collider2D collision) { /*if (collisionTag != "" && collisionTag != null) * {*/ foreach (string collisionTag in collisionTags) { if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger) { // print(collision.name); GenericHealth temp = collision.GetComponent <GenericHealth>(); if (temp) { //print(temp.currentHealth); if (statistics == null || !(statistics is Atacking)) { temp.Damage(damage); //print(damage); } else { Atacking atacking = (Atacking)statistics; temp.Damage(atacking.GetAttack()); //print(atacking.GetAttack()); } //print(damage); //print(temp.currentHealth); } } } }
//public Resorce res; public override void OnTriggerEnter2D(Collider2D collision) { foreach (string collisionTag in collisionTags) { if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger) { GenericHealth temp = collision.GetComponent <GenericHealth>(); if (temp) { //print(temp.currentHealth); switch (collisionTag) { case "Stone": if (statistics == null || !(statistics is PlayerStatistics)) { temp.Damage(damage); gui.ModifyStone(1); //print(damage); } else { PlayerStatistics player = (PlayerStatistics)statistics; temp.Damage(player.stoneDamage.Value); gui.ModifyStone((int)player.stoneGetting.Value); // print(player.stoneDamage.Value); } break; case "Tree": if (statistics == null || !(statistics is PlayerStatistics)) { temp.Damage(damage); gui.ModifyWood(1); //print(damage); } else { PlayerStatistics player = (PlayerStatistics)statistics; temp.Damage(player.woodDamage.Value); gui.ModifyWood((int)player.woodGetting.Value); // print(player.woodDamage.Value); } break; default: break; } } } } }
public void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(otherTag) && other.isTrigger) { GenericHealth temp = other.GetComponent <GenericHealth>(); if (temp) { temp.Damage(damage); } } }
public void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(_otherTag) && other.isTrigger) { GenericHealth component = other.GetComponent <GenericHealth>(); if (component) { component.Damage(_damage); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag(otherTag) && collision.isTrigger) { GenericHealth temp = collision.gameObject.GetComponent <GenericHealth>(); if (temp) { temp.Damage(damage); } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(otherString)) { //Check if there is health GenericHealth temp = other.gameObject.GetComponent <GenericHealth>(); if (temp) { temp.Damage(damage); } Destroy(this.gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag(otherString)) { // First check to see if there is health GenericHealth temp = other.gameObject.GetComponent <GenericHealth>(); if (temp) { temp.Damage(damage); } this.transform.gameObject.SetActive(false); //this.transform.parent.gameObject.SetActive(false); // Destroy(this.gameObject); } }
public override void OnTriggerEnter2D(Collider2D collision) { base.OnTriggerEnter2D(collision); foreach (string collisionTag in collisionTags) { if (collision.gameObject.CompareTag(collisionTag) && collision.isTrigger) { DeathEffect(); ghoustBasic.thisLoot = null; // Destroy(this.transform.parent.gameObject); this.GetComponent <KnockBack>().OnTriggerEnter2D(collision); //this.GetComponentInParent<Light2D>(). genericHealth.Damage(genericHealth.currentHealth); //print() } } }
public override void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag != "Untagged") { if (other.gameObject.CompareTag(otherTag) && other.isTrigger) { GenericHealth temp = other.GetComponent <GenericHealth>(); if (temp) { bool isCritical = false; if (tech.category == TechCategory.Physical) { float powerTemp = powerValue(tech, tech.power); // Debug.Log(tech.power + " : " + powerTemp); DamageCalc(thisMonster.GetComponent <MonsterStats>().currentLevel.RuntimeValue, tech.techType, powerTemp, thisMonster.GetComponentInParent <MonsterStats>().AttackStat, other.GetComponentInParent <MonsterStats>().DefenceStat); float multiplier = moveEffectiveness(tech, other); float final = multiplier * damage; final = Random.Range(final * 0.9f, final * 1.1f); temp.Damage((int)final); //Debug.Log("Damage: " + (int)final); DamagePopup.Create(other.transform.position, (int)final, isCritical); } else if (tech.category == TechCategory.Magical) { float powerTemp = powerValue(tech, tech.power); // Debug.Log(tech.power + " : " + powerTemp); DamageCalc(thisMonster.GetComponent <MonsterStats>().currentLevel.RuntimeValue, tech.techType, powerTemp, thisMonster.GetComponentInParent <MonsterStats>().MagicStat, other.GetComponentInParent <MonsterStats>().WillpowerStat); float multiplier = moveEffectiveness(tech, other); float final = multiplier * damage; final = Random.Range(final * 0.9f, final * 1.1f); temp.Damage((int)final); // Debug.Log("Damage: " + (int)final); DamagePopup.Create(other.transform.position, (int)final, isCritical); } float powerValue(GenericTech tech, float power) { if (tech.techType != MonsterType.Neutral) { if (tech.techType == thisMonster.GetComponent <MonsterStats>().thisMonster.type1 || tech.techType == thisMonster.GetComponent <MonsterStats>().thisMonster.type2) { power = power * 1.5f; } } return(power); } float moveEffectiveness(GenericTech tech, Collider2D otherMon) { float result = MonsterData.TypeEffectiveness[tech.techType.ToString()] [other.GetComponentInParent <MonsterStats>().thisMonster.type1.ToString()]; if (other.GetComponentInParent <MonsterStats>().thisMonster.type2.ToString() != "Neutral") { result *= MonsterData.TypeEffectiveness[tech.techType.ToString()] [other.GetComponentInParent <MonsterStats>().thisMonster.type2.ToString()]; } return(result); } } } } }