public void Attack() { if (countDown >= coolDown && magTar != null) { float aff; bool boss = false; if (magTar.tag != "Ezekiel") { eEng = magTar.GetComponent <EnemyEngine>(); if (eEng.eWeak == 0) { aff = 75; } else if (eEng.ePower == 0) { aff = 45; } else { aff = 65; } } else { bEng = magTar.GetComponent <Ezekiel>(); boss = true; if (bEng.weak == 0) { aff = 75; } else if (bEng.pow == 0) { aff = 45; } else { aff = 65; } } float hitChance = aff * (magLvl + magAttType) / eDef; float hit = Random.Range(0, 100); if (hit < hitChance) { float maxHit = Mathf.Ceil(0.5f * (magLvl + magAttType)); int magRoll = Mathf.RoundToInt(Random.Range(1, maxHit)); MagicGiveExp(magRoll); PlayerHealth.GiveHealthExp(magRoll); magChild = magTar.GetChild(magAttType + 1); if (boss) { if (bEng.health - magRoll > 0) { StartCoroutine(MagicAnimTimer(magChild)); } else { magChild.parent = null; StartCoroutine(MagicAnimTimer(magChild)); } bEng.health -= magRoll; } else { if (magRoll > eEng.eHealth) { magRoll = Mathf.RoundToInt(eEng.eHealth); } if (eEng.eHealth - magRoll > 0) { StartCoroutine(MagicAnimTimer(magChild)); } else { magChild.parent = null; StartCoroutine(MagicAnimTimer(magChild)); } eEng.eHealth -= magRoll; } DamageController.CreateDamageText(magRoll.ToString(), magTar.transform); Debug.Log("MAG - We hit: " + (magRoll)); } else { Debug.Log("MAG - P:0"); DamageController.CreateDamageText("0", magTar.transform); } if (!boss) { eEng.Aggro = true; } countDown = 0; } }
//Gets called when an enemy is going to be attacked with a strength hit. public void StrAttackEnemy() { if (ePos == null) { return; } bool boss = false; float aff; if (ePos.tag != "Ezekiel") { eEng = ePos.GetComponent <EnemyEngine>(); if (eEng.eWeak == 0) { aff = 75; } else if (eEng.ePower == 0) { aff = 45; } else { aff = 65; } } else { bEng = ePos.GetComponent <Ezekiel>(); boss = true; if (bEng.weak == 0) { aff = 75; } else if (bEng.pow == 0) { aff = 45; } else { aff = 65; } } float hitChance = aff * (strLvl + PlayerEngine.pWeaponLvl * 2) / eDef; float hit = Random.Range(0, 100); if (hit < hitChance) { float maxHit = Mathf.Ceil(0.5f * strLvl + PlayerEngine.pWeaponLvl); int strRoll = Mathf.RoundToInt(Random.Range(1, maxHit)); StrengthGiveExp(strRoll); PlayerHealth.GiveHealthExp(strRoll); DamageController.CreateDamageText(strRoll.ToString(), ePos.transform); if (boss) { bEng.health -= strRoll; } else { if (strRoll > eEng.eHealth) { strRoll = Mathf.RoundToInt(eEng.eHealth); } eEng.eHealth -= strRoll; } Debug.Log("STR - We hit: " + (strRoll)); } else { Debug.Log("STR - P:0"); DamageController.CreateDamageText("0", ePos.transform); } if (!boss) { eEng.Aggro = true; } }