카드 중복
This commit is contained in:
parent
1f33b11f66
commit
81b694b6af
|
|
@ -9131,7 +9131,7 @@ Transform:
|
|||
m_GameObject: {fileID: 85056388}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 20.840582, y: 7.99, z: 20.65}
|
||||
m_LocalPosition: {x: 36.23, y: 7.99, z: 20.65}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
|
|
@ -163981,6 +163981,10 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 172.153
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2669107996035270001, guid: 9f51c4433e5c81644807e9e547b7826c, type: 3}
|
||||
propertyPath: m_ConstrainProportionsScale
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4085536598674672635, guid: 9f51c4433e5c81644807e9e547b7826c, type: 3}
|
||||
propertyPath: m_Size.x
|
||||
value: 0.003
|
||||
|
|
|
|||
|
|
@ -35,38 +35,37 @@ public class LevelUpUIManager : MonoBehaviour
|
|||
Time.timeScale = 0f;
|
||||
|
||||
_selectedCardUI = null;
|
||||
if (applyButton != null) applyButton.interactable = false; // 시작 땐 버튼 비활성
|
||||
if (applyButton != null) applyButton.interactable = false;
|
||||
|
||||
foreach (Transform child in cardParent)
|
||||
Destroy(child.gameObject);
|
||||
|
||||
int slotCount = 2;
|
||||
|
||||
// ⭐ [에러 해결] selectedCards를 여기서 확실히 선언합니다!
|
||||
/* =========================
|
||||
* 1️⃣ CardData 선택 (중복 없음)
|
||||
* ========================= */
|
||||
List<CardData> selectedCards = new List<CardData>();
|
||||
List<CardData> tempDataPool = new List<CardData>(cardPool);
|
||||
|
||||
if (cardPool.Count >= slotCount)
|
||||
{
|
||||
List<CardData> tempPool = new List<CardData>(cardPool);
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
{
|
||||
int idx = Random.Range(0, tempPool.Count);
|
||||
selectedCards.Add(tempPool[idx]);
|
||||
tempPool.RemoveAt(idx);
|
||||
}
|
||||
}
|
||||
else // 카드 부족 시 순환
|
||||
{
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
selectedCards.Add(cardPool[i % cardPool.Count]);
|
||||
}
|
||||
|
||||
// 카드 생성 및 셋업
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
{
|
||||
// 프리팹 랜덤 선택 후 생성
|
||||
CardUI ui = Instantiate(cardPrefabs[Random.Range(0, cardPrefabs.Length)], cardParent);
|
||||
ui.Setup(selectedCards[i], this); // ⭐ 이제 selectedCards 에러가 뜨지 않습니다!
|
||||
int idx = Random.Range(0, tempDataPool.Count);
|
||||
selectedCards.Add(tempDataPool[idx]);
|
||||
tempDataPool.RemoveAt(idx);
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* 2️⃣ CardUI 프리팹 선택 (중복 없음)
|
||||
* ========================= */
|
||||
List<CardUI> tempPrefabs = new List<CardUI>(cardPrefabs);
|
||||
|
||||
for (int i = 0; i < slotCount; i++)
|
||||
{
|
||||
int idx = Random.Range(0, tempPrefabs.Count);
|
||||
CardUI ui = Instantiate(tempPrefabs[idx], cardParent);
|
||||
ui.Setup(selectedCards[i], this);
|
||||
tempPrefabs.RemoveAt(idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user