using System; using System.Collections; using System.Collections.Generic; using TMPro; using TTSDK; using TTSDK.UNBridgeLib.LitJson; using UnityEngine; using UnityEngine.UI; public class WinPanel : MonoBehaviour { [SerializeField] private Button nextButton; [SerializeField] private Button closeButton; [SerializeField] private List _taskItems; [SerializeField] private Slider _slider; [SerializeField] private TextMeshProUGUI _points; // Start is called before the first frame update void Start() { } public void SaveData(int id) { switch (id) { case 110011: TT.ReportAnalytics("a10103"); DotData.ins.SendEvent("a10103",""); break; case 110012: TT.ReportAnalytics("a10105"); DotData.ins.SendEvent("a10105",""); break; case 110013: TT.ReportAnalytics("a10107"); DotData.ins.SendEvent("a10107",""); break; case 110015: TT.ReportAnalytics("a10109"); DotData.ins.SendEvent("a10109",""); break; case 110025: TT.ReportAnalytics("a10110"); DotData.ins.SendEvent("a10110",""); break; case 110045: TT.ReportAnalytics("a10111"); DotData.ins.SendEvent("a10111",""); break; } var data=JsonTab.Instance.tables.Level.Get(id); _taskItems[0].InitData(id, data.Maintasks); for (int i = 1; i < _taskItems.Count; i++) { _taskItems[i].gameObject.SetActive(false); } for (int i = 0; i < data.Additionaltasks.Count; i++) { _taskItems[i+1].gameObject.SetActive(true); _taskItems[i+1].InitData(id,data.Additionaltasks[i]); } _points.text = DataManager.LastTimePoints(GameManager.ins.level).ToString(); _slider.value = GameManager.ins.NowLenght / data.Length; } private void OnEnable() { nextButton.onClick.AddListener(NextEvent); closeButton.onClick.AddListener(CloseEvent); } // Update is called once per frame void Update() { } private void OnDisable() { nextButton.onClick.RemoveListener(NextEvent); closeButton.onClick.RemoveListener(CloseEvent); } void NextEvent() { AdMgr.Instance.ShowAd((a) => { var lastPoints=DataManager.LastTimePoints(GameManager.ins.level)*2; DataManager.SetPointsData(GameManager.ins.level, lastPoints); SaveTTEvent(); DataManager.STTAnalytics("Double",DataManager.GTTAnalytics("Double")+1); switch (DataManager.GTTAnalytics("Double")) { case 1: TT.ReportAnalytics("a10136"); DotData.ins.SendEvent("a10136",""); break; case 2: TT.ReportAnalytics("a10137"); DotData.ins.SendEvent("a10137",""); break; case 3: TT.ReportAnalytics("a10138"); DotData.ins.SendEvent("a10138",""); break; case 5: TT.ReportAnalytics("a10139"); DotData.ins.SendEvent("a10139",""); break; case 10: TT.ReportAnalytics("a10140"); DotData.ins.SendEvent("a10140",""); break; } MainPanel.ins.ClosePanelEvent(); }); } private void SaveTTEvent() { var paramJson = new JsonData { ["level"] = GameManager.ins.level, ["value"] = DataManager.LastTimePoints(GameManager.ins.level), }; TT.SetImRankData(paramJson, (b, s) => { if (b) { Debug.Log("SetImRankData"); } else { Debug.Log("SetImRankData"); } }); } void CloseEvent() { MainPanel.ins.ClosePanelEvent(); SaveTTEvent(); } }