using UnityEngine;
|
|
|
public class AutoModeOperationAgent : IOperationAgent
|
{
|
protected StoryBattleField storyBattleField;
|
public AutoModeOperationAgent(BattleField battleField) : base(battleField)
|
{
|
storyBattleField = battleField as StoryBattleField;
|
}
|
|
float lastTime;
|
public override void Run()
|
{
|
if (Time.time - lastTime < 0.3f)
|
return;
|
lastTime = Time.time;
|
|
if (AutoFightModel.Instance.isPause)
|
return;
|
|
|
// 自动挑战boss
|
if (AutoChallengeBoss())
|
{
|
return;
|
}
|
DoNext();
|
}
|
|
public override void DoNext()
|
{
|
storyBattleField.RequestFight();
|
}
|
|
void FightBoss()
|
{
|
BattleManager.Instance.SendTurnFight(2);
|
BattleManager.Instance.storyBattleField.CleanBattle();
|
AutoFightModel.Instance.isPause = true;
|
}
|
|
bool AutoChallengeBoss()
|
{
|
// 自动挑战boss
|
if (AutoFightModel.Instance.isAutoChallengeBoss)
|
{
|
if (AutoFightModel.Instance.nowChallengeCount == -1)
|
{
|
return false;
|
}
|
if (!MainLevelManager.Instance.CanChallengeBoss())
|
{
|
return false;
|
}
|
//上次挑战boss失败了,再次尝试要等CD
|
if (Time.time - AutoFightModel.Instance.lastChallengeTime < AutoFightModel.Instance.maxTryChallengeCD)
|
{
|
return false;
|
}
|
|
if (!UIManager.Instance.IsOpened<HomeWin>())
|
{
|
return false;
|
}
|
|
if (NewBieCenter.Instance.inGuiding)
|
{
|
return false;
|
}
|
|
if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(""))
|
{
|
return false;
|
}
|
FightBoss();
|
return true;
|
}
|
return false;
|
}
|
|
|
}
|