任务系统一半多,商城筛选功能,一些细节和免费包
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class taskPrefabController : MonoBehaviour
|
||||
{
|
||||
@@ -13,4 +14,53 @@ public class taskPrefabController : MonoBehaviour
|
||||
public Button rewardButton;
|
||||
public Image rewardImg;
|
||||
public Text rewardAmmount;
|
||||
|
||||
public void Setup(DailyTaskViewData taskView, int displayIndex, Sprite rewardSprite, UnityAction onRewardClicked)
|
||||
{
|
||||
if (taskView == null || taskView.definition == null || taskView.runtimeEntry == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (taskNumber != null)
|
||||
{
|
||||
taskNumber.text = displayIndex.ToString("00");
|
||||
}
|
||||
|
||||
if (taskText != null)
|
||||
{
|
||||
taskText.text = taskView.definition.description;
|
||||
}
|
||||
|
||||
if (taskProgress_fillAmount_img != null)
|
||||
{
|
||||
float targetValue = Mathf.Max(0.0001f, taskView.definition.targetValue);
|
||||
float clampedProgress = Mathf.Clamp(taskView.runtimeEntry.progress, 0f, targetValue);
|
||||
taskProgress_fillAmount_img.fillAmount = clampedProgress / targetValue;
|
||||
}
|
||||
|
||||
if (rewardImg != null)
|
||||
{
|
||||
rewardImg.sprite = rewardSprite;
|
||||
rewardImg.enabled = rewardSprite != null;
|
||||
}
|
||||
|
||||
if (rewardAmmount != null)
|
||||
{
|
||||
rewardAmmount.text = taskView.definition.rewardAmount.ToString();
|
||||
}
|
||||
|
||||
if (rewardButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rewardButton.onClick.RemoveAllListeners();
|
||||
if (onRewardClicked != null)
|
||||
{
|
||||
rewardButton.onClick.AddListener(onRewardClicked);
|
||||
}
|
||||
|
||||
rewardButton.interactable = taskView.runtimeEntry.isCompleted && !taskView.runtimeEntry.isClaimed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user