2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.1 KiB
C#

2 years ago
using Entitas;
using UnityEngine;
using Game;
public class AIDirectorSystem : IExecuteSystem, IInitializeSystem
{
private LevelPoolItem _curLevel;
private LevelNodeMonsterWave _curWave;
private float _tickTime;
private float _attackRoundTime;
private float _attackWaitTime;
private int _attackTimes;
public void Initialize()
{
}
public void Execute()
{
if (Util.IsLevelLoading())
{
return;
}
var level = Util.GetCurLevel();
var wave = Util.GetCurWave();
if (level == null || wave == null)
{
return;
}
if (level != _curLevel)
{
_curLevel = level;
return;
}
if (wave != _curWave)
{
_curWave = wave;
Reset();
return;
}
UpdateAIDirectorBlueprint();
}
private void Reset()
{
_attackRoundTime = 0;
_attackWaitTime = 0;
_attackTimes = 0;
}
private void UpdateAIDirectorBlueprint()
{
if (!Util.GetAIDirectorInit())
{
Util.SetAIDirectorInit();
Util.RunBp(GameConst.BlueprintAIDirectorCommon, GameConst.BpEntranceEnter);
}
_tickTime -= Time.deltaTime;
if (_tickTime < 0)
{
_tickTime = GameConst.AIDirectorTick;
Util.RunBp(GameConst.BlueprintAIDirectorCommon, GameConst.BpEntranceUpdate);
}
if (_attackRoundTime < _curWave.attackRound)
{
_attackRoundTime += Time.deltaTime;
return;
}
if (_attackWaitTime < _curWave.attackFrequency)
{
_attackWaitTime += Time.deltaTime;
return;
}
if (_attackTimes >= _curWave.attackTimes)
{
Reset();
return;
}
_attackTimes++;
_attackWaitTime = 0;
Util.RunBp(GameConst.BlueprintAIDirectorCommon, GameConst.BpEntranceExecute);
}
}