yyl
2 天以前 1614a7b16b521225c98c507f92d6c5a43b49211c
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
using System;
using UnityEngine;
using UnityEngine.UI;
 
public class FullScreenBattleWin : UIBase
{
 
    // 组件引用
    public Transform mountPoint;
 
    private BattleRootNode battleRootNode = null;
 
 
    private BattleField battleField;
 
    [SerializeField]
    private Button btnSpeed;
 
    [SerializeField]
    private Text textSpeed;
 
    [SerializeField]
    private Button btnPass;
 
    [SerializeField]
    private Button btnPause;
 
    public RendererAdjuster buttonsAdjuster;
 
    // 生命周期
    protected override void InitComponent()
    {
        base.InitComponent();
        // 初始化组件引用 绑定按钮等UI组件事件
 
        btnSpeed.AddListener(ChangeSpeed);
 
        btnPass.AddListener(OnClickPass);
 
        btnPause.AddListener(OnClickPause);
    }
 
    private void OnClickPause()
    {
        if (null == battleField)
            return;
 
        battleField.IsPause = !battleField.IsPause;
    }
 
    private void OnClickPass()
    {
        if (null == battleField)
            return;
 
        battleField.ForceFinish();
    }
 
    private void ChangeSpeed()
    {
        if (null == battleField)
            return;
 
        BattleManager.Instance.speedIndex = (BattleManager.Instance.speedIndex + 1) % BattleManager.Instance.speedGear.Length;
        battleField.SetSpeedRatio(BattleManager.Instance.speedGear[BattleManager.Instance.speedIndex]);
        textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString();
    }
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        // SetBattleField(BattleManager.Instance.storyBattleField);
        BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField;
 
        UIManager.Instance.CloseWindow<MainWin>();
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        UIManager.Instance.CloseWindow<BattleHUDWin>();
        BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField;
 
        UIManager.Instance.OpenWindow<MainWin>(0);
    }
 
    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);
        buttonsAdjuster.SetSortingOrder(BattleConst.ActiveHeroActionSortingOrder);
 
        textSpeed.text = (BattleManager.Instance.speedIndex + 1).ToString();
    }
}