예제 #1
0
    float GetLoadPrograss()
    {
        // 로드할 파일이 없으면 100프로지~
        if (false == IsReMainLoadFiles())
        {
            return(100.0f);
        }

        float iProgress = 0.0f;

        SHUtils.ForToDic <string, SHLoadStartInfo>(m_pPrograss.LoadingFiles, (pKey, pValue) =>
        {
            if (true == m_pPrograss.IsDone(pKey))
            {
                return;
            }

            iProgress += pValue.GetPrograss();
        });

        SHPair <int, int> pCountInfo       = m_pPrograss.GetCountInfo();
        float             fCountGap        = SHMath.Divide(100.0f, pCountInfo.Value1);
        float             fComplatePercent = (fCountGap * pCountInfo.Value2);
        float             fProgressPercent = (fCountGap * iProgress);

        return(fComplatePercent + fProgressPercent);
    }
예제 #2
0
    // 인터페이스 : 프리팹에 종속이 걸린 원본리소스 리스트 얻기
    public List <string> GetDependency(string strPrefabPath)
    {
        string strExtension = Path.GetExtension(strPrefabPath);

        if (".prefab" != strExtension.ToLower())
        {
            return(null);
        }

        if (0 == m_dicGUID.Count)
        {
            ReadyGUID();
        }

        var pResult   = new List <string>();
        var strPrefab = SHUtils.ReadFile(strPrefabPath);

        SHUtils.ForToDic(m_dicGUID, (pKey, pValue) =>
        {
            int iIndex = strPrefab.IndexOf(pValue);
            if (-1 == iIndex)
            {
                return;
            }

            pResult.Add(pKey);
        });

        return((0 == pResult.Count) ? null : pResult);
    }
예제 #3
0
    // 인터페이스 : 리소스 리스트를 Json형태로 쓰기
    public static void SaveToResources(Dictionary <string, SHResourcesTableInfo> dicTable, string strSaveFilePath)
    {
        if (0 == dicTable.Count)
        {
            return;
        }

        string strNewLine = "\r\n";
        string strBuff    = "{" + strNewLine;

        // 테이블별 내용작성
        strBuff += string.Format("\t\"{0}\": [{1}", "ResourcesList", strNewLine);
        SHUtils.ForToDic(dicTable, (pKey, pValue) =>
        {
            strBuff += "\t\t{" + strNewLine;
            strBuff += SHResourcesLister.MakeSaveFormat(pValue, "\t\t");
            strBuff += "\t\t}," + strNewLine;
        });
        strBuff  = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);
        strBuff += string.Format("\t]{0}", strNewLine);
        strBuff += "}";

        // 저장
        SHUtils.SaveFile(strBuff, strSaveFilePath);
    }
예제 #4
0
 public override void OnFinalize()
 {
     SHUtils.ForToDic(m_dicDamages, (pKey, pValue) =>
     {
         ReturnDamage(pValue);
     });
     m_dicDamages.Clear();
 }
예제 #5
0
 void ClearChannel <T1, T2>(Dictionary <T1, T2> dicChannel) where T2 : UnityEngine.Object
 {
     SHUtils.ForToDic(dicChannel, (pKey, pValue) =>
     {
         GameObject.DestroyObject(pValue);
     });
     dicChannel.Clear();
 }
예제 #6
0
 void OnUpdateDamage()
 {
     SHUtils.ForToDic(m_dicDamages, (pKey, pValue) =>
     {
         pValue.OnFrameMove();
         CheckCollision(pValue);
     });
 }
예제 #7
0
    // 유틸 : 번들 패킹 시작 및 아웃풋
    static bool MakeAssetBundle(BuildTarget eTarget, string strOutputPath, Dictionary <string, AssetBundleInfo> dicBundles)
    {
        // 디렉토리 정리
        SHUtils.DeleteDirectory(strOutputPath);
        SHUtils.CreateDirectory(strOutputPath);

        // 번들 빌드 정보 만들기
        List <AssetBundleBuild> pBuildList = new List <AssetBundleBuild>();

        SHUtils.ForToDic(dicBundles, (pKey, pValue) =>
        {
            List <string> pAssets = new List <string>();
            SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) =>
            {
                pAssets.Add(string.Format("{0}/{1}{2}", "Assets/Resources", pResValue.m_strPath, pResValue.m_strExtension));
            });

            AssetBundleBuild pAssetInfo = new AssetBundleBuild();
            pAssetInfo.assetBundleName  = string.Format("{0}.unity3d", pValue.m_strBundleName);
            pAssetInfo.assetNames       = pAssets.ToArray();
            pBuildList.Add(pAssetInfo);
        });

        // 빌드할 번들이 없으면 종료
        if (0 == pBuildList.Count)
        {
            return(true);
        }

        // 번들 빌드하기
        AssetBundleManifest pManifest = BuildPipeline.BuildAssetBundles(strOutputPath, pBuildList.ToArray(), BuildAssetBundleOptions.DeterministicAssetBundle, eTarget);

        if (null == pManifest)
        {
            Debug.LogErrorFormat("Error!!! Make Assets Bundle : {0}", strOutputPath);
            return(false);
        }

        // 후 처리
        SHUtils.ForToList(pBuildList, (pBundle) =>
        {
            // 번들 크기와 해시코드 기록
            string strKey = pBundle.assetBundleName.Substring(0, pBundle.assetBundleName.Length - ".unity3d".Length).ToLower();
            if (true == dicBundles.ContainsKey(strKey))
            {
                dicBundles[strKey].m_pHash128    = pManifest.GetAssetBundleHash(pBundle.assetBundleName);
                dicBundles[strKey].m_lBundleSize = (new FileInfo(string.Format("{0}/{1}", strOutputPath, pBundle.assetBundleName))).Length;
            }

            // Manifest제거 ( 사용하지 않는 불필요한 파일이라 그냥 제거시킴 )
            SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, pBundle.assetBundleName));
        });
        SHUtils.DeleteFile(string.Format("{0}/{1}", strOutputPath, SHHard.GetStrToPlatform(eTarget)));
        SHUtils.DeleteFile(string.Format("{0}/{1}.manifest", strOutputPath, SHHard.GetStrToPlatform(eTarget)));

        return(true);
    }
예제 #8
0
    public override void OnFinalize()
    {
        SHUtils.ForToDic(m_dicBundles, (pKey, pValue) =>
        {
            pValue.m_pBundle.Unload(false);
        });

        m_dicBundles.Clear();
    }
예제 #9
0
    private void ForItemInactives(Action <SHObjectInfo> pCallback)
    {
        if (null == pCallback)
        {
            return;
        }

        SHUtils.ForToDic(m_dicInactives, (pKey, pValue) =>
        {
            SHUtils.ForToList(pValue, (pItem) => pCallback(pItem));
        });
    }
예제 #10
0
    // 유틸 : 원본 리소스 모두 제거
    static void DeleteOriginalResource(SHTableData pTableData)
    {
        var pBundleInfo = GetBundleTable(pTableData);

        SHUtils.ForToDic(pBundleInfo.GetContainer(), (pKey, pValue) =>
        {
            SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) =>
            {
                SHUtils.DeleteFile(string.Format("{0}/{1}{2}", SHPath.GetPathToResources(), pResValue.m_strPath, pResValue.m_strExtension));
                SHUtils.DeleteFile(string.Format("{0}/{1}{2}", SHPath.GetPathToResources(), pResValue.m_strPath, ".meta"));
            });
        });
    }
예제 #11
0
    void DestoryPanel(Dictionary <string, SHUIBasePanel> dicPanels)
    {
        if (null == dicPanels)
        {
            return;
        }

        SHUtils.ForToDic(new DicPanels(dicPanels), (pKey, pValue) =>
        {
            DestroyPanel(pValue);
            m_dicPanels.Remove(pKey);
        });
    }
