using System; 
 | 
using UnityEngine; 
 | 
using UnityEngine.UI; 
 | 
  
 | 
public class BattleWin : UIBase 
 | 
{ 
 | 
    // 组件引用 
 | 
    public Transform mountPoint; 
 | 
  
 | 
    private BattleRootNode battleRootNode = null; 
 | 
  
 | 
    public Button btnStop; 
 | 
  
 | 
    private BattleField battleField; 
 | 
  
 | 
    // 生命周期 
 | 
    protected override void InitComponent() 
 | 
    { 
 | 
        base.InitComponent(); 
 | 
        // 初始化组件引用 绑定按钮等UI组件事件 
 | 
  
 | 
        btnStop.AddListener(PauseGame); 
 | 
    } 
 | 
  
 | 
    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() 
 | 
    { 
 | 
        base.OnPreOpen(); 
 | 
        // SetBattleField(BattleManager.Instance.storyBattleField); 
 | 
        BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; 
 | 
    } 
 | 
  
 | 
    protected override void OnPreClose() 
 | 
    { 
 | 
        base.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); 
 | 
    } 
 | 
} 
 |