66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public partial class EventLuckyCardsProgressRewradPopupPanel : MonoBehaviour
|
|
{
|
|
LuckyCardsSystem luckyCardsSystem;
|
|
|
|
void Awake()
|
|
{
|
|
luckyCardsSystem = GContext.container.Resolve<LuckyCardsSystem>();
|
|
btnClose.onClick.AddListener(() =>
|
|
{
|
|
gameObject.SetActive(false);
|
|
});
|
|
}
|
|
private void OnEnable()
|
|
{
|
|
SetItem();
|
|
}
|
|
void SetItem()
|
|
{
|
|
var cardsMain = luckyCardsSystem.CardsMain;
|
|
int itemID = cardsMain.Item;
|
|
Item item = GContext.container.Resolve<Tables>().GetItemData(itemID);
|
|
List<int> milestoneList = cardsMain.MilestoneList;
|
|
List<int> milestoneRewardList = cardsMain.MilestoneRewardList;
|
|
int milestoneCount = milestoneList.Count;
|
|
ProgressMilestone progressMilestone = luckyCardsSystem.progressMilestone;
|
|
//计算奖励
|
|
int newProgress = progressMilestone.progress;
|
|
int curIndex = 0;
|
|
for (int i = 0; i < milestoneCount; i++)
|
|
{
|
|
if (i < rewardItems.Count)
|
|
{
|
|
EventLuckyCardsProgressRewardItem rewardItem = rewardItems[i];
|
|
int dropId = milestoneRewardList[i];
|
|
var rewardData = GContext.container.Resolve<PlayerItemData>().GetItemDataOne(dropId);
|
|
rewardItem.rewardItem.SetData(rewardData);
|
|
bool isClaim = newProgress >= milestoneList[i];
|
|
rewardItem.text_task.text = milestoneList[i].ToString();
|
|
if (isClaim)
|
|
{
|
|
rewardItem.rewardItem.SetReceived(true);
|
|
curIndex = i + 1;
|
|
}
|
|
}
|
|
}
|
|
if (curIndex == milestoneCount)
|
|
{
|
|
bar.fillAmount = 1f;
|
|
}
|
|
else
|
|
{
|
|
float startProgress = curIndex > 0 ? milestoneList[curIndex - 1] : 0f;
|
|
float endProgress = milestoneList[curIndex];
|
|
float startFillAmount = curIndex > 0 ? progressBar[curIndex - 1] : 0f;
|
|
float endFillAmount = progressBar[curIndex];
|
|
bar.fillAmount = (float)(newProgress - startProgress) / (endProgress - startProgress) * (endFillAmount - startFillAmount) + startFillAmount;
|
|
}
|
|
}
|
|
}
|