yyl
3 天以前 b20b06455ea5bedada2b552a92619a196bc736d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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;
        }
    }
}