58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using Obvious.Soap;
|
|
using UnityEngine;
|
|
|
|
public class UI_FishNetPanel : MonoBehaviour
|
|
{
|
|
public PlayerProfile PlayerProfile;
|
|
|
|
public UI_FishButton FishButtonTemplate;
|
|
|
|
public Transform FishButtonsParent;
|
|
|
|
public ScriptableEventNoParam OnFishRemovedFromNet;
|
|
|
|
public GameObject NoFishInNetTextObj;
|
|
|
|
private void OnEnable()
|
|
{
|
|
CreateFishMenuButtons();
|
|
OnFishRemovedFromNet.OnRaised += OnSellFish;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
OnFishRemovedFromNet.OnRaised -= OnSellFish;
|
|
}
|
|
|
|
private void OnSellFish()
|
|
{
|
|
CreateFishMenuButtons();
|
|
}
|
|
|
|
private void CreateFishMenuButtons()
|
|
{
|
|
Clear();
|
|
if (PlayerProfile.FishInNet.Count == 0)
|
|
{
|
|
NoFishInNetTextObj.SetActive(value: true);
|
|
return;
|
|
}
|
|
NoFishInNetTextObj.SetActive(value: false);
|
|
for (int i = 0; i < PlayerProfile.FishInNet.Count; i++)
|
|
{
|
|
List<FishData> fishInNet = PlayerProfile.FishInNet;
|
|
Object.Instantiate(FishButtonTemplate, FishButtonsParent).Initialize(fishInNet[i], i);
|
|
}
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
UI_FishButton[] componentsInChildren = FishButtonsParent.GetComponentsInChildren<UI_FishButton>();
|
|
for (int i = 0; i < componentsInChildren.Length; i++)
|
|
{
|
|
Object.Destroy(componentsInChildren[i].gameObject);
|
|
}
|
|
}
|
|
}
|