New file |
| | |
| | | using System; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | | public class BoneFieldBattleWin : 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; |
| | | |
| | | public BossLifeBar bossLifeBar; |
| | | |
| | | |
| | | public SkillWordCell[] skillWordCells; |
| | | |
| | | public BossHeadCell bossHeadCell; |
| | | |
| | | public Text txtBossName; |
| | | |
| | | public Text txtBattleRound; |
| | | |
| | | public TotalDamageDisplayer totalDamageDisplayer; |
| | | |
| | | // 生命周期 |
| | | 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; |
| | | |
| | | if (!UIManager.Instance.IsOpened<MainWin>()) |
| | | UIManager.Instance.OpenWindow<MainWin>(); |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |