Ejemplo n.º 1
0
    public void GenNewPotion()
    {
        GenPosition a     = potionGenList[Random.Range(0, potionGenList.Count)];
        int         count = 0;

        //과하게 안만들어질때 대비용
        while (!a.GenItem())
        {
            a = potionGenList[Random.Range(0, potionGenList.Count)];
            count++;
            if (count > 100)
            {
                return;
            }
        }
    }
Ejemplo n.º 2
0
    public void GenNewCoin()
    {
        if (coinGenList.Count == 0)
        {
            return;
        }
        GenPosition a     = coinGenList[Random.Range(0, coinGenList.Count)];
        int         count = 0;

        while (!a.GenItem())
        {
            a = potionGenList[Random.Range(0, potionGenList.Count)];
            count++;
            if (count > 100)
            {
                return;
            }
        }
    }
Ejemplo n.º 3
0
    private GameObject CreateOneBlock(bool isStartPoint)
    {
        Transform a;

        if (!isStartPoint)
        {
            int  tmp      = 0;
            bool passable = false;

            while (!passable)
            {
                tmp      = Random.Range(0, mapBlock.Length);
                passable = true;
                foreach (var i in specialBlockNum)
                {
                    if (i == tmp)
                    {
                        if (Random.Range(0, 100) < specialBlockRatio)
                        {
                            //스페셜 블럭 생성
                            passable = true;
                        }
                        else
                        {
                            //생성 취소.
                            passable = false;
                        }
                        break;
                    }
                }
            }

            a = mapBlock[tmp];
        }
        else
        {
            a = startBlock[Random.Range(0, startBlock.Length)];
        }

        GameObject b = Instantiate(a).gameObject;

        blockList.Add(b);
        int childNum = b.transform.childCount;

        for (int i = 0; i < childNum; i++)
        {
            Transform tmp = b.transform.GetChild(i);
            if (tmp.tag == "DrugGen")
            {
                GenPosition gp = tmp.gameObject.GetComponent <GenPosition>();
                drugGenList.Add(gp);

                if (isStartPoint)
                {
                    gp.GenItem();
                }
            }
            else if (tmp.tag == "PotionGen")
            {
                potionGenList.Add(tmp.gameObject.GetComponent <GenPosition>());
            }
            else if (tmp.tag == "CoinGen")
            {
                coinGenList.Add(tmp.gameObject.GetComponent <GenPosition>());
            }
        }

        return(b);
    }