123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using Common.Combat;
- using Fort23.Core;
- using Fort23.UTool;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Fort23.Mono
- {
- [UIBinding(prefab = "GraphicHelpPanel")]
- public partial class GraphicHelpPanel : UIPanel
- {
- public Button CloseBtn;
- public CustomStateController CustomStateController;
- public RectTransform MoveRoot;
- public int CurIndex;
- public int GraphicCount;
- public GameObjectPool GameObjectPool;
- private void Init()
- {
- IsShowAppBar = false;
- }
- public override async CTask<bool> AsyncInit(object[] uiData)
- {
- CTask<bool> InitCTask = CTask<bool>.Create();
- string name = (string)uiData[0];
- GraphicCount = (int)uiData[1];
- GameObjectPool = await GObjectPool.Instance.FetchAsync<GameObjectPool>(name);
- GameObjectPool.own.transform.SetParent(Root);
- GameObjectPool.own.transform.localScale = Vector3.one;
- GameObjectPool.own.transform.localPosition = Vector3.zero;
- CustomInit(GameObjectPool.own.GetComponent<ReferenceCollector>());
- InitCTask.SetResult(true);
- return await InitCTask;
- }
- public void CustomInit(ReferenceCollector referenceCollector)
- {
- CloseBtn = referenceCollector.Get<Button>("Btn_Close");
- CloseBtn.onClick.AddListener(CustomClose);
- CustomStateController = referenceCollector.Get<CustomStateController>("State");
- MoveRoot = referenceCollector.Get<RectTransform>("Root");
- CurIndex = 0;
- if (CurIndex == GraphicCount - 1)
- {
- Btn_Right.gameObject.SetActive(false);
- }
- else
- {
- Btn_Right.gameObject.SetActive(true);
- }
- if (CurIndex > 0)
- {
- Btn_Left.gameObject.SetActive(true);
- }
- else
- {
- Btn_Left.gameObject.SetActive(false);
- }
- }
- protected override void AddEvent()
- {
- }
- protected override void DelEvent()
- {
- }
- public override void AddButtonEvent()
- {
- Btn_Right.onClick.AddListener(Right);
- Btn_Left.onClick.AddListener(Left);
- MaskBtn.onClick.AddListener(CustomClose);
- }
- private void CustomClose()
- {
- UIManager.Instance.HideUIUIPanel<GraphicHelpPanel>();
- }
- private void Left()
- {
- if (CurIndex > 0)
- {
- MoveRoot.transform.localPosition += Vector3.right * 1103;
- CurIndex--;
- CustomStateController.ChangeState(CurIndex);
- }
- if (CurIndex == 0)
- {
- Btn_Left.gameObject.SetActive(false);
- }
- if (CurIndex < GraphicCount - 1)
- {
- Btn_Right.gameObject.SetActive(true);
- }
- }
- private void Right()
- {
- if (CurIndex < GraphicCount - 1)
- {
- MoveRoot.transform.localPosition -= Vector3.right * 1103;
- CurIndex++;
- CustomStateController.ChangeState(CurIndex);
- }
- if (CurIndex == GraphicCount - 1)
- {
- Btn_Right.gameObject.SetActive(false);
- }
- if (CurIndex > 0)
- {
- Btn_Left.gameObject.SetActive(true);
- }
- }
- public override void Close()
- {
- GObjectPool.Instance.Recycle(GameObjectPool);
- GameObjectPool = null;
- CloseBtn.onClick.RemoveAllListeners();
- base.Close();
- }
- }
- }
|