You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
6.1 KiB
119 lines
6.1 KiB
using IVDataFormat;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class EScrQuest : EScrCell
|
|
{
|
|
|
|
#region Ui
|
|
private TextMeshProUGUI txtCond;
|
|
private TextMeshProUGUI txtBtnGet;
|
|
private TextMeshProUGUI txtClearRate;
|
|
private TextMeshProUGUI txtGoodsCnt;
|
|
|
|
private Image imgGoodsIcon;
|
|
private Image imgCover;
|
|
private Slider sldClearRate;
|
|
private Button btnGet;
|
|
private RectTransform badge;
|
|
#endregion
|
|
|
|
private nAchivement achive = new nAchivement();
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
txtCond = trfself.Find("txtCond").GetComponent<TextMeshProUGUI>();
|
|
btnGet = trfself.Find("btnGet").GetComponent<Button>();
|
|
txtBtnGet = btnGet.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
imgCover = btnGet.transform.Find("cover").GetComponent<Image>();
|
|
imgGoodsIcon = trfself.Find("ImgIconBack").GetChild(0).GetComponent<Image>();
|
|
txtGoodsCnt = trfself.Find("ImgIconBack").GetChild(1).GetComponent<TextMeshProUGUI>();
|
|
sldClearRate = trfself.Find("sldClearRate").GetComponent<Slider>();
|
|
txtClearRate = sldClearRate.transform.Find("txtValue").GetComponent<TextMeshProUGUI>();
|
|
badge = btnGet.transform.Find("badge").GetComponent<RectTransform>();
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
if (iType == 0)
|
|
{
|
|
dQuest sysQuest = DataHandler.GetDailyQuest(itemID);
|
|
cQuestDaily playQuest = DataHandler.GetDailyQuestPlay(itemid);
|
|
|
|
achive = new nAchivement(sysQuest, eContentType.DailyQuest);
|
|
bool isClear = DataHandler.isClearAchievements(achive) > 0 ? true : false;
|
|
int currentGoalValue = DataHandler.GetAchievementValue(achive);
|
|
|
|
btnGet.interactable = isClear && playQuest.cond < 2 ? true : false;
|
|
txtBtnGet.text = playQuest.cond < 2 ? LocalizationText.GetText("all_get") : LocalizationText.GetText("all_comp");
|
|
btnGet.image.color = playQuest.cond < 2 ? new Color(255f/255f, 255f/255f, 255f/255f) : new Color(63f/255f, 161f/255f, 252f/255f, 0f/255f);
|
|
imgCover.gameObject.SetActive(!isClear);
|
|
txtCond.text = LocalizationText.GetText(FormatString.TextCondition(achive.condition, achive.condValue));
|
|
txtClearRate.text = FormatString.TextCntPer((currentGoalValue >= achive.condValue ? achive.condValue : currentGoalValue).ToString(), achive.condValue.ToString());
|
|
sldClearRate.value = (float)currentGoalValue / achive.condValue;
|
|
imgGoodsIcon.sprite = AddressableMgr.GetGoodsIcon(sysQuest.rewards[0].rewardId);
|
|
txtGoodsCnt.text = sysQuest.rewards[0].rewardType.ToString();
|
|
badge.gameObject.SetActive(btnGet.interactable);
|
|
}
|
|
else if(iType == 1)
|
|
{
|
|
achive = new nAchivement(DataHandler.GetRepeatQuest(itemID), eContentType.RepeatQuest);
|
|
btnGet.interactable = DataHandler.isClearAchievements(achive) > 0 ? true : false;
|
|
txtBtnGet.text = LocalizationText.GetText("all_get");
|
|
imgCover.gameObject.SetActive(!btnGet.interactable);
|
|
txtCond.text = LocalizationText.GetText(FormatString.TextCondition(achive.condition, achive.condValue));
|
|
txtClearRate.text = FormatString.TextCntPer(DataHandler.GetAchievementValue(achive).ToString(), achive.condValue.ToString());
|
|
sldClearRate.value = (float)DataHandler.GetAchievementValue(achive) / achive.condValue;
|
|
imgGoodsIcon.sprite = AddressableMgr.GetGoodsIcon(DataHandler.GetRepeatQuest(itemID).rewards[0].rewardId);
|
|
txtGoodsCnt.text = DataHandler.isClearAchievements(achive) > 0 ?
|
|
(DataHandler.isClearAchievements(achive) * DataHandler.GetRepeatQuest(itemID).rewards[0].rewardCount).ToString() : DataHandler.GetRepeatQuest(itemID).rewards[0].rewardCount.ToString();
|
|
badge.gameObject.SetActive(btnGet.interactable);
|
|
}
|
|
else if(iType == 2)
|
|
{
|
|
achive = new nAchivement(DataHandler.GetSysEventQuest(itemID), eContentType.EventQuest);
|
|
btnGet.interactable = DataHandler.isClearAchievements(achive) > 0 && DataHandler.GetPlayEventQuestPlay(itemid).cond < 2 ? true : false;
|
|
txtBtnGet.text = DataHandler.GetPlayEventQuestPlay(itemid).cond < 2 ? LocalizationText.GetText("all_get") : LocalizationText.GetText("all_comp");
|
|
imgCover.gameObject.SetActive(DataHandler.isClearAchievements(achive) > 0 ? false : true);
|
|
btnGet.image.color = DataHandler.GetPlayEventQuestPlay(itemid).cond < 2 ? new Color(255f / 255f, 255f / 255f, 255f / 255f) : new Color(63f / 255f, 161f / 255f, 252f / 255f, 0f / 255f);
|
|
txtCond.text = LocalizationText.GetText(FormatString.TextCondition(achive.condition, achive.condValue));
|
|
txtClearRate.text = FormatString.TextConditionRate(achive);
|
|
sldClearRate.value = (float)DataHandler.GetAchievementValue(achive) / achive.condValue;
|
|
imgGoodsIcon.sprite = AddressableMgr.GetGoodsIcon(DataHandler.GetSysEventQuest(itemID).rewards[0].rewardId);
|
|
txtGoodsCnt.text = DataHandler.isClearAchievements(achive) > 0 ?
|
|
(DataHandler.isClearAchievements(achive) * DataHandler.GetSysEventQuest(itemID).rewards[0].rewardCount).ToString() : DataHandler.GetSysEventQuest(itemID).rewards[0].rewardCount.ToString();
|
|
badge.gameObject.SetActive(btnGet.interactable);
|
|
|
|
txtBtnGet.color = imgCover.gameObject.activeSelf ? new Color(150f / 255f, 150f / 255f, 150f / 255f) : Global.CLR_White;
|
|
}
|
|
}
|
|
|
|
public void OnBtnGet()
|
|
{
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
if (iType == 0)
|
|
QuestMgr.SSClearDailyQuest(itemID);
|
|
else if (iType == 1)
|
|
{
|
|
int icnt = DataHandler.isClearAchievements(achive);
|
|
QuestMgr.SSClearRepeatQuest(itemID, icnt);
|
|
}
|
|
else if (iType == 2)
|
|
{
|
|
EventMgr.SSClearGrowMissionQuest(itemID);
|
|
}
|
|
}
|
|
}
|