예제 #12
0
    // 인터페이스 : 바이트파일 컨버터 ( 전달된 TableData를 참조해서 전달된 저장경로에 쏟아 냄 )
    public void ConvertByteFiles(SHTableData pTableData, string strSavePath)
    {
        if (null == pTableData)
        {
            return;
        }

        SHUtils.ForToDic(pTableData.Tables, (pKey, pValue) =>
        {
            ConvertByteFile(pValue, strSavePath);
        });

        Debug.Log("<color=yellow>ConvertByteFiles Finish!!!</color>");
    }
예제 #13
0
    private void ClearAll()
    {
        SHUtils.ForToDic(m_dicActives, (pKey, pValue) =>
        {
            SHUtils.ForToList(pValue, (pObject) => pObject.DestroyObject());
        });
        SHUtils.ForToDic(m_dicInactives, (pKey, pValue) =>
        {
            SHUtils.ForToList(pValue, (pObject) => pObject.DestroyObject());
        });

        m_dicActives.Clear();
        m_dicInactives.Clear();
    }
예제 #14
0
    void OnDelUnits()
    {
        SHUtils.ForToDic(m_dicDelUnits, (pKey, pValue) =>
        {
            if (false == m_dicUnits.ContainsKey(pKey))
            {
                return;
            }

            SHUtils.ForToList(pValue, (pUnit) =>
                              { m_dicUnits[pKey].Remove(pUnit); });
        });
        m_dicDelUnits.Clear();
    }
예제 #15
0
    void OnDelDamage()
    {
        SHUtils.ForToDic(m_dicDelDamages, (pKey, pValue) =>
        {
            if (false == m_dicDamages.ContainsKey(pKey))
            {
                return;
            }

            ReturnDamage(pValue);
            m_dicDamages.Remove(pKey);
        });
        m_dicDelDamages.Clear();
    }
예제 #16
0
    // 인터페이스 : 번들 리스트를 Json형태로 번들정보파일포맷으로 쓰기
    public static void SaveToAssetBundleInfo(Dictionary <string, AssetBundleInfo> dicTable, string strSaveFilePath)
    {
        if (0 == dicTable.Count)
        {
            return;
        }

        string strNewLine = "\r\n";
        string strBuff    = "{" + strNewLine;

        // 테이블별 내용작성
        strBuff += string.Format("\t\"{0}\": [{1}", "AssetBundleInfo", strNewLine);
        SHUtils.ForToDic(dicTable, (pKey, pValue) =>
        {
            strBuff += "\t\t{" + strNewLine;

            strBuff += string.Format("\t\t\t\"s_BundleName\": \"{0}\",{1}",
                                     pValue.m_strBundleName,
                                     strNewLine);

            strBuff += string.Format("\t\t\t\"s_BundleSize\": \"{0}\",{1}",
                                     pValue.m_lBundleSize,
                                     strNewLine);

            strBuff += string.Format("\t\t\t\"s_BundleHash\": \"{0}\",{1}",
                                     pValue.m_pHash128.ToString(),
                                     strNewLine);

            strBuff += string.Format("\t\t\t\"p_Resources\": {0}", strNewLine);
            strBuff += "\t\t\t[" + strNewLine;

            SHUtils.ForToDic(pValue.m_dicResources, (pResKey, pResValue) =>
            {
                strBuff += "\t\t\t\t{" + strNewLine;
                strBuff += MakeSaveFormat(pResValue, "\t\t\t\t");
                strBuff += "\t\t\t\t}," + strNewLine;
            });
            strBuff = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);

            strBuff += "\t\t\t]" + strNewLine;
            strBuff += "\t\t}," + strNewLine;
        });
        strBuff  = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);
        strBuff += string.Format("\t]{0}", strNewLine);
        strBuff += "}";

        // 저장
        SHUtils.SaveFile(strBuff, strSaveFilePath);
    }
