123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- /// #pkgName FGUI包名
- /// #panelName UIPanel名字
- /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
- /// 该脚本由模板创建
- /// created by cb 2024
- using FL.Data.Items;
- using FL.Network;
- using XGame.Database;
- using XGame.Framework.UI;
- namespace FL.FGUI
- {
- public class ItemParam
- {
- public long id;
- public int tableId;
- public int count;
- public int level;
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class ItemRewardItemCtrl : UIController<ItemRewardItemVM>
- {
- private long _equipId; // 装备的uid
- protected override void OnEnable(object intent)
- {
- AddUIListenres();
- }
- protected override void OnDisable()
- {
- RemoveUIListenres();
- }
- #region UI事件
- private void AddUIListenres()
- {
- }
- private void RemoveUIListenres()
- {
- }
- #endregion
- public void OnRefresh(int index, KindItem param)
- {
- EquipItem equipData = null;
- Item _item = new Item();
- bool bEquip = param.count == 0;
- int itemId = param.id;
- if (bEquip)
- {
- equipData = EquipData.Instance.GetTemporaryEquipItem(itemId);
- itemId = equipData.TableId;
- _item.Level = equipData.Level;
- _equipId = itemId;
- }
- else
- _equipId = 0;
- ShowCompareEquip(bEquip, equipData);
- var itemInfo = ItemTableRepo.Get(itemId);
- if (itemInfo != null)
- {
- _item.Count = param.count.ToString();
- _item.Init(itemInfo, bEquip ? param.id : 0);
- UiParam _uiParam = new UiParam();
- _uiParam.bShowBtn = true;
- _uiParam.bShowName = false;
- _uiParam.bShowCount = param.count > 1;
- _uiParam.bShowLevel = bEquip;
- _uiParam.bShowBaseInfo = bEquip ? false : true;
- VM.ItemBtn.Ctrl.ShowUI(_item, _uiParam);
- }
- }
- /// <summary>
- /// 装备战力比较标识
- /// </summary>
- private void ShowCompareEquip(bool bEquip, EquipItem equipData)
- {
- ShowEquipCtrlIndex(bEquip ? GetCompareValue(equipData) : 0);
- }
- private void ShowEquipCtrlIndex(int index)
- {
- VM.EquipCtrl.selectedIndex = index;
- }
- /// <summary>
- /// 与身上穿戴部位战力比较
- /// </summary>
- /// <param name="equipData"></param>
- /// <returns></returns>
- private int GetCompareValue(EquipItem equipData)
- {
- int compareFlag = 0;
- if (equipData?.Table?.Part > 0)
- {
- var wearEquipItem = EquipData.Instance.GetWearEquipData(equipData.Table.Part);
- long wearFightingPower = wearEquipItem?.FightingPower ?? 0;
- if (equipData.FightingPower > wearFightingPower)
- compareFlag = 1;
- else if (equipData.FightingPower < wearFightingPower)
- compareFlag = 2;
- }
- return compareFlag;
- }
- }
- }
|