137 lines
4.4 KiB
C#
137 lines
4.4 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class RodItem : MonoBehaviour
|
|
{
|
|
public Trait[] traits;
|
|
public Image bg;
|
|
public Image img_icon;
|
|
public GameObject mask_empty;
|
|
public TMP_Text text_level;
|
|
public StarItemRoot starRoot;
|
|
public RodItemData data;
|
|
private void Reset()
|
|
{
|
|
bg = transform.Find("bg").GetComponent<Image>();
|
|
img_icon = transform.Find("img_map").GetComponent<Image>();
|
|
mask_empty = transform.Find("mask_empty").gameObject;
|
|
text_level = transform.Find("text_level").GetComponent<TMP_Text>();
|
|
starRoot = transform.Find("star").GetComponent<StarItemRoot>();
|
|
}
|
|
|
|
public void Init(RodItemData _data)
|
|
{
|
|
IUIService uIService = GContext.container.Resolve<IUIService>();
|
|
data = _data;
|
|
mask_empty.SetActive(data.isLock);
|
|
text_level.gameObject.SetActive(!data.isLock);
|
|
starRoot.gameObject.SetActive(!data.isLock);
|
|
if (!data.isLock)
|
|
{
|
|
SetLevel();
|
|
SetStar();
|
|
}
|
|
uIService.SetImageSprite(bg, Define.sp_rod_card[data.config.Quality - 1], BasePanel.PanelName);
|
|
uIService.SetImageSprite(img_icon, data.skin.Avatar, BasePanel.PanelName);
|
|
if (traits != null && _data.traitIDs != null)
|
|
{
|
|
for (int i = 0; i < traits.Length; i++)
|
|
{
|
|
if (i < _data.traitIDs.Count)
|
|
{
|
|
traits[i].Init(_data.traitIDs[i], _data.noactions[i], _data.config.Quality);
|
|
}
|
|
else
|
|
{
|
|
traits[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetLevel()
|
|
{
|
|
text_level.gameObject.SetActive(!data.isLock);
|
|
text_level.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", data.level);
|
|
}
|
|
void SetStar()
|
|
{
|
|
int star = data.star;
|
|
var curRodAscend = GContext.container.Resolve<Tables>().TbRodAscend.GetOrDefault(data.config.AscendID);
|
|
starRoot.SetStar(star, curRodAscend.MaxAscent);
|
|
}
|
|
}
|
|
|
|
public class RodItemData
|
|
{
|
|
public int sort;
|
|
public int level;//展示用比数据多一级
|
|
public int star;
|
|
public RodData config;
|
|
public RodSkinData skin;
|
|
public bool isNew;
|
|
public bool isLock;
|
|
public bool isMax;
|
|
public bool isEquip;
|
|
public List<int> traitIDs = new List<int>();
|
|
public List<bool> noactions = new List<bool>();
|
|
public int RodPower;
|
|
public void SetRodPower()
|
|
{
|
|
if (isLock)
|
|
{
|
|
RodPower = 0;
|
|
}
|
|
else
|
|
{
|
|
RodRodLevelPeak rodLevelPeak = GContext.container.Resolve<Tables>().TbRodRodLevelPeak.GetOrDefault(config.Quality);
|
|
RodPower = config.DuelPowerLevel[level - 1] + config.DuelPowerAscend[star];
|
|
//巅峰等级
|
|
//星级对属性的加成 某几个属性加多少加到多少星
|
|
int honorLevel = GContext.container.Resolve<PlayerFishData>().GetHonorLevel(config.Quality);
|
|
if (rodLevelPeak != null && honorLevel > 0)
|
|
{
|
|
List<int> duelPowerLevelPeak = rodLevelPeak.DuelPowerLevelPeak;
|
|
int value;
|
|
int count = duelPowerLevelPeak.Count;
|
|
if (honorLevel > count)
|
|
{
|
|
value = duelPowerLevelPeak[count - 1];
|
|
value += (honorLevel - count) * (duelPowerLevelPeak[count - 1] - duelPowerLevelPeak[count - 2]);
|
|
}
|
|
else
|
|
{
|
|
value = duelPowerLevelPeak[honorLevel - 1];
|
|
}
|
|
RodPower += value;
|
|
}
|
|
}
|
|
}
|
|
public static int Sort(RodItemData a, RodItemData b)
|
|
{
|
|
int levelA = a.isLock ? -1 : a.RodPower;
|
|
int levelB = b.isLock ? -1 : b.RodPower;
|
|
levelA *= a.isEquip ? 100 : 1;
|
|
levelB *= b.isEquip ? 100 : 1;
|
|
if (levelA == levelB)
|
|
{
|
|
levelA = a.level;
|
|
levelB = b.level;
|
|
if (levelA == levelB)
|
|
{
|
|
if (b.config.Quality == a.config.Quality)
|
|
{
|
|
return b.star.CompareTo(a.star);
|
|
}
|
|
return b.config.Quality.CompareTo(a.config.Quality);
|
|
}
|
|
}
|
|
return levelB.CompareTo(levelA);
|
|
}
|
|
}
|