123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using System.Collections.Generic;
- using FL.Data;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class PartnerSbDetailNestedCtrl : UIController<PartnerSbDetailNestedVM>
- {
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres() { }
- private void RemoveUIListenres() { }
- #endregion
- private int _sbId;
- public void ShowUI(int id)
- {
- _sbId = id;
- if (_sbId == 0)
- {
- VM.ItemBase.Disable();
- VM.IsEmpty.selectedIndex = 1;
- return;
- }
- VM.ItemBase.Enable(null);
- VM.IsEmpty.selectedIndex = 0;
- var table = PartnerTableRepo.Get(_sbId);
- XGame.Framework.Assert.IsNotNull(table, $"圣兵表不存在,id:{_sbId}");
- VM.NameLabel.text = table.Name;
- var attr = PartnersData.Instance.GetPartnerAttrByTableId(_sbId);
- var level = attr?.Level ?? 1;
- var star = attr?.RisingStarLv ?? 1;
- var upStarTable = partnerStarUpTableRepo.GetPartnerStarTable(_sbId, star);
- XGame.Framework.Assert.IsNotNull(
- upStarTable,
- $"圣兵升星表不存在,id:{_sbId},level:{star}"
- );
- VM.SpPbar.max = upStarTable.StarUpCost;
- VM.SpPbar.value = ItemData.Instance.GetItemNum(upStarTable.PetId);
- //
- ShowStar(star);
- //
- ShowSkillBaseInfo(table.Skill[0]);
- //
- ShowAttr(level);
- //
- VM.ElementLoader.url = AddressableDefine.SbElementType(((int)table.Element));
- VM.TypeLoader.url = AddressableDefine.SbTypeIcon(table.Type);
- //
- VM.AttrLabel.text = $"+{table.Own_attr[1] / 100f}%";
- var item = ItemBase.Create(_sbId);
- VM.ItemBase.Ctrl.ShowUI(item);
- }
- private void ShowStar(int star)
- {
- var starStep = PartnersService.Instance.GetStarStep(star);
- var starLv = PartnersService.Instance.GetStarLv(star);
- var list = new List<int>();
- for (int i = 0; i < starLv; i++)
- {
- list.Add(starStep);
- }
- VM.StarList.BindDatas(list);
- }
- private void ShowAttr(int level)
- {
- var lvTable = partnerLvUpAttrTableRepo.GetPartnerLvUpAttrTable(_sbId, level);
- XGame.Framework.Assert.IsNotNull(lvTable, $"圣兵等级不存在,id:{_sbId},level:{level}");
- var partnerTable = PartnerTableRepo.Get(_sbId);
- XGame.Framework.Assert.IsNotNull(partnerTable, $"圣兵表不存在,id:{_sbId}");
- var map = new Dictionary<int, int>();
- for (int i = 0; i < partnerTable.Base_attr.Length; i += 2)
- {
- map.Add(partnerTable.Base_attr[i], partnerTable.Base_attr[i + 1]);
- }
- var atkVal = map.GetValueOrDefault((int)EAttributeType.PetDmg, 0);
- var atkSpeed = map.GetValueOrDefault((int)EAttributeType.PetSpeed, 0);
- for (int i = 0; i < lvTable.Attr.Length; i += 2)
- {
- var type = lvTable.Attr[i];
- if (type == (int)EAttributeType.PetDmg)
- {
- atkVal += lvTable.Attr[i + 1];
- }
- else if (type == (int)EAttributeType.PetSpeed)
- {
- atkSpeed += lvTable.Attr[i + 1];
- }
- }
- //var attributeInfo = AttrDescTableRepo.Get(attrType);
- string descAtk = atkVal > 0 ? atkVal.ToRealFloat().ToString("F1") : "0";
- VM.AtkValLabel.text = descAtk;
- string descSpeed = atkSpeed > 0 ? atkSpeed.ToRealFloat().ToString("F1") : "0";
- VM.SpeedValLabel.text = descSpeed;
- }
- /// <summary>
- /// 基础技能描述
- /// </summary>
- /// <param name="skillId"></param>
- private void ShowSkillBaseInfo(int skillId)
- {
- var skillInfo = SkillTableRepo.Get(skillId);
- XGame.Framework.Assert.IsNotNull(skillInfo, $"技能表不存在,id{skillId}");
- VM.DescLabel.text = skillInfo.Desc;
- }
- }
- }
|