Exemplo n.º 1
0
    // 단어가 겹치는지 체크
    void SetRootPos()
    {
        // 생성전에 생성될 위치에 자리가 있는지 확인
        var templist = new List <GameObject>();

        templist.AddRange(GameObject.FindGameObjectsWithTag("Vertical"));
        templist.AddRange(GameObject.FindGameObjectsWithTag("Horizontal"));

#pragma warning disable CS0162 // 접근할 수 없는 코드가 있습니다.
        for (int index = 0; index < templist.Count; index++)
        {
            // 생성된 Grid를 가져온다.
            QuaterSection Section = new QuaterSection();

            for (int j = 0; j < templist.Count; j++)
            {
                // 1분면 ( - , + )
                if (templist[j].transform.localPosition.x < 0 && templist[j].transform.localPosition.y > 0)
                {
                    Section.Section1++;
                }

                // 2분면 ( - , - )
                if (templist[j].transform.localPosition.x < 0 && templist[j].transform.localPosition.y < 0)
                {
                    Section.Section2++;
                }

                // 3분면 ( + , - )
                if (templist[j].transform.localPosition.x > 0 && templist[j].transform.localPosition.y < 0)
                {
                    Section.Section3++;
                }

                // 4분면 ( + , + )
                if (templist[j].transform.localPosition.x > 0 && templist[j].transform.localPosition.y > 0)
                {
                    Section.Section4++;
                }
            }

            // 가장 적게 생성된면을 불러온다.
            var num = Section.DisRank();
            //Debug.Log(num + " 분면에 가장 적은 단어가 생성되었습니다.");

            if (m_RootSet >= MaxX / 100)
            {
                m_bIsMake = true;
                Debug.LogWarning("더 이상 루트를 생성 할 수 없습니다.");
                return;
            }
            // 가장 적게 생성된면의 랜덤으로 좌표를 구한다.
            MakeX = Section.GetX(num, m_RootSet);
            MakeY = Section.GetY(num, m_RootSet);
            m_RootSet++;
            return;
        }
    }
Exemplo n.º 2
0
    // 단어가 겹치는지 체크
    void SetRootPos()
    {
        // 생성전에 생성될 위치에 자리가 있는지 확인
        var templist = new List <GameObject>();

        templist.AddRange(GameObject.FindGameObjectsWithTag("Vertical"));
        templist.AddRange(GameObject.FindGameObjectsWithTag("Horizontal"));

        for (int i = 0; i < templist.Count; i++)
        {
            // 생성된 Grid를 가져온다.
            QuaterSection Section = new QuaterSection();

            for (int j = 0; j < templist.Count; j++)
            {
                // 1분면 ( - , + )
                if (templist[j].transform.localPosition.x < 0 && templist[j].transform.localPosition.y > 0)
                {
                    Section.Section1++;
                }

                // 2분면 ( - , - )
                if (templist[j].transform.localPosition.x < 0 && templist[j].transform.localPosition.y < 0)
                {
                    Section.Section2++;
                }

                // 3분면 ( + , - )
                if (templist[j].transform.localPosition.x > 0 && templist[j].transform.localPosition.y < 0)
                {
                    Section.Section3++;
                }

                // 4분면 ( + , + )
                if (templist[j].transform.localPosition.x > 0 && templist[j].transform.localPosition.y > 0)
                {
                    Section.Section4++;
                }
            }

            // 가장 적게 생성된면을 불러온다.
            var num = Section.DisRank();
            //Debug.Log(num + " 분면에 가장 적은 단어가 생성되었습니다.");

            // 가장 적게 생성된면의 랜덤으로 좌표를 구한다.
            MakeX += Section.GetX(num, Random.Range(-4, 4));
            MakeY += Section.GetY(num, Random.Range(-4, 4));
            return;
        }
    }