using System; using System.Collections; using System.Collections.Generic; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; public class PackPanel : MonoBehaviour { [SerializeField] private TextMeshProUGUI _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 TextMeshProUGUI _moveTimeText; [SerializeField] private TextMeshProUGUI _speedText; [SerializeField] private TextMeshProUGUI _pointsText; [SerializeField] private GameObject settingObj; // 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); settingObj.SetActive(false); } // Update is called once per frame void Update() { } 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); } private void AudioEvent() { GameManager.ins.soundSystem.StopAudioSource(); } private void SoundEffects() { GameManager.ins.soundSystem.EventAudioSource(); } private void SetSettingsObj() { settingObj.SetActive(!settingObj.activeSelf); } public void GoTour() { GameManager.ins.index=0; GameManager.ins.PackEvent(); GameManager.ins.soundSystem.EventAudio(); } public void AddBox() { GameManager.ins.index++; GameManager.ins.soundSystem.EventAudio(); ResetTextData(); } public void CloseUI() { MainPanel.ins.ClosePanelEvent(); GameManager.ins.soundSystem.EventAudio(); } public void ResetPanelData() { GameManager.ins.PackEvent(); GameManager.ins.soundSystem.EventAudio(); ResetTextData(); } 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; } }