51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using Continentis.MainGame.Card;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Continentis.MainGame.UI
|
|
{
|
|
public class PileBase : UIElementBase
|
|
{
|
|
public List<CardViewBase> cardViews;
|
|
public TMP_Text cardCountText;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
cardViews = new List<CardViewBase>();
|
|
UpdateCountText();
|
|
}
|
|
|
|
public virtual void AddCard(CardViewBase cardObject)
|
|
{
|
|
cardViews.Add(cardObject);
|
|
cardObject.transform.SetParent(rectTransform);
|
|
UpdateCountText();
|
|
}
|
|
|
|
public virtual void InsertCard(CardViewBase cardObject, int index)
|
|
{
|
|
cardViews.Insert(index, cardObject);
|
|
cardObject.transform.SetParent(rectTransform);
|
|
cardObject.transform.SetSiblingIndex(index);
|
|
UpdateCountText();
|
|
}
|
|
|
|
public virtual void RemoveCard(CardViewBase cardObject)
|
|
{
|
|
cardViews.Remove(cardObject);
|
|
UpdateCountText();
|
|
//Debug.Log($"Removed {cardObject.cardInstance.cardLogic.contentSubmodule.cardName} from {this.name}" );
|
|
}
|
|
|
|
private void UpdateCountText()
|
|
{
|
|
if (cardCountText != null)
|
|
{
|
|
cardCountText.text = cardViews.Count.ToString();
|
|
}
|
|
}
|
|
}
|
|
} |