40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
|
|
public class Character : MonoBehaviour
|
|
{
|
|
[SerializeField] private int ID;
|
|
[SerializeField] private List<GameObject> ownedCardPrefabList;
|
|
private readonly List<Card> ownedCardList = new();
|
|
private Vector3 cardDeckWorldPosition;
|
|
private Transform cardDeckContainer;
|
|
private Camera mainCamera;
|
|
|
|
public List<Card> SetupCharacter(int id, Vector3 deckPosition, Transform cardContainer, Camera camera1)
|
|
{
|
|
ID = id;
|
|
cardDeckContainer = cardContainer;
|
|
cardDeckWorldPosition = deckPosition;
|
|
mainCamera = camera1;
|
|
SetupCharacterCard();
|
|
return ownedCardList;
|
|
}
|
|
|
|
private void SetupCharacterCard()
|
|
{
|
|
foreach (GameObject cardGo in ownedCardPrefabList)
|
|
{
|
|
GameObject _card = Instantiate<GameObject>(cardGo, transform.position, Quaternion.identity, parent: cardDeckContainer);
|
|
_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, mainCamera);
|
|
}
|
|
}
|
|
} |