Setup and play area prefab
This commit is contained in:
parent
fe61df43e7
commit
af12b601fc
166 changed files with 14014 additions and 10 deletions
28
WizardDuelsProject/Assets/Scripts/Deck/CardSpawner.cs
Normal file
28
WizardDuelsProject/Assets/Scripts/Deck/CardSpawner.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Deck
|
||||
{
|
||||
public class CardSpawner : MonoBehaviour
|
||||
{
|
||||
[Header("Spawn Point")]
|
||||
[SerializeField] private GameObject visualsParent;
|
||||
[SerializeField] private GameObject cardParent;
|
||||
[SerializeField] private Transform spawnPoint;
|
||||
[Header("Prefabs")]
|
||||
[SerializeField] private GameObject cardPrefab;
|
||||
|
||||
[SerializeField] private GameObject visualsPrefab;
|
||||
|
||||
public Card SpawnCard(CardData cardData)
|
||||
{
|
||||
GameObject cardGO = Instantiate(cardPrefab, spawnPoint.position, Quaternion.identity, cardParent.transform);
|
||||
Card card = cardGO.GetComponent<Card>();
|
||||
|
||||
GameObject visualsGO = Instantiate(visualsPrefab, spawnPoint.position, Quaternion.identity, visualsParent.transform );
|
||||
CardVisual cardVisual = visualsGO.GetComponent<CardVisual>();
|
||||
cardVisual.Initialize(card, cardData.image);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue