2025-11-20 02:23:07 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2025-11-21 20:16:36 +08:00
|
|
|
using System.Linq;
|
|
|
|
|
using DG.Tweening;
|
2025-11-20 02:23:07 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Character : MonoBehaviour
|
|
|
|
|
{
|
2025-11-20 14:43:50 +08:00
|
|
|
[SerializeField] private int ID;
|
2025-11-21 20:16:36 +08:00
|
|
|
[SerializeField] private List<GameObject> ownedCardPrefabList;
|
|
|
|
|
private readonly List<Card> ownedCardList = new();
|
|
|
|
|
private Vector3 cardDeckWorldPosition;
|
2025-11-22 23:24:51 +08:00
|
|
|
private Transform cardDeckContainer;
|
2025-11-20 14:43:50 +08:00
|
|
|
|
2025-11-22 23:24:51 +08:00
|
|
|
public List<Card> SetupCharacter(int id, Vector3 deckPosition)
|
2025-11-21 02:12:50 +08:00
|
|
|
{
|
2025-11-21 20:16:36 +08:00
|
|
|
ID = id;
|
|
|
|
|
cardDeckWorldPosition = deckPosition;
|
|
|
|
|
foreach (GameObject cardGo in ownedCardPrefabList)
|
|
|
|
|
{
|
2025-11-22 23:24:51 +08:00
|
|
|
GameObject _card = Instantiate<GameObject>(cardGo, transform.position, Quaternion.identity, parent: cardDeckContainer);
|
2025-11-21 20:16:36 +08:00
|
|
|
_card.SetActive(false);
|
|
|
|
|
int cardID = ID + ownedCardPrefabList.IndexOf(cardGo) + 1;
|
|
|
|
|
_card.name = $"card_{cardID}";
|
|
|
|
|
Card cardComponent = _card.GetComponent<Card>();
|
|
|
|
|
ownedCardList.Add(cardComponent);
|
|
|
|
|
cardComponent.SetupCard(cardID);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-22 23:24:51 +08:00
|
|
|
return ownedCardList;
|
2025-11-21 02:12:50 +08:00
|
|
|
}
|
2025-11-20 02:23:07 +08:00
|
|
|
}
|