using System; using System.Collections; using System.Collections.Generic; using TMPro; using TTSDK; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class PackPanel : MonoBehaviour { [SerializeField] private Button beginner; [SerializeField] private Text _textMeshPro; [SerializeField] private Button packButton; [SerializeField] private Button addBoxButton; [SerializeField] private Button close; [SerializeField] private Button goTourButton; [SerializeField] private Button settingButton; [SerializeField] private Button audioButton; [SerializeField] private Button soundEffectsButton; [SerializeField] private Button videoUnlock; [SerializeField] private Slider time; [SerializeField] private TextMeshProUGUI _moveTimeText; [SerializeField] private TextMeshProUGUI _speedText; [SerializeField] private TextMeshProUGUI _pointsText; [SerializeField] private GameObject settingObj; private int index=0; // Start is called before the first frame update void Start() { } private void OnEnable() { packButton.onClick.AddListener(ResetPanelData); addBoxButton.onClick.AddListener(AddBox); close.onClick.AddListener(CloseUI); goTourButton.onClick.AddListener(GoTour); settingButton.onClick.AddListener(SetSettingsObj); audioButton.onClick.AddListener(AudioEvent); soundEffectsButton.onClick.AddListener(SoundEffects); videoUnlock.onClick.AddListener(AddUnlock); beginner.onClick.AddListener(CloseBeginner); settingObj.SetActive(false); } // Update is called once per frame void Update() { time.value = (300 - GameManager.ins.NowTime) / 300; } private void OnDisable() { packButton.onClick.RemoveListener(ResetPanelData); addBoxButton.onClick.RemoveListener(AddBox); close.onClick.RemoveListener(CloseUI); goTourButton.onClick.RemoveListener(GoTour); settingButton.onClick.RemoveListener(SetSettingsObj); audioButton.onClick.RemoveListener(AudioEvent); soundEffectsButton.onClick.RemoveListener(SoundEffects); videoUnlock.onClick.RemoveListener(AddUnlock); beginner.onClick.RemoveListener(CloseBeginner); } private void AudioEvent() { GameManager.ins.soundSystem.StopAudioSource(); } private void SoundEffects() { GameManager.ins.soundSystem.EventAudioSource(); } private void CloseBeginner() { beginner.gameObject.SetActive(false); TT.ReportAnalytics("10102"); DotData.ins.SendEvent("10102",""); } private void SetSettingsObj() { settingObj.SetActive(!settingObj.activeSelf); } public void GoTour() { GameManager.ins.index=0; GameManager.ins.PackEvent(); GameManager.ins.soundSystem.EventAudio(); } public void AddBox() { AdMgr.Instance.ShowAd((a => { index++; switch (index) { case 1: TT.ReportAnalytics("10117"); DotData.ins.SendEvent("10117",""); break; case 2: TT.ReportAnalytics("10118"); DotData.ins.SendEvent("10118",""); break; } DataManager.STTAnalytics("box",DataManager.GTTAnalytics("box")+1); switch (DataManager.GTTAnalytics("box")) { case 1: TT.ReportAnalytics("10112"); DotData.ins.SendEvent("10112",""); break; case 2: TT.ReportAnalytics("10113"); DotData.ins.SendEvent("10113",""); break; case 3: TT.ReportAnalytics("10114"); DotData.ins.SendEvent("10114",""); break; case 5: TT.ReportAnalytics("10115"); DotData.ins.SendEvent("10115",""); break; case 10: TT.ReportAnalytics("10116"); DotData.ins.SendEvent("10116",""); break; } GameManager.ins.index++; GameManager.ins.soundSystem.EventAudio(); ResetTextData(); ResetAddButton(); })); } private void ResetAddButton() { if (index>=2) { addBoxButton.gameObject.SetActive(false); } else { addBoxButton.gameObject.SetActive(true); } } public void CloseUI() { MainPanel.ins.ClosePanelEvent(); GameManager.ins.soundSystem.EventAudio(); } public void ResetPanelData() { GameManager.ins.PackEvent(); GameManager.ins.soundSystem.EventAudio(); ResetTextData(); } public void ResetAddUnlock() { videoUnlock.gameObject.SetActive(!MapManager.ins.Lock()); } public void StartPanel() { index = 0; if (DataManager.GetInt("firstPackBeginner")!=1) { beginner.gameObject.SetActive(true); DataManager.SetInt("firstPackBeginner",1); } else { beginner.gameObject.SetActive(false); } ResetAddButton(); } public void ResetTextData() { _textMeshPro.text = "\u00d7" + (GameManager.ins.index - 1); } public void ResetPropattributes() { var moveTime = Mathf.Round(ItemSystem.ins.boxMoveTime).ToString(); if ((ItemSystem.ins.moveTime-ItemSystem.ins.boxMoveTime)!=0) { moveTime += "+" + ""+Mathf.Round(ItemSystem.ins.moveTime - ItemSystem.ins.boxMoveTime)+""; } _moveTimeText.text =moveTime; var boxMove = Mathf.Round(ItemSystem.ins.boxSpeed).ToString(); if ((ItemSystem.ins.speed-ItemSystem.ins.boxSpeed)>0) { boxMove += "+" + ""+Mathf.Round(ItemSystem.ins.speed-ItemSystem.ins.boxSpeed)+""; } _speedText.text = boxMove; var boxPoint = Mathf.Round(ItemSystem.ins.boxPoints).ToString(); if ((ItemSystem.ins.points- ItemSystem.ins.boxPoints)>0) { boxPoint += "+" +""+ Mathf.Round(ItemSystem.ins.points- ItemSystem.ins.boxPoints)+""; } _pointsText.text = boxPoint; } public void AddUnlock() { AdMgr.Instance.ShowAd((a) => { if (MapManager.ins._unLockIndex==1) { TT.ReportAnalytics("10125"); DotData.ins.SendEvent("10125",""); } if (MapManager.ins._unLockIndex==2) { TT.ReportAnalytics("10126"); DotData.ins.SendEvent("10126",""); } if (MapManager.ins._unLockIndex==3) { TT.ReportAnalytics("10127"); DotData.ins.SendEvent("10127",""); } if (MapManager.ins._unLockIndex==5) { TT.ReportAnalytics("10128"); DotData.ins.SendEvent("10128",""); } DataManager.STTAnalytics("grid", DataManager.GTTAnalytics("grid")+1); switch (DataManager.GTTAnalytics("grid")) { case 1: TT.ReportAnalytics("10119"); DotData.ins.SendEvent("10119",""); break; case 2: TT.ReportAnalytics("10120"); DotData.ins.SendEvent("10120",""); break; case 3: TT.ReportAnalytics("10121"); DotData.ins.SendEvent("10121",""); break; case 5: TT.ReportAnalytics("10122"); DotData.ins.SendEvent("10122",""); break; case 10: TT.ReportAnalytics("10123"); DotData.ins.SendEvent("10123",""); break; case 20: TT.ReportAnalytics("10124"); DotData.ins.SendEvent("10124",""); break; } MapManager.ins.RandomUnlock(); GameManager.ins.OpenVideoLock(); }); } }