using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class EndPanel : MonoBehaviour { [SerializeField] private Button closeButton; [SerializeField] private Button videoButton; [SerializeField] private GameObject win; [SerializeField] private GameObject lose; [SerializeField] private Transform itemParent; [SerializeField] private GameObject item; [SerializeField] private List _listItem = new List(); public void SetData(bool bo) { win.SetActive(bo); lose.SetActive(!bo); var ls = new List(); if (_listItem.Count!=0) { foreach (var o in _listItem) { Destroy(o); } } _listItem = new List(); foreach (var fall in BattleManager.ins.Fallings) { bo = false; foreach (var f in ls.Where(f => f.id==fall.id)) { f.num += fall.num; bo = true; } if (!bo) { ls.Add(fall); } } foreach (var f in ls) { var obj=Instantiate(item,itemParent); obj.SetActive(true); obj.GetComponent().SetData(f); _listItem.Add(obj); } } private void OnEnable() { closeButton.onClick.AddListener(ClosePanel); videoButton.onClick.AddListener(ClosePanel); } private void OnDisable() { closeButton.onClick.RemoveListener(ClosePanel); videoButton.onClick.RemoveListener(ClosePanel); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } void ClosePanel() { UIMgr.ins.OpenForgePanel(); } }