/* Keegan: * This function feels kind of smelly to me. Flagging for refactor */ private void OnTriggerEnter(Collider other) { string spellCasterTag = ""; if (_SpellCaster) { spellCasterTag = _SpellCaster.tag; } if (other.gameObject.CompareTag("AttackRange")) { return; } //if ((other.gameObject.CompareTag("Player") && _SpellCaster.tag != "Player") || other.gameObject.CompareTag("Enemy")) if ((other.gameObject.tag == "Player/Boy" || other.gameObject.tag == "Player/Girl") || other.gameObject.tag == "Enemy") { MessageHandler msgHandler = other.GetComponent <MessageHandler>(); if (isHeal) { // Debug.Log("Bullet: isHeal = true"); RecoverData rcvrData = new RecoverData(); rcvrData.HP_up = Healing; if (msgHandler) { msgHandler.GiveMessage(MessageTypes.HEALED, this.gameObject, rcvrData); DisplayHealing(other.gameObject, _HealColor, Healing); } } if ((spellCasterTag == "Player/Boy" || spellCasterTag == "Player/Girl") && (other.gameObject.tag == "Player/Boy" || other.gameObject.tag == "Player/Girl")) { return; } Debug.Log("I am here after the sheep attack against : " + other.tag + " with SpellCaster of : " + spellCasterTag); if (!isHeal) { DamageData dmgData = new DamageData(); dmgData.damage = Damage; if (msgHandler) { msgHandler.GiveMessage(MessageTypes.DAMAGED, this.gameObject, dmgData); Debug.Log("Bullet check: Other's Tag = " + other.tag); Debug.Log("Bullet Check: Spellcaster's Tag = " + _SpellCaster.tag); DisplayDamage(other.gameObject, _DamageColor, Damage); } } } if (other.gameObject.CompareTag("wall")) { DestroyObject(); } else { return; } }
//Healing the Ghoul private IEnumerator HealGhoul() { MessageHandler msgHandler = this.GetComponent <MessageHandler>(); RecoverData rcvrData = new RecoverData(); rcvrData.HP_up = HealAmount; if (msgHandler) { msgHandler.GiveMessage(MessageTypes.HEALED, this.gameObject, rcvrData); DisplayHealing(this.gameObject, _HealColor, HealAmount); } yield return(new WaitForSeconds(DarknessTimer)); }
void RecieveMessage(MessageTypes msgType, GameObject go, MessageData msgData) { switch (msgType) { case MessageTypes.DAMAGED: DamageData dmgData = msgData as DamageData; if (gameObject.tag == "Player/Boy" || gameObject.tag == "Player/Girl") { if (dmgData != null && !invincibility) { invincibilityTimer = 0; invincibility = true; ApplyDamage(dmgData.damage, go); } } if (gameObject.tag == "Enemy" || gameObject.tag == "Objects") { if (dmgData != null && !invincibility) { ApplyDamage(dmgData.damage, go); } } break; case MessageTypes.AGGROCHANGED: AggroData aggroData = msgData as AggroData; if (go.name == "Boy") { aggroBoy += aggroData.aggro; //Need to establish Aggro for each character on all enemies } else if (go.name == "Girl") { //Debug.Log("here"); aggroGirl += aggroData.aggro; } break; case MessageTypes.HEALED: //for healing character RecoverData recoverData = msgData as RecoverData; if (recoverData != null && !invincibilityHeal) { invincibilityHealTimer = 0; invincibilityHeal = true; //Debug.Log("HealthController: case HEALED"); RecoverHealth(recoverData.HP_up, go); } break; } }