123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FairyGUI;
- using FL.Data;
- using System.Collections.Generic;
- using UnityEngine;
- using XGame;
- using XGame.Database;
- using XGame.Framework;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerEpiDetailInfoCtrl : UIController<PartnerEpiDetailInfoVM>
- {
- protected override void OnEnable(object intent)
- {
- id = (int)intent;
- AddUIListenres();
- UpView();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- VM.ShangZhenBtn.onClick.Add(OnClickShangZhenBtn);
- VM.GotoBtn.onClick.Add(OnClickGotoBtn);
- VM.RankUpBtn.onClick.Add(OnClickRankUpBtn);
- }
- private void RemoveUIListenres()
- {
- VM.ShangZhenBtn.onClick.Remove(OnClickShangZhenBtn);
- VM.GotoBtn.onClick.Remove(OnClickGotoBtn);
- VM.RankUpBtn.onClick.Remove(OnClickRankUpBtn);
- }
- private void OnClickShangZhenBtn(EventContext context) { }
- private void OnClickGotoBtn(EventContext context) { }
- private void OnClickRankUpBtn(EventContext context)
- {
- var info = EpigraphData.Instance.GetEpigraphInfo(id);
- if (info == null)
- return;
- var table = epigraphUpTableRepo.GetEpiragphUp(id, info.starLv);
- if (table == null)
- return;
- if (table.LevelUpCost > ItemData.Instance.GetItemNum(id))
- {
- EventSingle.Instance.Notify(EventDefine.ShowTips, StringDefine.epigraphUpUnenough);
- return;
- }
- EpigraphService.Instance.RequestEpiStarUp(id);
- }
- #endregion
- #region 属性
- private int id;
- #endregion
- #region 页面
- private void UpView()
- {
- UpDescInfo();
- UpProgressInfo();
- UpSkillList();
- }
- private void UpDescInfo()
- {
- var table = EpigraphTableRepo.Get(id);
- if (table == null)
- return;
- VM.EpiLabel.Ctrl.SetEpiIcon(id, true);
- var initSkillId = table.Skill[0];
- var skillTable = SkillTableRepo.Get(initSkillId);
- if (skillTable == null)
- return;
- VM.DescLabel.text = skillTable.Desc;
- VM.NameLabel.text = table.Name;
- var info = EpigraphData.Instance.GetEpigraphInfo(id);
- if (info != null)
- {
- VM.Up.selectedIndex = info.partnerId > 0 ? 1 : 0;
- int nextLv = info.starLv + 1;
- var nextUpTable = epigraphUpTableRepo.GetEpiragphUp(id, nextLv);
- VM.HaveState.selectedIndex = nextUpTable != null ? 1 : 2;
- }
- else
- {
- VM.HaveState.selectedIndex = 0;
- }
- if (table.Element > 0)
- {
- VM.AttrIcon.visible = true;
- VM.AttrIcon.url = AddressableDefine.PartnerElementType(((int)table.Element));
- }
- else
- {
- VM.AttrIcon.visible = false;
- }
- string str = "";
- for (int i = 0; i < table.Own_attr.Length; i += 2)
- {
- var attrTable = AttrDescTableRepo.Get(table.Own_attr[i]);
- if (attrTable == null)
- continue;
- var attrValue = table.Own_attr[i + 1];
- var val = attrValue > 0 ? TableUtils.ToRealDouble(attrValue).ToString("F2") : "0";
- if (i > 0)
- str += ",";
- str += $"{attrTable.ShowName}{val}%";
- }
- VM.AttrLabel.text = str;
- }
- private void UpProgressInfo()
- {
- var info = EpigraphData.Instance.GetEpigraphInfo(id);
- var curlv = info != null ? info.starLv : 0;
- var table = epigraphUpTableRepo.GetEpiragphUp(id, curlv);
- if (table != null)
- {
- VM.ChipPbar.max = table.LevelUpCost;
- VM.ChipPbar.value = 0;
- }
- }
- private void UpSkillList()
- {
- var list = new List<EpigraphSkillLimit>();
- var epiTable = EpigraphTableRepo.Get(id);
- if (epiTable == null)
- return;
- for (var i = 2; i < epiTable.Skill.Length; i = i + 2)
- {
- var skill = epiTable.Skill[i];
- var limit = epiTable.Skill[i + 1];
- var skillLimit = new EpigraphSkillLimit()
- {
- epiId = id,
- limitLv = limit,
- skillId = skill,
- };
- list.Add(skillLimit);
- }
- VM.EffectList.BindDatas(list);
- }
- #endregion
- }
- }
|