PO/Assets/Scripts/Enemy/BaseEnemyTurn.cs

66 lines
1.7 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
public class BaseEnemyTurn : MonoBehaviour
{
public static BaseEnemyTurn basic;
public List<EnemyLoopTurn> enemyLoopTurns;
public GameObject currentEnemy;
2022-01-15 00:55:46 +03:00
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<Enemy>().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");
}
2022-01-15 00:55:46 +03:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void FindLoopForLocal(GameObject _enemy, int _phaseAttack)
{
for (int i = 0; i < enemyLoopTurns.Count; i++)
{
if (enemyLoopTurns[i].config == _enemy.GetComponent<Enemy>().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<UnityEvent> attackLoop = new List<UnityEvent>();
}