//applies damage to target based on character stats + power used public void Apply(Character obj, Character target) { if (obj.Mp - manaCost >= 0) { float rand = Random.Range(1, 100); float MissRange = 10 + target.GetComponent <Character>().Agi - obj.GetComponent <Character>().Dex; float IncomingDmg = 0; //if the random number from 1-100 is less than the miss range, the attack hits if (rand >= MissRange) { IncomingDmg = CalculateDamage(obj, target); //loops over current effects on this power, applies them to the target for (int i = 0; i < currentEffects.Count; i++) { currentEffects[i].Apply(target, duration); } } //plays miss text if attack misses else if (rand < MissRange) { GetScreenLoc tempLoc = new GetScreenLoc(); Vector2 location = tempLoc.getScreenPos(target.transform); FloatingTextController.CreateMissText(("Miss!").ToString(), location); } //plays damage ammount animations if damage is delt if (IncomingDmg != 0) { Debug.Log("Applying Damage"); GetScreenLoc tempLoc = new GetScreenLoc(); Vector2 location = tempLoc.getScreenPos(target.transform); if (target.tag == "Enemy") { FloatingTextController.CreateDamageEnemyText((IncomingDmg).ToString(), location); } else if (target.tag == "Player") { FloatingTextController.CreateDamageAllyText((IncomingDmg).ToString(), location); } } target.Hp -= IncomingDmg; obj.Mp -= manaCost; } }
void SetStats(Character target) { //RPGStats.Stats tmp = 0; switch (StatusEffects.effect) { case StatusEffectType.Buff: { //target.Str += StatusEffects.amount; RPGStats.Stats tmp = FindStatModified(StatusEffects.statBuff, target); target.CharaStats[tmp] += StatusEffects.amount; break; } case StatusEffectType.Debuff: { RPGStats.Stats tmp = FindStatModified(StatusEffects.statBuff, target); target.CharaStats[tmp] -= StatusEffects.amount; break; } case StatusEffectType.Heal: { //caps HP to the max so you can't overheal target.Hp += StatusEffects.amount; if (target.Hp > target.hpStat) { target.Hp = target.hpStat; } //HACK check if in battle so it doesn't try making effect when using potion in inventory if (GameController.Instance.state == GameController.EGameStates.Battle) { GetScreenLoc tempLoc = new GetScreenLoc(); Vector2 location = tempLoc.getScreenPos(target.transform); if (target.tag == "Enemy") { FloatingTextController.CreateHealEnemyText((StatusEffects.amount).ToString(), location); } else if (target.tag == "Player") { FloatingTextController.CreateHealAllyText((StatusEffects.amount).ToString(), location); } } break; } case StatusEffectType.ManaHeal: { target.Mp += StatusEffects.amount; if (target.Mp > target.mpStat) { target.Mp = target.mpStat; } //HACK check if in battle so it doesn't try making effect when using potion in inventory if (GameController.Instance.state == GameController.EGameStates.Battle) { GetScreenLoc tempLoc = new GetScreenLoc(); Vector2 location = tempLoc.getScreenPos(target.transform); if (target.tag == "Enemy") { FloatingTextController.CreateHealEnemyText((StatusEffects.amount).ToString(), location); } else if (target.tag == "Player") { FloatingTextController.CreateHealAllyText((StatusEffects.amount).ToString(), location); } } break; } default: Debug.Log("error"); break; } }