예제 #17
0
 void OnAddDamage()
 {
     SHUtils.ForToDic(m_dicAddDamages, (pKey, pValue) =>
     {
         if (true == m_dicDamages.ContainsKey(pKey))
         {
             pValue.SetActive(false);
         }
         else
         {
             m_dicDamages.Add(pKey, pValue);
         }
     });
     m_dicAddDamages.Clear();
 }
예제 #18
0
    public void OnEventToChangeScene(eSceneType eCurrentScene, eSceneType eNextScene)
    {
        var pDestroyPanels = new DicPanels();

        SHUtils.ForToDic(m_dicPanels, (pKey, pValue) =>
        {
            if (eObjectDestoryType.ChangeScene != pValue.m_eDestroyType)
            {
                return;
            }

            pDestroyPanels.Add(pKey, pValue);
        });

        DestoryPanel(pDestroyPanels);
    }
예제 #19
0
    public List <eMonsterType> GetEnableMonstersForDic()
    {
        var pResult = new List <eMonsterType>();

        SHUtils.ForToDic(m_dicMonsterInfo, (pKey, pValue) =>
        {
            if (eGoodsState.Enable != pValue)
            {
                return;
            }

            pResult.Add(pKey);
        });

        return(pResult);
    }
예제 #20
0
    public void SaveLoadResourceList()
    {
        string strBuff = string.Empty;
        SHUtils.ForToDic(m_dicRealLoadInfo, (pKey, pValue) =>
        {
            strBuff += string.Format("Scene : {0}\n", pKey);
            SHUtils.ForToList(pValue, (pInfo) =>
            {
                strBuff += string.Format("\t{0}\n", pInfo);
            });
        });

        string strSavePath = string.Format("{0}/{1}", SHPath.GetPathToAssets(), "RealTimeLoadResource.txt");
        SHUtils.SaveFile(strBuff, strSavePath);
        System.Diagnostics.Process.Start(strSavePath);
    }
예제 #21
0
    // 인터페이스 : 번들 리스트 얻기( 리소스 테이블과 비교 : 번들파일크기, 리소스 파일크기/해시코드 )
    public Dictionary <string, AssetBundleInfo> GetBundleListToCompare(JsonResourcesTable pResourceInfo)
    {
        var dicBundleInfo = GetContainer();

        if (null == pResourceInfo)
        {
            return(dicBundleInfo);
        }

        var pResult = new Dictionary <string, AssetBundleInfo>();

        SHUtils.ForToDic(dicBundleInfo, (pBundleKey, pBundleValue) =>
        {
            // 체크 : 번들파일크기
            if (0 == pBundleValue.m_lBundleSize)
            {
                pResult.Add(pBundleKey, pBundleValue);
                return;
            }

            // 체크 : 추가/제거/변경된 리소스(존재확인/파일크기/해시코드)
            SHUtils.ForToDic(pBundleValue.m_dicResources, (pResKey, pResValue) =>
            {
                var pResourceUnit = pResourceInfo.GetResouceInfo(pResValue.m_strName);

                // 제거된 리소스 확인
                if (null == pResourceUnit)
                {
                    var pCopyInfo = new AssetBundleInfo(pBundleValue);
                    pCopyInfo.DelResourceInfo(pResValue.m_strName);
                    pResult.Add(pBundleKey, pCopyInfo);
                    return;
                }

                // 추가 및 변경된 리소스 확인
                if ((pResourceUnit.m_strSize != pResValue.m_strSize) ||
                    (pResourceUnit.m_strHash != pResValue.m_strHash))
                {
                    pResult.Add(pBundleKey, pBundleValue);
                    return;
                }
            });
        });

        return(pResult);
    }
