public void DrawP2(int n) { // ถ้าไม่มีการ์ดก็ไม่จั่ว if (DeckP2.Count > 0) { for (int y = 0; y < n; y++) { int c = UnityEngine.Random.Range(0, DeckP2.Count - 1); // หา position ที่ว่างแล้วลง for (int i = 0; i < spawnPointHand2.Length; i++) { if (spawnPointHand2[i] == false) { GameObject go2 = Instantiate(handcardP2, spawnPointHandP2[i].position, Quaternion.identity); CardDisplay display = go2.GetComponent <CardDisplay>(); go2.name = "P2Card " + i; spawnPointHand2[i] = true; handP2 = i; display.CardSetup(DeckP2[c], 2); DeckP2.RemoveAt(c); DeckCountP2.text = DeckP2.Count.ToString(); break; } } } } if (DeckP2.Count <= 0) { // endgame card 0 GameLevelManager.instance.endGame(3f, 1); } }
public void DrawP1(int n) { // ถ้าไม่มีการ์ดก็ไม่จั่ว if (DeckP1.Count > 0) { for (int y = 0; y < n; y++) { int c = UnityEngine.Random.Range(0, DeckP1.Count - 1); // หา position ที่ว่างแล้วลง for (int i = 0; i < spawnPointHand1.Length; i++) { if (spawnPointHand1[i] == false) { GameObject go = Instantiate(handcard, spawnPointHand[i].position, Quaternion.identity); CardDisplay display = go.GetComponent <CardDisplay>(); go.name = "P1Card " + i; spawnPointHand1[i] = true; //handP1 = i; display.CardSetup(DeckP1[c], 1); DeckP1.RemoveAt(c); //Debug.Log(DeckP1.Count); //DeckCountP1.text = DeckP1.Count.ToString(); break; } } } } }
private void Start() { int currentSpawn = 0; float xPos = 0f; float yPos = 2f; for (int i = 0; i < 11; i++) { foreach (Card card in cardsInColl) { if (card.manaCost == i) { switch (cardDisplayPosition) { case 0: xPos = -1.5f; break; case 1: xPos = 1f; break; case 2: xPos = 3.5f; break; case 3: xPos = 6f; break; default: break; } cardDisplayPosition++; if (cardDisplayPosition > 3) { cardDisplayPosition = 0; } GameObject go = Instantiate(cardPrefab, new Vector3(xPos, yPos, 0), Quaternion.identity); CardDisplay display = go.GetComponent <CardDisplay>(); display.CardSetup(card, 0); currentSpawn++; //เลื่อนแถวไปบรรทัดต่อไป if (currentSpawn > 3) { yPos -= 4.5f; currentSpawn = 0; } } } } }
private void Start() { int CurrentSpawn = 0; float xPos = 0f; float yPos = 2f; float xAmount = 3f; for (int i = 0; i < 11; i++) { foreach (Card card in instance.cards) { if (card.manaCost == i) { switch (cardDisplayPosition) { case 0: xPos = -4.5f; break; case 1: xPos = xPos + xAmount; break; case 2: xPos = xPos + xAmount; break; case 3: xPos = xPos + xAmount; break; default: break; } cardDisplayPosition++; if (cardDisplayPosition > 3) { cardDisplayPosition = 0; } GameObject go = Instantiate(cardPrefab, new Vector3(xPos, yPos, 0), Quaternion.identity); CardDisplay display = go.GetComponent <CardDisplay>(); display.CardSetup(card); CurrentSpawn++; if (CurrentSpawn > 3) { yPos -= 4f; CurrentSpawn = 0; } } } } }
public void addCoin(int p) { if (p == 1) { // หา position ที่ว่างแล้วลง for (int i = 0; i < spawnPointHand1.Length; i++) { if (spawnPointHand1[i] == false) { GameObject go = Instantiate(handcard, spawnPointHand[i].position, Quaternion.identity); CardDisplay display = go.GetComponent <CardDisplay>(); go.name = "P1Card " + i; spawnPointHand1[i] = true; handP1 = i; display.CardSetup(coin, 1); break; } } } else if (p == 2) { for (int i = 0; i < spawnPointHand2.Length; i++) { if (spawnPointHand2[i] == false) { GameObject go2 = Instantiate(handcardP2, spawnPointHandP2[i].position, Quaternion.identity); CardDisplay display = go2.GetComponent <CardDisplay>(); go2.name = "P2Card " + i; spawnPointHand2[i] = true; handP2 = i; display.CardSetup(coin, 2); break; } } } }