Esempio n. 1
0
        /// <summary>
        /// 트랙창고리스트에서 원하는 종류의 트랙타일을 받아오는 메소드 IF 창고안에 비활성화 된 트랙타일이 없을시 생성하여 가져옵니다.
        /// </summary>
        /// <param name="tTrackKind">원하는 트랙의 종류</param>
        /// <returns>원하는 트랙타일을 반환</returns>
        public CTrackTile GetTrackTile(CTrackCreater.TRACKKIND tTrackKind)
        {
            CTrackTile tTile = null;

            if (TrackStorage.ContainsKey(tTrackKind))
            {
                for (int i = 0; i < TrackStorage[tTrackKind].Count; i++)
                {
                    if (TrackStorage[tTrackKind][i].gameObject.activeSelf == false)
                    {
                        tTile = TrackStorage[tTrackKind][i];
                        return(tTile);
                    }
                }

                tTile = GameObject.Instantiate(GetPrefab(tTrackKind), Vector3.zero, Quaternion.identity);
                tTile.gameObject.SetActive(false);
                tTile.transform.SetParent(mTrackParent);
                tTile.SetTrackCreater(mTrackCreater);

                TrackStorage[tTrackKind].Add(tTile);
                return(tTile);
            }

            return(null);
        }
Esempio n. 2
0
        public void InitTrackStorage(Transform tParent, CTrackCreater tTrackCreater)
        {
            mTrackParent  = tParent;
            mTrackCreater = tTrackCreater;

            TrackStorage = new Dictionary <CTrackCreater.TRACKKIND, List <CTrackTile> >();
            var tTrackKinds = System.Enum.GetValues(typeof(CTrackCreater.TRACKKIND)).GetEnumerator();

            while (tTrackKinds.MoveNext())
            {
                CTrackCreater.TRACKKIND tKind = (CTrackCreater.TRACKKIND)tTrackKinds.Current;
                int tCreateCount = 0;

                if (tKind == CTrackCreater.TRACKKIND.START || tKind == CTrackCreater.TRACKKIND.END)
                {
                    tCreateCount = 1;
                }
                else
                {
                    tCreateCount = 5;
                }

                for (int i = 0; i < tCreateCount; i++)
                {
                    if (TrackStorage.ContainsKey(tKind) == false)
                    {
                        TrackStorage.Add(tKind, new List <CTrackTile>());
                    }
                    if (GetPrefab(tKind) == null)
                    {
                        Debug.Log("Prefab is Null");
                    }
                    CTrackTile tTile = GameObject.Instantiate(GetPrefab(tKind), Vector3.zero, Quaternion.identity);
                    tTile.gameObject.SetActive(false);
                    tTile.transform.SetParent(tParent);
                    tTile.SetTrackCreater(mTrackCreater);



                    TrackStorage[tKind].Add(tTile);
                }
            }
        }