コード例 #1
0
    /// <summary>
    /// 스냅기능을 위해 바닥에 변경사항이 생길 때마다 Dot 리스트를 갱신해주는 함수.
    /// </summary>
    /// <param name="floor"></param>
    private void RefreshDots(GameObject floor)
    {
        snapDots        = new List <Dot>();
        roomContainsDot = new Dictionary <Dot, Transform>();
        xRightDots      = new List <Dot>();
        xLeftDots       = new List <Dot>();
        yUpDots         = new List <Dot>();
        yDownDots       = new List <Dot>();
        Outliner   outliner    = new Outliner();
        List <Dot> tempOutLine = new List <Dot>();


        for (int i = 0; i < Model.Instance.Room.Rooms.Count; i++)
        {
            List <Transform> floors = new List <Transform>();
            for (int j = 0; j < Model.Instance.Room.Rooms[i].childCount; j++)
            {
                if (floor != Model.Instance.Room.Rooms[i].GetChild(j).gameObject)
                {
                    floors.Add(Model.Instance.Room.Rooms[i].GetChild(j));
                }
            }

            if (floors.Count > 0)
            {
                tempOutLine = outliner.FindOutline(floors);
                snapDots.AddRange(tempOutLine);

                for (int k = 0; k < tempOutLine.Count; k++)
                {
                    try
                    {
                        roomContainsDot.Add(tempOutLine[k], Model.Instance.Room.Rooms[i]);
                    }
                    catch (Exception e)
                    {
                        Debug.Log(e.Message);
                    }
                }
            }
        }

        Floor tempfloor = Util.ConvertFloorToFloor(floor.transform);

        // 바닥에서 4방향으로 나누고, 해당 부분을 리스트로 따로 담음.
        xRightDots = snapDots.FindAll(x => (x.diretion == Direction.Down ||
                                            x.diretion == Direction.Right && x.attribute == "Cross" ||
                                            x.diretion == Direction.Left && x.attribute == "Corner"));

        xLeftDots = snapDots.FindAll(x => (x.diretion == Direction.Up ||
                                           x.diretion == Direction.Left && x.attribute == "Cross" ||
                                           x.diretion == Direction.Right && x.attribute == "Corner"));

        yUpDots = snapDots.FindAll(x => (x.diretion == Direction.Right ||
                                         x.diretion == Direction.Up && x.attribute == "Cross" ||
                                         x.diretion == Direction.Down && x.attribute == "Corner"));

        yDownDots = snapDots.FindAll(x => (x.diretion == Direction.Left ||
                                           x.diretion == Direction.Down && x.attribute == "Cross" ||
                                           x.diretion == Direction.Up && x.attribute == "Corner"));

        if (isDebugMode)
        {
            Debug.Log("---DotListCount---");
            Debug.Log("xRightDots : " + xRightDots.Count);
            Debug.Log("xLeftDots : " + xLeftDots.Count);
            Debug.Log("yUpDots : " + yUpDots.Count);
            Debug.Log("yDownDots : " + yDownDots.Count);
            Debug.Log("------------------");
        }
    }