123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Battle.Components.AI;
- using FL.Data;
- using System.Collections.Generic;
- using UnityEngine.UI;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PlayerChangeImprintPanelCtrl : UIController<PlayerChangeImprintPanelVM>
- {
- private int _slotId; // 槽位id
- private int _runeType; // 符文类型
- private GButton[] _btnsArray;
- private runeTable _runeTableInfo;
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- _btnsArray = new GButton[3] {VM.AttackImprintBtn, VM.SkillImprintBtn, VM.PartnerImprintBtn };
- ShowUI(int.Parse(intent.ToString()));
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.CancelBtn.onClick.Add(OnClickCancelBtn);
- VM.SureBtn.onClick.Add(OnClickSureBtn);
- VM.AttackImprintBtn.onClick.Add(OnClickAttackImprintBtn);
- VM.SkillImprintBtn.onClick.Add(OnClickSkillImprintBtn);
- VM.PartnerImprintBtn.onClick.Add(OnClickPartnerImprintBtn);
- }
- private void RemoveUIListenres()
- {
- VM.CancelBtn.onClick.Remove(OnClickCancelBtn);
- VM.SureBtn.onClick.Remove(OnClickSureBtn);
- VM.AttackImprintBtn.onClick.Remove(OnClickAttackImprintBtn);
- VM.SkillImprintBtn.onClick.Remove(OnClickSkillImprintBtn);
- VM.PartnerImprintBtn.onClick.Remove(OnClickPartnerImprintBtn);
- }
- private void OnClickCancelBtn(EventContext context)
- {
- Context.ClosePanel();
- }
- private void OnClickSureBtn(EventContext context)
- {
- PlayerService.Instance.SendToChangeRuneType(PlayerData.Instance.CurPlanIndex, _slotId, _runeType);
- Context.ClosePanel();
- }
- private void OnClickAttackImprintBtn(EventContext context)
- {
- _runeType = _runeTableInfo.Handoff[0];
- ShowSelectUI(0);
- }
- private void OnClickSkillImprintBtn(EventContext context)
- {
- _runeType = _runeTableInfo.Handoff[1];
- ShowSelectUI(1);
- }
- private void OnClickPartnerImprintBtn(EventContext context)
- {
- _runeType = _runeTableInfo.Handoff[2];
- ShowSelectUI(2);
- }
- #endregion
- /// <summary>
- /// 显示可选择替换的符文UI
- /// </summary>
- /// <param name="imprintIndex"></param>
- private void ShowUI(int imprintIndex)
- {
- _slotId = imprintIndex + 1;
- _runeTableInfo = runeTableRepo.Get(_slotId);
- if (_runeTableInfo != null)
- {
- int count = _runeTableInfo.Name.Length;
- for (int i = 0; i < _btnsArray.Length; i++)
- {
- if (i < count)
- {
- _btnsArray[i].visible = true;
- _btnsArray[i].title = _runeTableInfo.Name[i];
- }
- else
- {
- _btnsArray[i].visible = false;
- }
- }
- }
- OnClickAttackImprintBtn(null);
- }
- private void ShowSelectUI(int index)
- {
- for (int i = 0; i < _btnsArray.Length; i++)
- {
- _btnsArray[i].GetController("SelectCtrl").selectedIndex = i == index ? 1 : 0;
- }
- }
- }
- }
|