备份CatanBuilding瘦身独立工程
This commit is contained in:
164
Assets/Scripts/UI/Turntable/TurntableRewardInfoPopupPanel.cs
Normal file
164
Assets/Scripts/UI/Turntable/TurntableRewardInfoPopupPanel.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using cfg;
|
||||
using asap.core;
|
||||
|
||||
public class TurntableRewardInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
FishingEventData _fishingEventData;
|
||||
Button btn_close;
|
||||
Button btn_mask;
|
||||
Button btn_left;
|
||||
Button btn_right;
|
||||
TMP_Text text_info;
|
||||
TMP_Text text_title;
|
||||
TMP_Text text_level;
|
||||
List<WheelLevel> wheelLevels = new List<WheelLevel>();
|
||||
List<List<WheelDrop>> wheelsList = new List<List<WheelDrop>>();
|
||||
int wheelInitId;
|
||||
int index = 99999;
|
||||
List<GameObject> rewards;
|
||||
List<int> requiredPoints = new List<int>();
|
||||
int Progress;
|
||||
void Awake()
|
||||
{
|
||||
_fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_mask = transform.Find("mask").GetComponent<Button>();
|
||||
btn_left = transform.Find("root/btn_slider_left").GetComponent<Button>();
|
||||
btn_right = transform.Find("root/btn_slider_right").GetComponent<Button>();
|
||||
text_info = transform.Find("root/text_info").GetComponent<TMP_Text>();
|
||||
wheelInitId = _fishingEventData.wheelInit.ID;
|
||||
text_title = transform.Find("root/turntable/text_title").GetComponent<TMP_Text>();
|
||||
text_level = transform.Find("root/turntable/text_title/grade/text_level").GetComponent<TMP_Text>();
|
||||
rewards = new List<GameObject>();
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
rewards.Add(transform.Find($"root/turntable/reward{i}").gameObject);
|
||||
}
|
||||
Progress = _fishingEventData.GetWheelLevelCount(_fishingEventData.wheelLevel.Level);
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableRewardInfoPopupPanel);
|
||||
});
|
||||
btn_mask.onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.TurntableRewardInfoPopupPanel);
|
||||
});
|
||||
btn_left.onClick.AddListener(OnLeftClick);
|
||||
btn_right.onClick.AddListener(OnRightClick);
|
||||
Init();
|
||||
}
|
||||
void Init()
|
||||
{
|
||||
int max = 0;
|
||||
bool isFind = false;
|
||||
foreach (var wheelLevel in GContext.container.Resolve<Tables>().TbWheelLevel.DataList)
|
||||
{
|
||||
if (wheelLevel.Wheel == wheelInitId)
|
||||
{
|
||||
wheelLevels.Add(wheelLevel);
|
||||
wheelsList.Add(new List<WheelDrop>());
|
||||
foreach (int wheelDropId in wheelLevel.WheelDrop)
|
||||
{
|
||||
wheelsList[max].Add(GContext.container.Resolve<Tables>().TbWheelDrop.Get(wheelDropId));
|
||||
}
|
||||
max++;
|
||||
isFind = true;
|
||||
}
|
||||
else if (isFind)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
SetPointsList();
|
||||
index = _fishingEventData.wheelLevel.Level;
|
||||
if (index >= wheelsList.Count)
|
||||
{
|
||||
index = wheelsList.Count - 1;
|
||||
}
|
||||
UpDisplay();
|
||||
}
|
||||
void UpDisplay()
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().wheelDrop = wheelsList[index][i];
|
||||
if (index > 0 && requiredPoints[index] != 0)
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().preWheelDrop = wheelsList[index - 1][i];
|
||||
}
|
||||
else
|
||||
{
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().preWheelDrop = null;
|
||||
}
|
||||
rewards[i].GetComponent<TurntablelInfoRewardItem>().Init();
|
||||
}
|
||||
text_level.text = (index + 1).ToString();
|
||||
|
||||
if (requiredPoints[index] == 0)
|
||||
{
|
||||
text_info.text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
text_info.text = LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_7", ConvertTools.GetNumberString(requiredPoints[index]), index + 1);
|
||||
}
|
||||
|
||||
text_title.text = LocalizationMgr.GetFormatTextValue("UI_TurntableInfoPopupPanel_9", index + 1);
|
||||
|
||||
OnLeftOrRight();
|
||||
}
|
||||
void OnLeftClick()
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
index--;
|
||||
UpDisplay();
|
||||
}
|
||||
|
||||
}
|
||||
void OnRightClick()
|
||||
{
|
||||
if (index < wheelsList.Count - 1)
|
||||
{
|
||||
index++;
|
||||
UpDisplay();
|
||||
}
|
||||
}
|
||||
void OnLeftOrRight()
|
||||
{
|
||||
btn_left.interactable = index > 0;
|
||||
btn_right.interactable = index < wheelsList.Count - 1;
|
||||
}
|
||||
|
||||
void SetPointsList()
|
||||
{
|
||||
foreach (var wheelLevel in wheelLevels)
|
||||
{
|
||||
int pointsNeeded = 0;
|
||||
|
||||
if (wheelLevel.Level <= _fishingEventData.wheelLevel.Level)
|
||||
{
|
||||
pointsNeeded = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log($"Progress:{Progress}");
|
||||
for (int i = _fishingEventData.wheelLevel.Level - 1; i < wheelLevel.Level - 1; i++)
|
||||
{
|
||||
pointsNeeded += wheelLevels[i].NextLevelPoint;
|
||||
}
|
||||
pointsNeeded -= Progress;
|
||||
}
|
||||
requiredPoints.Add(pointsNeeded);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user