using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class BattleWin : UIBase
|
{
|
// 组件引用
|
public Transform mountPoint;
|
[SerializeField] Button fightBtn;
|
|
private BattleRootNode battleRootNode = null;
|
|
public Button btnStop;
|
|
private BattleField battleField;
|
|
float lastClickTime;
|
bool needGuide = false;
|
// 生命周期
|
protected override void InitComponent()
|
{
|
base.InitComponent();
|
// 初始化组件引用 绑定按钮等UI组件事件
|
|
btnStop.AddListener(PauseGame);
|
|
fightBtn.AddListener(()=>
|
{
|
UIManager.Instance.GetUI<MainWin>()?.ClickFunc(0);
|
});
|
}
|
|
private void PauseGame()
|
{
|
// BattleDebug.LogError("PauseeGame");
|
if (null == battleField)
|
return;
|
|
battleField.IsPause = !battleField.IsPause;
|
|
BattleDebug.LogError(" is pause " + battleField.IsPause.ToString());
|
|
// if (battleField != null)
|
// {
|
// battleField.operationAgent.DoNext();
|
// }
|
}
|
|
protected override void OnPreOpen()
|
{
|
lastClickTime = Time.realtimeSinceStartup;
|
needGuide = !MainLevelManager.Instance.IsPassedByMainLevelID(BattleManager.Instance.fightGuideMainLevelLimit);
|
|
// SetBattleField(BattleManager.Instance.storyBattleField);
|
BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField;
|
}
|
|
protected override void OnPreClose()
|
{
|
UIManager.Instance.CloseWindow<BattleHUDWin>();
|
BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField;
|
}
|
|
private void OnCreateBattleField(string arg1, BattleField field)
|
{
|
if (field.GetType() == battleField.GetType())
|
{
|
SetBattleField(field);
|
}
|
}
|
|
protected override void OnOpen()
|
{
|
base.OnOpen();
|
}
|
|
protected override void OnClose()
|
{
|
base.OnClose();
|
|
if (battleRootNode != null)
|
{
|
battleRootNode.transform.SetParent(Launch.Instance.transform);
|
battleRootNode.transform.localPosition = new Vector3(-10000, -10000, 0);
|
}
|
|
battleField = null;
|
}
|
|
protected override void NextFrameAfterOpen()
|
{
|
base.NextFrameAfterOpen();
|
}
|
|
protected override void CompleteClose()
|
{
|
base.CompleteClose();
|
}
|
|
public void SetBattleField(BattleField _battleField)
|
{
|
battleField = _battleField;
|
if (battleRootNode != null)
|
{
|
battleRootNode.transform.localPosition = Vector3.zero;
|
battleRootNode.transform.SetParent(Launch.Instance.transform);
|
}
|
|
battleRootNode = battleField.battleRootNode;
|
|
battleRootNode.transform.SetParent(mountPoint);
|
battleRootNode.transform.localPosition = Vector3.zero;
|
battleRootNode.transform.localScale = Vector3.one;
|
|
BattleHUDWin ui = UIManager.Instance.GetUI<BattleHUDWin>();
|
|
if (null == ui)
|
{
|
ui = UIManager.Instance.OpenWindow<BattleHUDWin>();
|
}
|
|
ui.SetBattleField(battleField);
|
battleField.UpdateCanvas(canvas);
|
}
|
|
|
|
// 新手期 玩家未做任何操作下,在主线战斗中提醒点击战锤
|
void LateUpdate()
|
{
|
if (!needGuide)
|
return;
|
|
if (Input.GetMouseButtonDown(0))
|
{
|
lastClickTime = Time.realtimeSinceStartup;
|
}
|
|
|
if (Time.realtimeSinceStartup - lastClickTime > BattleManager.Instance.fightGuideNoClickSeconds)
|
{
|
if (AutoFightModel.Instance.isAutoAttack)
|
{
|
return;
|
}
|
|
if (NewBieCenter.Instance.inGuiding)
|
{
|
return;
|
}
|
|
if (UIManager.Instance.ExistAnyFullScreenOrMaskWin(""))
|
{
|
return;
|
}
|
|
NewBieCenter.Instance.StartNewBieGuide(BattleManager.Instance.fightGuideID);
|
needGuide = !MainLevelManager.Instance.IsPassedByMainLevelID(BattleManager.Instance.fightGuideMainLevelLimit);
|
BattleManager.Instance.storyBattleField.IsPause = false;
|
lastClickTime = Time.realtimeSinceStartup;
|
}
|
}
|
}
|