2024-12-13 20:38:15 +08:00
|
|
|
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<GameObject> _listItem = new List<GameObject>();
|
2024-12-22 20:35:00 +08:00
|
|
|
private List<Falling> _fallings = new List<Falling>();
|
2024-12-13 20:38:15 +08:00
|
|
|
public void SetData(bool bo)
|
|
|
|
{
|
|
|
|
win.SetActive(bo);
|
|
|
|
lose.SetActive(!bo);
|
2024-12-26 11:39:49 +08:00
|
|
|
if (bo)
|
|
|
|
{
|
|
|
|
SoundSystem.ins.WinEventAudio();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SoundSystem.ins.LoseEventAudio();
|
|
|
|
}
|
2024-12-22 20:35:00 +08:00
|
|
|
_fallings = new List<Falling>();
|
2024-12-13 20:38:15 +08:00
|
|
|
if (_listItem.Count!=0)
|
|
|
|
{
|
|
|
|
foreach (var o in _listItem)
|
|
|
|
{
|
|
|
|
Destroy(o);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_listItem = new List<GameObject>();
|
|
|
|
foreach (var fall in BattleManager.ins.Fallings)
|
|
|
|
{
|
|
|
|
bo = false;
|
2024-12-22 20:35:00 +08:00
|
|
|
foreach (var f in _fallings.Where(f => f.id==fall.id))
|
2024-12-13 20:38:15 +08:00
|
|
|
{
|
|
|
|
f.num += fall.num;
|
|
|
|
bo = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bo)
|
|
|
|
{
|
2024-12-22 20:35:00 +08:00
|
|
|
_fallings.Add(fall);
|
2024-12-13 20:38:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-12-22 20:35:00 +08:00
|
|
|
foreach (var f in _fallings)
|
2024-12-13 20:38:15 +08:00
|
|
|
{
|
|
|
|
var obj=Instantiate(item,itemParent);
|
|
|
|
obj.SetActive(true);
|
|
|
|
obj.GetComponent<EndItem>().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()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-12-22 20:35:00 +08:00
|
|
|
void VideoClosePanel()
|
|
|
|
{
|
|
|
|
ADSystem.getInstance().PlayAd(() =>
|
|
|
|
{
|
|
|
|
UIMgr.ins.OpenForgePanel();
|
|
|
|
foreach (var falling in _fallings)
|
|
|
|
{
|
|
|
|
DataManager.AddItem(falling.id,falling.num*2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-12-13 20:38:15 +08:00
|
|
|
void ClosePanel()
|
|
|
|
{
|
|
|
|
UIMgr.ins.OpenForgePanel();
|
2024-12-22 20:35:00 +08:00
|
|
|
foreach (var falling in _fallings)
|
|
|
|
{
|
|
|
|
DataManager.AddItem(falling.id,falling.num);
|
|
|
|
}
|
2024-12-13 20:38:15 +08:00
|
|
|
}
|
|
|
|
}
|