예제 #22
0
    // 인터페이스 : 타입에 해당하는 리소스 정보 리스트 얻기
    public List <SHResourcesTableInfo> GetResourceInfoByType(eResourceType eType)
    {
        if (false == IsLoadTable())
        {
            LoadJson(m_strFileName);
        }

        var pList = new List <SHResourcesTableInfo>();

        SHUtils.ForToDic(m_pData, (pKey, pValue) =>
        {
            if (eType == pValue.m_eResourceType)
            {
                pList.Add(pValue);
            }
        });

        return(pList);
    }
예제 #23
0
    public override Dictionary <string, SHLoadData> GetLoadList(eSceneType eType)
    {
        var dicLoadList = new Dictionary <string, SHLoadData>();

        // 로컬 테이블 데이터
        SHUtils.ForToDic <Type, SHBaseTable>(m_dicTables,
                                             (pKey, pValue) =>
        {
            // 이미 로드된 데이터인지 체크
            if (true == pValue.IsLoadTable())
            {
                return;
            }

            dicLoadList.Add(pValue.m_strFileName, CreateLoadInfo(pValue.m_strFileName));
        });

        return(dicLoadList);
    }
예제 #24
0
    void OnAddUnits()
    {
        SHUtils.ForToDic(m_dicAddUnits, (pKey, pValue) =>
        {
            if (false == m_dicUnits.ContainsKey(pKey))
            {
                m_dicUnits.Add(pKey, new List <SHMonoWrapper>());
            }

            SHUtils.ForToList(pValue, (pUnit) =>
            {
                if (true == m_dicUnits[pKey].Contains(pUnit))
                {
                    return;
                }

                m_dicUnits[pKey].Add(pUnit);
            });
        });
        m_dicAddUnits.Clear();
    }
예제 #25
0
    // 유틸 : 번들정보 스크립트 아웃풋
    static void UpdateBundleInfoTable(BuildTarget eTarget, SHTableData pTableData, Dictionary <string, AssetBundleInfo> dicMakeBundles, string strOutputPath)
    {
        var pBundleTable   = GetBundleTable(pTableData);
        var pResourceTable = GetResourceTable(pTableData);

        SHUtils.ForToDic(dicMakeBundles, (pKey, pValue) =>
        {
            AssetBundleInfo pData = pBundleTable.GetBundleInfo(pValue.m_strBundleName);
            pData.m_lBundleSize   = pValue.m_lBundleSize;
            pData.m_pHash128      = pValue.m_pHash128;
            pData.CopyResourceInfo(pValue.m_dicResources);

            SHUtils.ForToDic(pData.m_dicResources, (pResKey, pResValue) =>
            {
                pResValue.CopyTo(pResourceTable.GetResouceInfo(pResKey));
            });
        });

        pBundleTable.SaveJsonFileByDic(
            string.Format("{0}/{1}.json", strOutputPath, pBundleTable.m_strFileName));
    }
예제 #26
0
    public override Dictionary <string, SHLoadData> GetPatchList()
    {
        var dicLoadList = new Dictionary <string, SHLoadData>();

        // 서버정보파일(ServerConfiguration.json)에 URL이 없으면 패치하지 않는다.
        if (true == string.IsNullOrEmpty(SHPath.GetURLToBundleCDN()))
        {
            return(dicLoadList);
        }

        SHUtils.ForToDic(Single.Table.GetAssetBundleInfo(), (pKey, pValue) =>
        {
            if (true == IsExist(pKey))
            {
                return;
            }

            dicLoadList.Add(pKey, CreatePatchInfo(pValue));
        });

        return(dicLoadList);
    }
