备份CatanBuilding瘦身独立工程
This commit is contained in:
206
Assets/Scripts/UI/Rod/RodBag/FishingRodBagPanel.cs
Normal file
206
Assets/Scripts/UI/Rod/RodBag/FishingRodBagPanel.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using DG.Tweening;
|
||||
public class AvatarEvent
|
||||
{
|
||||
public Transform avatar;
|
||||
public GameObject[] fx_fishingrods;
|
||||
public RenderTexture rt;
|
||||
}
|
||||
public class FishingRodBagPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
List<TMP_Text> text_num;
|
||||
Button btn_close;
|
||||
GameObject item;
|
||||
Transform Content;
|
||||
List<RodBagItem> rodItems = new List<RodBagItem>();
|
||||
private RodBagItem currentEqRodItem;
|
||||
PlayerFishData playerFishData;
|
||||
IDisposable disposable;
|
||||
FishingRodUpSystem upSystem;
|
||||
Transform guidance;
|
||||
RodBagImprove rodBagImprove;
|
||||
|
||||
public AnimationCurve easeCurve;
|
||||
public AnimationCurve FadeEaseCurve;
|
||||
[SerializeField]
|
||||
private CanvasGroup cg;
|
||||
public IconRodRoot iconRod;
|
||||
public RawImage rawImageRod;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
GContext.container.Unregister<FishingRodUpSystem>();
|
||||
upSystem = new FishingRodUpSystem();
|
||||
UIManager.Instance.panelStack.Push(UITypes.FishingRodBagPanel);
|
||||
GContext.container.RegisterInstance(upSystem);
|
||||
btn_close = transform.Find("bottom/btn_close").GetComponent<Button>();
|
||||
Content = transform.Find("root/ScrollView/Viewport/Content");
|
||||
item = transform.Find("root/ScrollView/Viewport/Content/Item").gameObject;
|
||||
item.SetActive(false);
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
disposable = upSystem.Subscribe<RefreshRodBagEvent>(Refresh);
|
||||
guidance = transform.Find("root/Guidance");
|
||||
rodBagImprove = transform.Find("root/benifit").GetComponent<RodBagImprove>();
|
||||
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
iconRod.SetRawImage(rawImageRod);
|
||||
|
||||
AvatarEvent avatarEvent = new AvatarEvent();
|
||||
avatarEvent.avatar = iconRod.avatar;
|
||||
avatarEvent.fx_fishingrods = iconRod.fx_fishingrods;
|
||||
avatarEvent.rt = iconRod.rt;
|
||||
upSystem.bagPanel = avatarEvent;
|
||||
GContext.Publish(new InGradeAquariumEvent());
|
||||
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
btn_close.onClick.AddListener(async () =>
|
||||
{
|
||||
if (UIManager.Instance.panelStack.Count > 0)
|
||||
{
|
||||
UIManager.Instance.panelStack.Pop();
|
||||
}
|
||||
if (UIManager.Instance.panelStack.Count > 0)
|
||||
{
|
||||
UIType topUI = UIManager.Instance.panelStack.Pop();
|
||||
await UIManager.Instance.ShowUI(topUI);
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingRodBagPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingRodBagPanel);
|
||||
GContext.Publish(new RestartShowHomeUIEvent());
|
||||
}
|
||||
GContext.Publish(new ActChangeRodDataEvent(currentEqRodItem.data.config.ID));
|
||||
});
|
||||
InitRodList();
|
||||
SetSelect();
|
||||
}
|
||||
/// <summary>
|
||||
/// 新手引导,但现在没有选中态,延时选中
|
||||
/// </summary>
|
||||
async void SetSelect()
|
||||
{
|
||||
int index = currentEqRodItem.data.sort;
|
||||
GuideDataCenter guideDataCenter = GContext.container.Resolve<GuideDataCenter>();
|
||||
bool isGuide = guideDataCenter.InspectTriggerGuide("FishingRodBagPanel");
|
||||
RodItemData rodItemData;
|
||||
int shopSelectId = playerFishData.RodSelectedInPack;
|
||||
if (isGuide)
|
||||
{
|
||||
GroupName guideName = guideDataCenter.curGroupDefine.groupName;
|
||||
shopSelectId = 30003;
|
||||
if (guideName == GroupName.BuyPack01)
|
||||
{
|
||||
shopSelectId = 40001;
|
||||
}
|
||||
}
|
||||
if (shopSelectId > 0)
|
||||
{
|
||||
for (int i = 0; i < upSystem.rodItemDatas.Count; i++)
|
||||
{
|
||||
rodItemData = upSystem.rodItemDatas[i];
|
||||
if (rodItemData.config.ID == shopSelectId)
|
||||
{
|
||||
index = rodItemData.sort;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
await Awaiters.Seconds(0.4f);
|
||||
guidance.position = rodItems[index].transform.position;
|
||||
}
|
||||
void Refresh(RefreshRodBagEvent refreshRodBagEvent)
|
||||
{
|
||||
rodBagImprove.UpLevel();
|
||||
InitRodList();
|
||||
}
|
||||
void InitRodList()
|
||||
{
|
||||
GameObject[] gameObjects = iconRod.fx_fishingrods;
|
||||
for (int i = 0; i < gameObjects.Length; i++)
|
||||
{
|
||||
gameObjects[i].SetActive(i == 2);
|
||||
}
|
||||
upSystem.InitRodList();
|
||||
for (int i = 0; i < text_num.Count; i++)
|
||||
{
|
||||
int hasCount = upSystem.hasRodID.TryGetValue(i + upSystem.StartQuality, out List<int> rodIDs) ? rodIDs.Count : 0;
|
||||
text_num[i].text = $"{hasCount}/{upSystem.allCount[i + upSystem.StartQuality]}";
|
||||
}
|
||||
Show();
|
||||
}
|
||||
void Show()
|
||||
{
|
||||
for (int i = 0; i < upSystem.rodItemDatas.Count; i++)
|
||||
{
|
||||
RodItemData rodItemData = upSystem.rodItemDatas[i];
|
||||
rodItemData.sort = i;
|
||||
|
||||
RodBagItem rodItem;
|
||||
if (i < rodItems.Count)
|
||||
{
|
||||
rodItem = rodItems[i];
|
||||
rodItem.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject go = Instantiate(item, Content);
|
||||
rodItem = go.GetComponent<RodBagItem>();
|
||||
rodItems.Add(rodItem);
|
||||
}
|
||||
rodItem.Init(rodItemData, playerFishData.CheckUpgrade(rodItemData.config) || playerFishData.CheckRodUpLevel(rodItemData.config));
|
||||
rodItem.onClick = OnRodItemClick;
|
||||
if (rodItemData.config.ID == GContext.container.Resolve<PlayerData>().equipRodID)
|
||||
{
|
||||
currentEqRodItem = rodItem;
|
||||
currentEqRodItem.SetEquipped(playerFishData.CheckRodUpLevel(rodItemData.config));
|
||||
}
|
||||
}
|
||||
StartCoroutine(ShowFish());
|
||||
}
|
||||
Tween fadeTween;
|
||||
IEnumerator ShowFish()
|
||||
{
|
||||
fadeTween.Kill();
|
||||
cg.alpha = 0f;
|
||||
fadeTween = cg.DOFadeAlpha(1f, 0.5f).SetEase(FadeEaseCurve);
|
||||
|
||||
for (int i = 0; i < rodItems.Count; i++)
|
||||
{
|
||||
rodItems[i].gameObject.SetActive(true);
|
||||
|
||||
rodItems[i].transform.localScale = Vector3.zero;
|
||||
rodItems[i].transform.DOScale(Vector3.one, 0.2f).SetEase(easeCurve);
|
||||
|
||||
if (i <= 3)
|
||||
{
|
||||
yield return new WaitForSeconds(0.01f * i);
|
||||
}
|
||||
else
|
||||
yield return new WaitForSeconds(0.04f);
|
||||
}
|
||||
}
|
||||
async void OnRodItemClick(RodBagItem rodItem)
|
||||
{
|
||||
upSystem.SelectIndex = rodItem.data.sort;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodPanel);
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingRodRewardPopupPanel);
|
||||
GContext.container.Unregister<FishingRodUpSystem>();
|
||||
GContext.Publish(new InGradeAquariumEvent() { type = 1 });
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Rod/RodBag/FishingRodBagPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Rod/RodBag/FishingRodBagPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d26330961a127643920f9386c75dac5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
133
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs
Normal file
133
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
public class FishingRodUpSystem
|
||||
{
|
||||
public IEventAggregator eventAggregator;
|
||||
|
||||
public List<RodItemData> rodItemDatas = new List<RodItemData>();
|
||||
public Dictionary<int, int> allCount = new Dictionary<int, int>();
|
||||
public Dictionary<int, List<int>> hasRodID;
|
||||
|
||||
PlayerFishData playerFishData;
|
||||
Tables _tables;
|
||||
public int SelectIndex = 0;
|
||||
public int StartQuality => 2;
|
||||
int EndQuality => 4;
|
||||
public AvatarEvent bagPanel;
|
||||
|
||||
public FishingRodUpSystem()
|
||||
{
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
eventAggregator = new EventAggregator();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
|
||||
for (int i = StartQuality; i <= EndQuality; i++)
|
||||
{
|
||||
allCount[i] = dataList.Where(x => x.Quality == i).Count();
|
||||
}
|
||||
}
|
||||
public List<int> HasRodID(int quality)
|
||||
{
|
||||
return hasRodID.TryGetValue(quality, out List<int> rodIDs) ? rodIDs : new List<int>();
|
||||
}
|
||||
public void InitRodList()
|
||||
{
|
||||
rodItemDatas.Clear();
|
||||
hasRodID = new Dictionary<int, List<int>>();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
int count = dataList.Count;
|
||||
RodData _rodData;
|
||||
RodAscend _rodAscend;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_rodData = dataList[i];
|
||||
bool isLock = playerFishData.NotRod(_rodData.ID);
|
||||
if (!isLock)
|
||||
{
|
||||
if (!hasRodID.TryGetValue(_rodData.Quality, out List<int> rodIDs))
|
||||
{
|
||||
hasRodID[_rodData.Quality] = rodIDs = new List<int>();
|
||||
}
|
||||
rodIDs.Add(_rodData.ID);
|
||||
}
|
||||
|
||||
_rodData = dataList[i];
|
||||
_rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
|
||||
|
||||
int level = playerFishData.GetRodLevel(_rodData.ID);
|
||||
int star = playerFishData.GetRodPiece(_rodData.ID);
|
||||
bool isMax = star >= _rodAscend.MaxAscent;
|
||||
RodItemData rodItemData = new RodItemData()
|
||||
{
|
||||
config = dataList[i],
|
||||
isLock = isLock,
|
||||
level = level + 1,
|
||||
star = star,
|
||||
isNew = GContext.container.Resolve<PlayerData>().IsNewRod(dataList[i].ID),
|
||||
isMax = isMax,
|
||||
isEquip = dataList[i].ID == GContext.container.Resolve<PlayerData>().equipRodID
|
||||
};
|
||||
if (!isLock)
|
||||
{
|
||||
GetDuelPerk(rodItemData);
|
||||
}
|
||||
int skindID = playerFishData.GetRodSkin(_rodData.ID);
|
||||
rodItemData.skin = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (rodItemData.skin == null)
|
||||
{
|
||||
Debug.LogError($"No SkinID {skindID} in RodID {rodItemData.config.ID}");
|
||||
continue;
|
||||
}
|
||||
rodItemData.SetRodPower();
|
||||
rodItemDatas.Add(rodItemData);
|
||||
}
|
||||
rodItemDatas.Sort(RodItemData.Sort);
|
||||
}
|
||||
void GetDuelPerk(RodItemData rodItemData)
|
||||
{
|
||||
var playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
Dictionary<int, string> RodPerkList = playerFishData.GetRodDuelPerk(rodItemData.config.ID, rodItemData.star);
|
||||
//float power = rodItemData.config.DuelPower[rodItemData.level - 1];
|
||||
//float param = 1;
|
||||
foreach (var perk in RodPerkList)
|
||||
{
|
||||
//var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(perk.Key);
|
||||
rodItemData.traitIDs.Add(perk.Key);
|
||||
rodItemData.noactions.Add(true);
|
||||
//string value = perk.Value;
|
||||
//if (!string.IsNullOrEmpty(value) && !value.Contains('|'))
|
||||
//{
|
||||
// param += float.Parse(value) * _tables.TbRodAscendPerk.GetOrDefault(perk.Key)?.DuelPowerParam ?? 0;
|
||||
//}
|
||||
}
|
||||
//power *= param;
|
||||
//rodItemData.DuelPower = (int)power;
|
||||
}
|
||||
public RodItemData GetCurrentRodItemData()
|
||||
{
|
||||
return rodItemDatas[SelectIndex];
|
||||
}
|
||||
|
||||
public IDisposable Subscribe<T>(Action<T> eventAction)
|
||||
{
|
||||
return eventAggregator.GetEvent<T>().Subscribe(eventAction);
|
||||
}
|
||||
|
||||
public void Publish<T>(T evt)
|
||||
{
|
||||
if (eventAggregator != null)
|
||||
eventAggregator.Publish(evt);
|
||||
}
|
||||
}
|
||||
public struct RefreshRodBagEvent
|
||||
{
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs.meta
Normal file
11
Assets/Scripts/UI/Rod/RodBag/FishingRodUpSystem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 014fdb79693f06f48a7be739b5a66a1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
173
Assets/Scripts/UI/Rod/RodBag/RodBagImprove.cs
Normal file
173
Assets/Scripts/UI/Rod/RodBag/RodBagImprove.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using Coffee.UIExtensions;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RodBagImprove : MonoBehaviour
|
||||
{
|
||||
public TMP_Text btn_improve_text;
|
||||
public Button btn_improve;
|
||||
public Image up_bar;
|
||||
public TMP_Text bar_text;
|
||||
public GameObject max_text;
|
||||
public GameObject fx;
|
||||
public CanvasGroup canvasGroup;
|
||||
|
||||
public UIParticleAttractor uIParticleAttractor;
|
||||
private List<RodLevelupStats> dataList;
|
||||
PlayerFishData playerFishData;
|
||||
int allScore = 0;
|
||||
bool isMax = false;
|
||||
int level = 0;
|
||||
private void Awake()
|
||||
{
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
dataList = _tables.TbRodLevelupStats.DataList;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_improve.onClick.AddListener(() =>
|
||||
{
|
||||
_ = UIManager.Instance.ShowUI(UITypes.FishingRodRewardPopupPanel);
|
||||
});
|
||||
InitLevel();
|
||||
}
|
||||
void InitLevel()
|
||||
{
|
||||
allScore = playerFishData.GetRodAllScore();
|
||||
int count = dataList.Count;
|
||||
var data = dataList[^1];
|
||||
level = count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (allScore < dataList[i].Count)
|
||||
{
|
||||
data = dataList[i];
|
||||
level = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
isMax = level == count;
|
||||
max_text.SetActive(isMax);
|
||||
bar_text.gameObject.SetActive(!max_text.activeSelf);
|
||||
if (isMax)
|
||||
{
|
||||
up_bar.fillAmount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bar_text.text = $"{allScore}/{data.Count}";
|
||||
float fillAmount = (float)allScore / data.Count;
|
||||
up_bar.fillAmount = fillAmount;
|
||||
}
|
||||
btn_improve_text.text = level.ToString();
|
||||
}
|
||||
|
||||
public async void UpLevel()
|
||||
{
|
||||
int newScore = playerFishData.GetRodAllScore();
|
||||
if (isMax || newScore == allScore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int count = dataList.Count;
|
||||
var newdata = dataList[^1];
|
||||
int newlevel = count;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (newScore < dataList[i].Count)
|
||||
{
|
||||
newdata = dataList[i];
|
||||
newlevel = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
ParticleAttractor(newScore - allScore);
|
||||
await Awaiters.Seconds(1f);
|
||||
if (up_bar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (level != newlevel)
|
||||
{
|
||||
int oldlevel = level;
|
||||
var data = dataList[level];
|
||||
level = newlevel;
|
||||
isMax = level == count;
|
||||
up_bar.DOKill();
|
||||
up_bar.DOFillAmount(1, 0.5f).OnUpdate(() =>
|
||||
{
|
||||
bar_text.text = $"{(int)(data.Count * up_bar.fillAmount)}/{data.Count}";
|
||||
}).OnComplete(async () =>
|
||||
{
|
||||
btn_improve_text.text = level.ToString();
|
||||
bar_text.text = $"{data.Count}/{data.Count}";
|
||||
max_text.SetActive(isMax);
|
||||
bar_text.gameObject.SetActive(!max_text.activeSelf);
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.FishingRodRewardSettlementPopupPanel);
|
||||
if (go != null)
|
||||
{
|
||||
var panel = go.GetComponent<FishingRodRewardSettlementPopupPanel>();
|
||||
panel.Show(oldlevel);
|
||||
}
|
||||
});
|
||||
if (isMax)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await Awaiters.Seconds(0.5f);
|
||||
}
|
||||
if (up_bar==null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
up_bar.DOKill();
|
||||
bar_text.text = $"{allScore}/{newdata.Count}";
|
||||
float fillAmount = (float)allScore / newdata.Count;
|
||||
up_bar.fillAmount = fillAmount;
|
||||
//新进度条
|
||||
allScore = newScore;
|
||||
fillAmount = (float)allScore / newdata.Count;
|
||||
up_bar.DOFillAmount(fillAmount, 0.5f).OnUpdate(() =>
|
||||
{
|
||||
bar_text.text = $"{(int)(allScore * up_bar.fillAmount)}/{newdata.Count}";
|
||||
}).OnComplete(() =>
|
||||
{
|
||||
bar_text.text = $"{allScore}/{newdata.Count}";
|
||||
});
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源飞入
|
||||
/// </summary>
|
||||
/// <param name="classification"></param>
|
||||
/// <returns></returns>
|
||||
public async System.Threading.Tasks.Task ParticleAttractor(int showCount)
|
||||
{
|
||||
ParticleSystem particleSystem = fx.transform.Find("Scale/quan03").GetComponent<ParticleSystem>();
|
||||
if (particleSystem != null)
|
||||
{
|
||||
particleSystem.Clear();
|
||||
|
||||
var main = particleSystem.main;
|
||||
int maxCount = main.maxParticles;
|
||||
if (showCount < maxCount)
|
||||
{
|
||||
int addCount = (int)showCount;
|
||||
main.maxParticles = addCount;
|
||||
}
|
||||
fx.SetActive(true);
|
||||
uIParticleAttractor.enabled = true;
|
||||
await Awaiters.Seconds(1.8f);
|
||||
fx.SetActive(false);
|
||||
uIParticleAttractor.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Rod/RodBag/RodBagImprove.cs.meta
Normal file
11
Assets/Scripts/UI/Rod/RodBag/RodBagImprove.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5374e56e12ef22646bd8361588d57c5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/Scripts/UI/Rod/RodBag/RodBagItem.cs
Normal file
46
Assets/Scripts/UI/Rod/RodBag/RodBagItem.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using asap.core;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RodBagItem : MonoBehaviour
|
||||
{
|
||||
public RodItem rodItem;
|
||||
public Button btn_item;
|
||||
public GameObject equipped;
|
||||
public GameObject redpoint;
|
||||
public Action<RodBagItem> onClick;
|
||||
public bool isUp;
|
||||
public RodItemData data => rodItem?.data;
|
||||
private void Reset()
|
||||
{
|
||||
btn_item = GetComponent<Button>();
|
||||
rodItem = transform.Find("rod").GetComponent<RodItem>();
|
||||
equipped = transform.Find("rod/equipped").gameObject;
|
||||
redpoint = transform.Find("rod/redpoint").gameObject;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_item.onClick.AddListener(OnBtnItem);
|
||||
}
|
||||
void OnBtnItem()
|
||||
{
|
||||
onClick?.Invoke(this);
|
||||
}
|
||||
public void Init(RodItemData _data, bool isUp)
|
||||
{
|
||||
rodItem.Init(_data);
|
||||
equipped.SetActive(false);
|
||||
redpoint.SetActive(isUp);
|
||||
this.isUp = isUp;
|
||||
}
|
||||
public void SetEquipped(bool isUpLevel)
|
||||
{
|
||||
equipped.SetActive(true);
|
||||
//if (isUpLevel)
|
||||
//{
|
||||
// isUp = true;
|
||||
// redpoint.SetActive(isUpLevel);
|
||||
//}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Rod/RodBag/RodBagItem.cs.meta
Normal file
11
Assets/Scripts/UI/Rod/RodBag/RodBagItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36a62a5031774d943afbf6a8b8de7088
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
136
Assets/Scripts/UI/Rod/RodBag/RodItem.cs
Normal file
136
Assets/Scripts/UI/Rod/RodBag/RodItem.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Rod/RodBag/RodItem.cs.meta
Normal file
11
Assets/Scripts/UI/Rod/RodBag/RodItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 236e01ee0ebf0f2438f64b1a561a70a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user