ResPathUtil.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using YooAsset;
  2. namespace GFGGame
  3. {
  4. public class ResPathUtil
  5. {
  6. public const string FONT_DIR_PATH = "Assets/ResIn/Font";
  7. public static readonly string UI_DIR_PATH = "Assets/ResIn/UI";
  8. public static readonly string PREFAB_DIR_PATH = "Assets/ResIn/Prefab";
  9. public static readonly string TEXTURE_FIGHT_DIR_PATH = "Assets/ResIn/Fight";
  10. public static readonly string CONFIG_DIR_PATH = "Assets/Game/CSShare/Sqlite";
  11. public const string RES_ROOT_DIR_PATH = "Assets/Res";
  12. public static readonly string MUSIC_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Music";
  13. public static readonly string SOUND_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Sound";
  14. public static readonly string TEXTURE_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Texture";
  15. public static readonly string ANIMATION_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Animation";
  16. public static readonly string EFFECT_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Effect";
  17. public static readonly string Material_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Material";
  18. public static readonly string Shader_DIR_PATH = $"{RES_ROOT_DIR_PATH}/Shader";
  19. public static readonly string Model_DIR_PATH = $"{RES_ROOT_DIR_PATH}/model";
  20. public static readonly string SQLITE_FILE_PATH = CONFIG_DIR_PATH + "/" + LauncherConfig.SQL_FILE_NAME;
  21. public static string GetUIPackagePath(string res)
  22. {
  23. return $"{UI_DIR_PATH}/{res}/{res}";
  24. }
  25. public static string GetScorePath(int score)
  26. {
  27. return GetCommonGameResPath("kp_sx_" + score);
  28. }
  29. public static string GetCommonGameResPath(string res)
  30. {
  31. return "ui://CommonGame/" + res;
  32. }
  33. //===================================↑↑↑UI路径↑↑↑================================
  34. public static string GetIconPath(string res, string extName)
  35. {
  36. if (res.IndexOf("kp_") == 0)
  37. {
  38. return GetCardIconPath(res);
  39. }
  40. return $"{TEXTURE_DIR_PATH}/Icon/{res}.{extName}";
  41. }
  42. public static string GetIconPath(ItemCfg itemCfg)
  43. {
  44. return GetIconPath(itemCfg.res, ItemUtil.GetItemResExt(itemCfg.itemType, itemCfg.subType, true));
  45. }
  46. public static string GetBgImgPath(string res, string extName = "png")
  47. {
  48. return $"{TEXTURE_DIR_PATH}/BgImg/{res}.{extName}";
  49. }
  50. public static string GetFightBgImgPath(string res, string extName = "png")
  51. {
  52. return $"{TEXTURE_FIGHT_DIR_PATH}/{res}.{extName}";
  53. }
  54. public static string GetSceneBgPath(string res, string extName = "jpg")
  55. {
  56. return $"{TEXTURE_DIR_PATH}/SceneBg/{res}.{extName}";
  57. }
  58. public static string GetDressUpPath(ItemCfg itemCfg, int layerId)
  59. {
  60. string res = GetDressUpItemLayerRes(itemCfg, layerId);
  61. if(itemCfg.subType == ConstDressUpItemType.BEI_JING)
  62. {
  63. return GetSceneBgPath(res);
  64. }
  65. return GetDressUpPath(res);
  66. }
  67. public static string GetDressUpPath(string res, string extName = "png")
  68. {
  69. return $"{TEXTURE_DIR_PATH}/DressUp/{res}.{extName}";
  70. }
  71. public static string GetNpcPicSPath(string res, string extName = "png")
  72. {
  73. return $"{TEXTURE_DIR_PATH}/Npc/PicS/{res}.{extName}";
  74. }
  75. public static string GetNpcPicFPath(string res, string extName = "png")
  76. {
  77. return $"{TEXTURE_DIR_PATH}/Npc/PicF/{res}.{extName}";
  78. }
  79. public static string GetPhotographBorderPath(string res, string extName = "png")
  80. {
  81. return $"{TEXTURE_DIR_PATH}/Photograph/border/{res}.{extName}";
  82. }
  83. public static string GetFieldGuideIconPath(string res, string extName = "png")
  84. {
  85. return $"{TEXTURE_DIR_PATH}/FieldGuide/SuitIcon/{res}.{extName}";
  86. }
  87. public static string GetChapterGuideIconPath(string res, string extName = "png")
  88. {
  89. return $"{TEXTURE_DIR_PATH}/FieldGuide/ChapterIcon/{res}.{extName}";
  90. }
  91. public static string GetNpcHeadPath(string res, string extName = "png")
  92. {
  93. return $"{TEXTURE_DIR_PATH}/Npc/Head/{res}.{extName}";
  94. }
  95. public static string GetCardPath(string res, string extName = "jpg")
  96. {
  97. return $"{TEXTURE_DIR_PATH}/Card/Bg/{res}.{extName}";
  98. }
  99. public static string GetCardIconPath(string res, string extName = "jpg")
  100. {
  101. return $"{TEXTURE_DIR_PATH}/Card/Card/{res}.{extName}";
  102. }
  103. public static string GetCardSkillPath(string res, string extName = "png")
  104. {
  105. return $"{TEXTURE_DIR_PATH}/Card/Skill/{res}.{extName}";
  106. }
  107. public static string GetCardSoundPath(string res, string extName = "mp3")
  108. {
  109. return $"{SOUND_DIR_PATH}/Card/{res}.{extName}";
  110. }
  111. public static string GetMusicPath(string res, string extName = "mp3")
  112. {
  113. return $"{MUSIC_DIR_PATH}/{res}.{extName}";
  114. }
  115. public static string GetFontPath(string res, string extName = "TTF")
  116. {
  117. return $"{FONT_DIR_PATH}/{res}.{extName}";
  118. }
  119. public static string GetPrefabPath(string res, string extName = "prefab")
  120. {
  121. return $"{PREFAB_DIR_PATH}/{res}.{extName}";
  122. }
  123. public static string GetDressUpAnimationDirPath(string res)
  124. {
  125. return $"{ANIMATION_DIR_PATH}/DressUp/{res}";
  126. }
  127. public static string GetDressUpAnimationPath(string res, string extName = "prefab")
  128. {
  129. return $"{GetDressUpAnimationDirPath(res)}/{res}.{extName}";
  130. }
  131. public static bool CheckDressUpAnimationResExist(string res, string extName = "prefab")
  132. {
  133. if (string.IsNullOrEmpty(res))
  134. {
  135. return false;
  136. }
  137. string resPath = ResPathUtil.GetDressUpAnimationPath(res, extName);
  138. return YooAssets.CheckDressUpResExist(resPath);
  139. }
  140. public static string GetDressUpEffectDirPath(string res)
  141. {
  142. return $"{EFFECT_DIR_PATH}/DressUp/{res}";
  143. }
  144. public static string GetDressUpEffectPath(string res, bool inAniDir = false, string extName = "prefab")
  145. {
  146. if (inAniDir)
  147. {
  148. return $"{GetDressUpEffectDirPath(res)}/{res}_2.{extName}";
  149. }
  150. return $"{GetDressUpEffectDirPath(res)}/{res}.{extName}";
  151. }
  152. public static string GetViewEffectPath(string uiName, string resName, string extName = "prefab")
  153. {
  154. return $"{EFFECT_DIR_PATH}/UI/{uiName}/{resName}.{extName}";
  155. }
  156. public static string GetCardAnimationPath(string res, string extName = "prefab")
  157. {
  158. return $"{ANIMATION_DIR_PATH}/Card/{res}/{res}.{extName}";
  159. }
  160. public static string GetActivityPath(string res, string extName = "jpg")
  161. {
  162. return $"{TEXTURE_DIR_PATH}/Activity/Activity/{res}.{extName}";
  163. }
  164. public static string GetActivityShow1Path(string res, string extName = "jpg")
  165. {
  166. return $"{TEXTURE_DIR_PATH}/Activity/Show1/{res}.{extName}";
  167. }
  168. public static string GetActivityShow2Path(string res, string extName = "jpg")
  169. {
  170. return $"{TEXTURE_DIR_PATH}/Activity/Show1/{res}.{extName}";
  171. }
  172. public static string GetTravelBgPath(string res, string extName = "png")
  173. {
  174. return $"{TEXTURE_DIR_PATH}/Travel/Bg/{res}.{extName}";
  175. }
  176. public static string GetTravelRolePath(string res, string extName = "png")
  177. {
  178. return $"{TEXTURE_DIR_PATH}/Travel/Role/{res}.{extName}";
  179. }
  180. public static string GetHeadPath(string res, string extName = "png")
  181. {
  182. return $"{TEXTURE_DIR_PATH}/Head/Head/{res}.{extName}";
  183. }
  184. public static string GetHeadBorderPath(string res, string extName = "png")
  185. {
  186. if (string.IsNullOrEmpty(res)) return "";
  187. return $"{TEXTURE_DIR_PATH}/Head/HeadBorder/{res}.{extName}";
  188. }
  189. public static string GetShaderPath(string res)
  190. {
  191. return $"{Shader_DIR_PATH}/{res}.shader";
  192. }
  193. public static string GetLeagueIconPath(string res, string extName = "png")
  194. {
  195. return $"{TEXTURE_DIR_PATH}/LeagueIcon/{res}.{extName}";
  196. }
  197. public static string GetDressUpItemLayerRes(ItemCfg itemCfg, int layerId)
  198. {
  199. string res = itemCfg.res;
  200. switch (layerId)
  201. {
  202. case 1:
  203. res = itemCfg.resLayer1 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer1);
  204. break;
  205. case 2:
  206. res = itemCfg.resLayer2 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer2);
  207. break;
  208. case 3:
  209. res = itemCfg.resLayer3 == "n" ? res : string.Format("{0}_{1}", res, itemCfg.resLayer3);
  210. break;
  211. }
  212. return res;
  213. }
  214. }
  215. }