예제 #27
0
    // 인터페이스 : 중복파일 리스트 내보내기
    public static void SaveToDuplicationList(Dictionary <string, List <string> > dicDuplications, string strSaveFilePath)
    {
        if (0 == dicDuplications.Count)
        {
            return;
        }

        string strNewLine = "\r\n";
        string strBuff    = string.Empty;

        SHUtils.ForToDic(dicDuplications, (pKey, pValue) =>
        {
            strBuff += string.Format("FileName : {0}{1}", pKey, strNewLine);
            SHUtils.ForToList(pValue, (strPath) =>
            {
                strBuff += string.Format("\tPath : Resources/{0}{1}", strPath, strNewLine);
            });
            strBuff += string.Format("{0}", strNewLine);
        });

        SHUtils.SaveFile(strBuff, strSaveFilePath);
    }
예제 #28
0
    public void AddLoadInfo(Dictionary <string, SHLoadData> dicLoadList)
    {
        SHUtils.ForToDic(dicLoadList, (pKey, pValue) =>
        {
            // 무결성체크
            if (null == pValue)
            {
                return;
            }

            // 중복파일체크
            SHLoadData pLoadData = GetLoadDataInfo(pValue.m_strName);
            if (null != pLoadData)
            {
                Debug.LogError(string.Format("중복파일 발견!!!(FileName : {0})", pValue.m_strName));
                return;
            }

            // 초기화 및 등록
            SetLoadData(pValue);
            m_pLoadCount.Value1++;
        });
    }
예제 #29
0
    // 인터페이스 : DataSet을 Json으로 쓰기
    public void Write(string strFileName, Dictionary <string, List <SHTableDataSet> > dicData)
    {
        #if UNITY_EDITOR
        if (null == dicData)
        {
            Debug.LogError(string.Format("Json으로 저장할 데이터가 없습니다!!"));
            return;
        }

        string strNewLine = "\r\n";
        string strBuff    = "{" + strNewLine;
        SHUtils.ForToDic(dicData, (pKey, pValue) =>
        {
            strBuff += string.Format("\t\"{0}\": [{1}", pKey, strNewLine);
            SHUtils.ForToList(pValue, (pData) =>
            {
                strBuff += "\t\t{" + strNewLine;
                SHUtils.For(0, pData.m_iMaxCol, (iCol) =>
                {
                    strBuff += string.Format("\t\t\t\"{0}\": {1},{2}",
                                             pData.m_ColumnNames[iCol],
                                             pData.m_pDatas[iCol],
                                             strNewLine);
                });
                strBuff  = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);
                strBuff += "\t\t}," + strNewLine;
            });
            strBuff  = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);
            strBuff += string.Format("\t],{0}", strNewLine);
        });
        strBuff  = string.Format("{0}{1}", strBuff.Substring(0, strBuff.Length - (strNewLine.Length + 1)), strNewLine);
        strBuff += "}";

        SHUtils.SaveFile(strBuff, string.Format("{0}/{1}.json", SHPath.GetPathToJson(), Path.GetFileNameWithoutExtension(strFileName)));
        #endif
    }
예제 #30
0
    public void Write(string strFileName, Dictionary <string, List <SHTableDataSet> > dicData)
    {
        if (null == dicData)
        {
            Debug.LogError(string.Format("SQLite로 저장할 데이터가 없습니다!!"));
            return;
        }

        string strSavePath = string.Format("{0}/{1}.db", SHPath.GetPathToSQLite(), Path.GetFileNameWithoutExtension(strFileName));

        File.Delete(strSavePath);

        try
        {
            m_pSQLiteDB = new SQLiteDB();
            m_pSQLiteDB.Open(strSavePath);
            SHUtils.ForToDic(dicData, (pKey, pValue) =>
            {
                // 테이블 생성
                if (false == CreateTable(pKey, pValue[0]))
                {
                    return;
                }

                // 생성한 테이블에 데이터 인설트
                if (false == InsertData(pKey, pValue))
                {
                    return;
                }
            });
        }
        catch (System.Exception e)
        {
            Debug.LogError(string.Format("SQLite Read Fail : {0}", e.ToString()));
        }
    }