using System.Collections.Generic; using System; using UnityEditor; using UnityEngine; using UnityEngine.Events; public class BaseEnemyTurn : MonoBehaviour { public static BaseEnemyTurn basic; public List enemyLoopTurns; public GameObject currentEnemy; public int phase; private void Awake() { if (basic != null && basic != this) { Debug.LogWarning("2 base enemy turn on the scene"); Destroy(this); return; } basic = this; } public void FindLoopTurn(GameObject _enemy, int _phaseAttack) { for(int i = 0; i < enemyLoopTurns.Count; i++) { if(enemyLoopTurns[i].config == _enemy.GetComponent().enemyConfig) { currentEnemy = _enemy; int _phase = _phaseAttack % enemyLoopTurns[i].attackLoop.Count; Debug.Log(_phase + " " + _enemy.name); enemyLoopTurns[i].attackLoop[_phase]?.Invoke(); return; } } Debug.LogError("Loop not found"); } //Возвращает фазу атаки без ее изменения public void FindLoopForLocal(GameObject _enemy, int _phaseAttack) { for (int i = 0; i < enemyLoopTurns.Count; i++) { if (enemyLoopTurns[i].config == _enemy.GetComponent().enemyConfig) { phase = _phaseAttack % enemyLoopTurns[i].attackLoop.Count; return; } } } } [Serializable] public class EnemyLoopTurn { [Tooltip("the config is necessary to find the right chain of actions")] public EnemyConfig config; public List attackLoop = new List(); }