using asap.core; using cfg; using game; using GameCore; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class EventPinballRewardPoupPanel : MonoBehaviour { GameObject item; float itemHeight; Tables tables; RewardItemNew[] rewardItems; ScrollRect scrollRect; private EventPinballDataManager m_DataManager; private void Awake() { m_DataManager = GContext.container.Resolve(); tables = GContext.container.Resolve(); rewardItems = transform.Find("root/bg/grand_prize/reward").GetComponentsInChildren(true); item = transform.Find("root/bg/ScrollView/Viewport/Content/item").gameObject; item.SetActive(false); itemHeight = item.GetComponent().rect.height; SetData(); } void SetData() { Transform content = transform.Find("root/bg/ScrollView/Viewport/Content"); List pinballRewards = tables.TbEventPinballReward.DataList; int rewardMaxIndex = pinballRewards.Count - 1; EventPinballReward pinballReward = pinballRewards[0]; float progress = m_DataManager.PinballData.Scores; PinballRewardItem duelRewardItem = null; content.GetComponent().anchoredPosition = new Vector3(0, (3 - m_DataManager.PinballData.RewardIndex) * itemHeight, 0); for (int i = 0; i < pinballRewards.Count - 1; i++) { pinballReward = pinballRewards[i]; GameObject go = Instantiate(item, content); go.SetActive(true); duelRewardItem = go.GetComponent(); List rewardItemData = GContext.container.Resolve().GetItemDataByDropIdLureInflation(m_DataManager.PinballData.InflationRate, pinballReward.DropID); if (rewardItemData != null) { int dataCount = rewardItemData.Count; int rewardCount = duelRewardItem.rewardItems.Count; for (int j = 0; j < rewardCount; j++) { if (j < dataCount) { duelRewardItem.rewardItems[j].SetData(rewardItemData[j]); duelRewardItem.rewardItems[j].SetReceived(i < m_DataManager.PinballData.RewardIndex); } else { duelRewardItem.rewardItems[j].gameObject.SetActive(false); } } } duelRewardItem.bg_done.SetActive(i < m_DataManager.PinballData.RewardIndex); duelRewardItem.bg_next.SetActive(i == m_DataManager.PinballData.RewardIndex); duelRewardItem.bg_lock.SetActive(true); if (i == m_DataManager.PinballData.RewardIndex - 1) { int spinPoint = pinballReward.SpinPoint; int nextSpinPoint = pinballRewards[i + 1].SpinPoint; duelRewardItem.bar.fillAmount = (progress - spinPoint) / (nextSpinPoint - spinPoint); if (m_DataManager.PinballData.RewardIndex == rewardMaxIndex) { duelRewardItem.bar.fillAmount *= 0.6231884f; } } else if (i < m_DataManager.PinballData.RewardIndex) { duelRewardItem.bar.fillAmount = 1; } else { duelRewardItem.bar.fillAmount = 0; } } int grandPrizeDropID = pinballRewards[pinballRewards.Count - 1].DropID; DropPackageList dropPackageList = tables.TbDrop[grandPrizeDropID].DropList; Item itemcfg = tables.TbItem[dropPackageList.DropIDList[0]]; var grandPrizeItemData = GContext.container.Resolve().GetItemDataByDropIdLureInflation(m_DataManager.PinballData.InflationRate, itemcfg.RedirectID); if (grandPrizeItemData != null) { int dataCount = grandPrizeItemData.Count; int rewardCount = rewardItems.Length; for (int j = 0; j < rewardCount; j++) { if (j < dataCount) { rewardItems[j].SetData(grandPrizeItemData[j]); } else { rewardItems[j].gameObject.SetActive(false); } } } } }