์ ๋ฒํผ ๋๋ฌ์ ์ ๋ฐ ํํ์ Summon ํจ์ ์๋์ํค๊ณ ์ถ์๋ฐ
์๋ฌด๋ฆฌ ์ฐพ์๋ด๋ ์ ๋ฐ ํ์์ผ๋ก ๋ชปํ๊ณ ๊ฒ์ ๋๊ธฐ ํ๋ฉด ์ ํ ์ด๋ฐ๊ฒ ๋ฐ์ ์๋๋ค
๋ณผํธ์ธ๊ฐ ๋ญ๊ฐ ์ ์ฐ๊ณ ํ๊ณ ์ถ์๋ฐ ํน์ ๊ฐ๋ฅํ ๊น??
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Summon : MonoBehaviour
{
ย ย public Transform[] summonPoints;
ย ย public GameObject[] diceObjects;
ย ย const int HOWMANYDICES = 5;
ย ย const int HOWMANYPOINTS = 3;
ย ย private int cnt;
ย ย public bool[] isSummon = new bool[HOWMANYPOINTS];
ย ย void SummonDice()
ย ย {
ย ย ย ย int randomDice = Random.Range(0, HOWMANYDICES + 1);
ย ย ย ย int randomPoint = Random.Range(0, HOWMANYPOINTS + 1);
ย ย ย ย if (cnt <= HOWMANYPOINTS + 1)
ย ย ย ย { }
ย ย ย ย else if (isSummon[randomPoint] == false)
ย ย ย ย {
ย ย ย ย ย ย Instantiate(diceObjects[randomDice], summonPoints[randomPoint].position, summonPoints[randomPoint].rotation);
ย ย ย ย ย ย isSummon[randomPoint] = true;
ย ย ย ย ย ย cnt++;
ย ย ย ย }
ย ย ย ย else
ย ย ย ย {
ย ย ย ย ย ย SummonDice();
ย ย ย ย }
ย ย }
}
ํด๋น ๋๊ธ์ ์ญ์ ๋์์ต๋๋ค.
SummonDice ๋งํ๋๊ฑฐ์ผ?
์ค ๊ณ ๋ง์ ์ ํํ๋๊ฑด ๋ด๋๋ฐ ์ํ์ ์๋๋ค ใ ใ ์ผ๋จ ๋ ๊ณ ๋ง์ ใ ใ ์ ๋ ๊ฒ ๊ฐ๋จํ๊ฑฐ์๊ตฌ๋