using System.Collections; using System.Collections.Generic; using System; using UnityEngine; using UnityEditor; public class LibraryTurnMethods : MonoBehaviour { private Enemy enemy; public static LibraryTurnMethods main; private void Awake() { enemy = GetComponent(); main = this; } public void Attack() { Player.main.ChangeHp(enemy.enemyConfig.enemyCharacteristics.damage); } public void HealingSelf() { int _selfHealing = enemy.enemyConfig.enemyCharacteristics.selfHealing; enemy.ChangeHp(-_selfHealing); } public void HealingAlly() { int _allyHealing = enemy.enemyConfig.enemyCharacteristics.allyHealing; List _currentEnemies = Session.main.currentEnemies; int _index = 0; int _max = 0; for (int i = 0; i < _currentEnemies.Count; i++) { Enemy _allyScript = _currentEnemies[i].GetComponent(); int _hp = _allyScript.CheckHp(); if (_allyScript.enemyConfig.enemyCharacteristics.maxHp - _hp > _max) { _max = _allyScript.enemyConfig.enemyCharacteristics.maxHp - _hp; _index = i; } } if (_currentEnemies[_index] == null) { return; } _currentEnemies[_index].GetComponent().ChangeHp(-_allyHealing); } public void HealingAll() { int _allHealing = enemy.enemyConfig.enemyCharacteristics.allHealing; List _currentEnemies = Session.main.currentEnemies; for (int i = 0; i < _currentEnemies.Count; i++) { Enemy _allyScript = _currentEnemies[i].GetComponent(); _currentEnemies[i].GetComponent().ChangeHp(-_allHealing); } } public void AddArmorSelf() { int _addArmor = enemy.enemyConfig.enemyCharacteristics.addArmorSelf; enemy.AddArmor(_addArmor); } public void AddArmorAlly() { int _addArmorAlly = enemy.enemyConfig.enemyCharacteristics.addArmorAlly; List _currentEnemies = Session.main.currentEnemies; int _index = 0; int _max = 0; for (int i = 0; i < _currentEnemies.Count; i++) { Enemy _allyScript = _currentEnemies[i].GetComponent(); int _hp = _allyScript.CheckHp(); if (_allyScript.enemyConfig.enemyCharacteristics.maxHp - _hp > _max) { _max = _allyScript.enemyConfig.enemyCharacteristics.maxHp - _hp; _index = i; } } if (_currentEnemies[_index] == null) { return; } _currentEnemies[_index].GetComponent().AddArmor(_addArmorAlly); } public void AddArmorAll() { int _addArmorAll = enemy.enemyConfig.enemyCharacteristics.addArmorAll; List _currentEnemies = Session.main.currentEnemies; for (int i = 0; i < _currentEnemies.Count; i++) { Enemy _allyScript = _currentEnemies[i].GetComponent(); _currentEnemies[i].GetComponent().AddArmor(_addArmorAll); } } public void Poison() { for (int i = 0; i < enemy.enemyConfig.enemyCharacteristics.effects.Length; i++) { if (enemy.enemyConfig.enemyCharacteristics.effects[i].effect.ToString() == "poison") { Effects(i); } } } public void Stun() { for (int i = 0; i < enemy.enemyConfig.enemyCharacteristics.effects.Length; i++) { if (enemy.enemyConfig.enemyCharacteristics.effects[i].effect.ToString() == "stun") { Effects(i); } } } private void Effects(int i) { Player.main.effectsName.Add(enemy.enemyConfig.enemyCharacteristics.effects[i].effect.ToString()); Player.main.effectsDamage.Add(enemy.enemyConfig.enemyCharacteristics.effects[i].damage); Player.main.effectsTurns.Add(enemy.enemyConfig.enemyCharacteristics.effects[i].turns); LibraryEffects.main.InstantiateEffect(enemy.enemyConfig.enemyCharacteristics.effects[i].effect.ToString(), Player.main.gameObject, enemy.enemyConfig.enemyCharacteristics.effects[i].damage, i); } }