75 lines
2.5 KiB
C#
75 lines
2.5 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 Queue<Sequence> moveDeckAnimationQueue = new Queue<Sequence>();
|
|
private Vector3 cardDeckWorldPosition;
|
|
|
|
// private bool isMoveDeckAnimationPlaying = false;
|
|
public (List<Sequence>, List<Card>) SetupCharacter(int id, Vector3 deckPosition,
|
|
Quaternion doRotation, Vector3 doScale, float animationDuration)
|
|
{
|
|
ID = id;
|
|
cardDeckWorldPosition = deckPosition;
|
|
List<Sequence> ownedCardTweenList = new List<Sequence>();
|
|
foreach (GameObject cardGo in ownedCardPrefabList)
|
|
{
|
|
GameObject _card = Instantiate<GameObject>(cardGo, transform.position, Quaternion.identity, parent: transform);
|
|
_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);
|
|
ownedCardTweenList.Add(cardComponent.GetTweenMoveCardGoDeck(doGoPosition: cardDeckWorldPosition, doGoRotation: doRotation,
|
|
doGoScale: doScale, doGoDuration: animationDuration));
|
|
}
|
|
|
|
return (ownedCardTweenList, ownedCardList);
|
|
}
|
|
|
|
// public void MoveOwnedCardToDeck() => PlayNextMoveOwnedCardToDeck();
|
|
//
|
|
//
|
|
// private void PlayNextMoveOwnedCardToDeck()
|
|
// {
|
|
// if (moveDeckAnimationQueue.Count == 0)
|
|
// {
|
|
// isMoveDeckAnimationPlaying = false;
|
|
// return;
|
|
// }
|
|
//
|
|
// isMoveDeckAnimationPlaying = true;
|
|
// Sequence seq = moveDeckAnimationQueue.Dequeue();
|
|
// seq.OnComplete(PlayNextMoveOwnedCardToDeck);
|
|
// seq.Play();
|
|
// }
|
|
|
|
|
|
private void CreateOneCard(GameObject cardPrefab, int index)
|
|
{
|
|
// takeOutCard.SetupCard();
|
|
// handCardList.Add(takeOutCard);
|
|
// ReadjustCardPosition(takeOutCard);
|
|
}
|
|
|
|
|
|
// public List<Card> SetCardID()
|
|
// {
|
|
// for (int i = 0; i < ownedCardList.Count; i++)
|
|
// {
|
|
// ownedCardList[i].SetID(int.Parse($"{ID}{i}"));
|
|
// }
|
|
//
|
|
// return ownedCardList;
|
|
// }
|
|
} |