CustomManager.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using GameFramework.Event;
  5. using UnityEngine;
  6. using GameFramework.DataTable;
  7. using DG.Tweening;
  8. namespace MetaClient
  9. {
  10. public class CustomManager : MonoBehaviour
  11. {
  12. public static CustomManager Instance;
  13. public RoleCustomData bodyData;
  14. public const float valueFloating = 1f;
  15. public CustomRoleController testPlayer = null;
  16. public Dictionary<string, Transform> bones = new Dictionary<string, Transform>();
  17. private void Awake()
  18. {
  19. Instance = this;
  20. }
  21. public void Init()
  22. {
  23. GameEntry.Event.Subscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  24. CreateCustomBodyData();
  25. }
  26. /// <summary>
  27. /// 生成玩家自定义数据信息
  28. /// </summary>
  29. public void CreateCustomBodyData()
  30. {
  31. testPlayer = GameObject.Find("biaonv").GetComponent<CustomRoleController>();
  32. bodyData = new RoleCustomData();
  33. //初始化身体部分
  34. IDataTable<DRCustomBody> drCB = GameEntry.DataTable.GetDataTable<DRCustomBody>();
  35. DRCustomBody[] dtCB = drCB.GetAllDataRows();
  36. for (int i = 0; i < dtCB.Length; i++)
  37. {
  38. var partData = new PartData(
  39. dtCB[i].Id,
  40. dtCB[i].BoneName.Split(','),
  41. dtCB[i].ScaleRangeMin,
  42. dtCB[i].ScaleRangeMax,
  43. dtCB[i].ScaleChange,
  44. dtCB[i].PositionChange,
  45. dtCB[i].RotationChange,
  46. dtCB[i].IsBlend,
  47. dtCB[i].BiggerBlendName,
  48. dtCB[i].SmallerBlendName,
  49. dtCB[i].DefaultBlendValue,
  50. dtCB[i].ExtraKeepBoneName,
  51. dtCB[i].IsKeepChildrenScale
  52. );
  53. bodyData.bodyList.Add(dtCB[i].Id, partData);
  54. }
  55. //初始化脸部分
  56. IDataTable<DRCustomFace> drCF = GameEntry.DataTable.GetDataTable<DRCustomFace>();
  57. DRCustomFace[] dtCF = drCF.GetAllDataRows();
  58. for (int i = 0; i < dtCF.Length; i++)
  59. {
  60. //颜色替换
  61. if (dtCF[i].BoneName == "Color")
  62. {
  63. bodyData.colorList.Add(dtCF[i].ParentStyple, Vector3.zero);
  64. continue;
  65. }
  66. //图片替换
  67. if (dtCF[i].BoneName == "Sprite")
  68. {
  69. bodyData.spriteList.Add(dtCF[i].ParentStyple, 1);
  70. continue;
  71. }
  72. var partData = new PartData(
  73. dtCF[i].Id,
  74. dtCF[i].BoneName==""?null:dtCF[i].BoneName.Split(','),
  75. dtCF[i].ScaleRangeMin,
  76. dtCF[i].ScaleRangeMax,
  77. dtCF[i].ScaleChange,
  78. dtCF[i].PositionChange,
  79. dtCF[i].RotationChange,
  80. dtCF[i].IsBlend,
  81. dtCF[i].BiggerBlendName,
  82. dtCF[i].SmallerBlendName,
  83. dtCF[i].DefaultBlendValue,
  84. "",
  85. true,
  86. dtCF[i].IsMirror
  87. );
  88. bodyData.faceList.Add(dtCF[i].Id, partData);
  89. }
  90. bones.Clear();
  91. foreach (var item in bodyData.bodyList)
  92. {
  93. var key = item.Key;
  94. var value = item.Value;
  95. if(!value.useBlend)
  96. {
  97. for (int i = 0; i < value.bones.Length; i++)
  98. {
  99. var transform = CustomRoleUtility.GetChild(testPlayer.transform, value.bones[i]);
  100. if (!transform)
  101. {
  102. continue;
  103. }
  104. if (!bones.ContainsKey(value.bones[i]))
  105. {
  106. bones.Add(value.bones[i], transform);
  107. }
  108. }
  109. }
  110. }
  111. foreach (var item in bodyData.faceList)
  112. {
  113. var key = item.Key;
  114. var value = item.Value;
  115. if (!value.useBlend)
  116. {
  117. for (int i = 0; i < value.bones.Length; i++)
  118. {
  119. var transform = CustomRoleUtility.GetChild(testPlayer.transform, value.bones[i]);
  120. if (!transform)
  121. {
  122. continue;
  123. }
  124. if (!bones.ContainsKey(value.bones[i]))
  125. {
  126. bones.Add(value.bones[i], transform);
  127. }
  128. }
  129. }
  130. }
  131. Debug.Log( "一共有"+ bones.Count + "部位的骨骼自定义修改");
  132. //获取自定义骨骼的初始数据
  133. foreach (var item in bones)
  134. {
  135. var key = item.Key;
  136. var value = item.Value;
  137. bodyData.orginLocalScaleList.Add(key, value.localScale);
  138. bodyData.orginChangeScaleList.Add(key, new Vector3(1,1,1));
  139. bodyData.ChangedScaleParamsList.Add(key, new Vector3(1,1,1));
  140. bodyData.orginLocalPositionList.Add(key, value.localPosition);
  141. bodyData.orginLocalRotationList.Add(key, value.localEulerAngles);
  142. }
  143. }
  144. public void Clear()
  145. {
  146. GameEntry.Event.Unsubscribe(CustomRoleBodyEventArgs.EventId, UpdateBody);
  147. }
  148. private void UpdateBody(object sender, GameEventArgs e)
  149. {
  150. CustomRoleBodyEventArgs crf = (CustomRoleBodyEventArgs)e;
  151. if (crf != null)
  152. {
  153. PartData partData = null;
  154. switch (crf.Type)
  155. {
  156. case ECustomStyple.None:
  157. break;
  158. case ECustomStyple.NieLian:
  159. partData = bodyData.faceList[crf.Part];
  160. break;
  161. case ECustomStyple.Body:
  162. partData = bodyData.bodyList[crf.Part];
  163. break;
  164. case ECustomStyple.Cloth:
  165. break;
  166. case ECustomStyple.Ornament:
  167. break;
  168. default:
  169. break;
  170. }
  171. //更新数据
  172. if(partData == null)
  173. {
  174. Debug.LogError("ID :" + crf.Part + " 无数据");
  175. return;
  176. }
  177. if(partData.useBlend)
  178. {
  179. ChangeBlendShape(partData, crf.ChangeValue);
  180. }
  181. else
  182. {
  183. ChangeBone(partData, crf.ChangeValue);
  184. }
  185. }
  186. }
  187. /// <summary>
  188. /// 变形器改变
  189. /// </summary>
  190. /// <param name="partData"></param>
  191. /// <param name="changeValue"></param>
  192. private void ChangeBlendShape(PartData partData, Vector3 changeValue)
  193. {
  194. partData.floatValue = changeValue.x;
  195. Debug.Log(partData.id + " : "+ partData.floatValue);
  196. if(partData.oneBlend)
  197. {
  198. RefreshRoleBlendShape(partData.biggerBlendName, partData.floatValue * 100);
  199. return;
  200. }
  201. if(partData.floatValue == 0.5f)
  202. {
  203. RefreshRoleBlendShape(partData.biggerBlendName, 0);
  204. RefreshRoleBlendShape(partData.smallerBlendName, 0);
  205. }
  206. if(partData.floatValue > 0.5f)
  207. {
  208. RefreshRoleBlendShape(partData.biggerBlendName, (partData.floatValue - 0.5f) * 2 * 100);
  209. RefreshRoleBlendShape(partData.smallerBlendName, 0);
  210. }
  211. if(partData.floatValue < 0.5f)
  212. {
  213. RefreshRoleBlendShape(partData.biggerBlendName, 0);
  214. RefreshRoleBlendShape(partData.smallerBlendName, (0.5f - partData.floatValue) * 2 * 100);
  215. }
  216. }
  217. /// <summary>
  218. /// 骨骼改变
  219. /// </summary>
  220. /// <param name="partData"></param>
  221. /// <param name="changeValue"></param>
  222. private void ChangeBone(PartData partData,Vector3 changeValue)
  223. {
  224. if (partData.scaleChange != Vector3.zero)
  225. {
  226. if (changeValue.x == 0.5f)
  227. {
  228. partData.floatValue = 1;
  229. }
  230. if (changeValue.x < 0.5f)
  231. {
  232. partData.floatValue = partData.minChangeValue + (1 - partData.minChangeValue) * (changeValue.x / 0.5f);
  233. }
  234. if (changeValue.x > 0.5f)
  235. {
  236. partData.floatValue = 1 + (partData.maxChangeValue - 1) * ((changeValue.x - 0.5f) / 0.5f);
  237. }
  238. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  239. for (int i = 0; i < partData.bones.Length; i++)
  240. {
  241. //var orginBoneScale = bodyData.orginWorldScaleList[partData.bones[i]];
  242. var orginBoneScale = bodyData.orginLocalScaleList[partData.bones[i]];
  243. var changeScale = bodyData.orginChangeScaleList[partData.bones[i]];
  244. var bone = bones[partData.bones[i]];
  245. var nowBone = bones[partData.bones[i]];
  246. //var scale = nowBone.lossyScale;
  247. var scale = nowBone.localScale;
  248. var nowScale = new Vector3(scale.x / orginBoneScale.x, scale.y / orginBoneScale.y, scale.z / orginBoneScale.z);
  249. //var newBoneScale = new Vector3(orginBoneScale.x * (partData.scaleChange.x == 1 ? partData.floatValue : 1) * nowScale.x, orginBoneScale.y * (partData.scaleChange.y == 1 ? partData.floatValue : 1) * nowScale.y, orginBoneScale.z * (partData.scaleChange.z == 1 ? partData.floatValue : 1) * nowScale.y);
  250. var newBoneScale = new Vector3(
  251. partData.scaleChange.x == 1 ? partData.floatValue * orginBoneScale.x * changeScale.x : scale.x,
  252. partData.scaleChange.y == 1 ? partData.floatValue * orginBoneScale.y * changeScale.y : scale.y,
  253. partData.scaleChange.z == 1 ? partData.floatValue * orginBoneScale.z * changeScale.z : scale.z
  254. );
  255. bodyData.changedScaleList[partData.bones[i]] = newBoneScale;
  256. bodyData.ChangedScaleParamsList[partData.bones[i]] = new Vector3(newBoneScale.x / orginBoneScale.x / changeScale.x, newBoneScale.y / orginBoneScale.y / changeScale.y, newBoneScale.z / orginBoneScale.z / changeScale.z);
  257. Debug.Log(partData.bones[i] + " : " + bodyData.ChangedScaleParamsList[partData.bones[i]]);
  258. if(!partData.keepChild)
  259. {
  260. continue;
  261. }
  262. //子物体
  263. var count = nowBone.childCount;
  264. for (int j = 0; j < count; j++)
  265. {
  266. var childname = nowBone.GetChild(j).name;
  267. if (bones.ContainsKey(childname))
  268. {
  269. var orginChildBoneScale = bodyData.orginLocalScaleList[childname];
  270. var beforeChildScaleParams = bodyData.ChangedScaleParamsList[childname];
  271. bodyData.orginChangeScaleList[childname] = new Vector3(orginBoneScale.x / newBoneScale.x, orginBoneScale.y / newBoneScale.y, orginBoneScale.z / newBoneScale.z);
  272. bodyData.changedScaleList[childname] = new Vector3(
  273. beforeChildScaleParams.x * bodyData.orginChangeScaleList[childname].x * orginChildBoneScale.x,
  274. beforeChildScaleParams.y * bodyData.orginChangeScaleList[childname].y * orginChildBoneScale.y,
  275. beforeChildScaleParams.z * bodyData.orginChangeScaleList[childname].z * orginChildBoneScale.z
  276. );
  277. Debug.Log( "child ==>" + childname + " : " + orginChildBoneScale + " | " + beforeChildScaleParams + " | " + bodyData.orginChangeScaleList[childname] + " | " + bodyData.changedScaleList[childname]);
  278. }
  279. }
  280. if (partData.extraBones == null || partData.extraBones.Length == 0)
  281. {
  282. continue;
  283. }
  284. for (int j = 0; j < partData.extraBones.Length; j++)
  285. {
  286. var childname = partData.extraBones[j];
  287. if (bones.ContainsKey(childname))
  288. {
  289. var orginChildBoneScale = bodyData.orginLocalScaleList[childname];
  290. var beforeChildScaleParams = bodyData.ChangedScaleParamsList[childname];
  291. bodyData.orginChangeScaleList[childname] = new Vector3(orginBoneScale.x / newBoneScale.x, orginBoneScale.y / newBoneScale.y, orginBoneScale.z / newBoneScale.z);
  292. bodyData.changedScaleList[childname] = new Vector3(
  293. beforeChildScaleParams.x * bodyData.orginChangeScaleList[childname].x * orginChildBoneScale.x,
  294. beforeChildScaleParams.y * bodyData.orginChangeScaleList[childname].y * orginChildBoneScale.y,
  295. beforeChildScaleParams.z * bodyData.orginChangeScaleList[childname].z * orginChildBoneScale.z
  296. );
  297. Debug.Log(childname + " : " + bodyData.ChangedScaleParamsList[childname]);
  298. }
  299. }
  300. }
  301. }
  302. //修改位置
  303. if (partData.positionChange != Vector3.zero)
  304. {
  305. if (changeValue.x == 0.5f)
  306. {
  307. partData.floatValue = 0;
  308. }
  309. if (changeValue.x < 0.5f)
  310. {
  311. partData.floatValue = partData.minChangeValue * (0.5f - changeValue.x) * 2;
  312. }
  313. if (changeValue.x > 0.5f)
  314. {
  315. partData.floatValue = partData.maxChangeValue * (changeValue.x - 0.5f) * 2;
  316. }
  317. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  318. for (int i = 0; i < partData.bones.Length; i++)
  319. {
  320. var nowBone = bones[partData.bones[i]];
  321. var orginBonePosition = bodyData.orginLocalPositionList[partData.bones[i]];
  322. var newBonePosition = new Vector3(
  323. partData.positionChange.x == 1 ? partData.floatValue + orginBonePosition.x : orginBonePosition.x,
  324. partData.positionChange.y == 1 ? partData.floatValue + orginBonePosition.y : orginBonePosition.y,
  325. partData.positionChange.z == 1 ? partData.floatValue + orginBonePosition.z : orginBonePosition.z
  326. );
  327. bodyData.changedPositionList[partData.bones[i]] = newBonePosition;
  328. }
  329. }
  330. //修改旋转
  331. if (partData.rotationChange != Vector3.zero)
  332. {
  333. if (changeValue.x == 0.5f)
  334. {
  335. partData.floatValue = 0;
  336. }
  337. if (changeValue.x < 0.5f)
  338. {
  339. partData.floatValue = partData.minChangeValue * (0.5f - changeValue.x) * 2;
  340. }
  341. if (changeValue.x > 0.5f)
  342. {
  343. partData.floatValue = partData.maxChangeValue * (changeValue.x - 0.5f) * 2;
  344. }
  345. Debug.Log(partData.id + " : " + changeValue + " 转换后 :" + partData.floatValue);
  346. for (int i = 0; i < partData.bones.Length; i++)
  347. {
  348. var changeVal = 1;
  349. if(i == 1 && partData.isMirror)
  350. {
  351. changeVal = -1;
  352. }
  353. var nowBone = bones[partData.bones[i]];
  354. var rotate = nowBone.localEulerAngles;
  355. var orginBoneRot = bodyData.orginLocalRotationList[partData.bones[i]];
  356. var newBoneRot = new Vector3(
  357. partData.rotationChange.x == 1 ? changeVal * partData.floatValue + orginBoneRot.x : rotate.x,
  358. partData.rotationChange.y == 1 ? changeVal * partData.floatValue + orginBoneRot.y : rotate.y,
  359. partData.rotationChange.z == 1 ? changeVal * partData.floatValue + orginBoneRot.z : rotate.z
  360. );
  361. bodyData.changedRotationList[partData.bones[i]] = newBoneRot;
  362. }
  363. }
  364. RefreshRoleBone();
  365. }
  366. public float GetBodyBoneValue(ECustomStyple styple,int id)
  367. {
  368. PartData partData = null;
  369. switch (styple)
  370. {
  371. case ECustomStyple.None:
  372. break;
  373. case ECustomStyple.NieLian:
  374. partData = bodyData.faceList[id];
  375. break;
  376. case ECustomStyple.Body:
  377. partData = bodyData.bodyList[id];
  378. break;
  379. case ECustomStyple.Cloth:
  380. break;
  381. case ECustomStyple.Ornament:
  382. break;
  383. default:
  384. break;
  385. }
  386. if(partData == null)
  387. {
  388. return 0;
  389. }
  390. Debug.Log(partData.id + " :" + partData.useBlend + " : " + partData.floatValue);
  391. if (partData.useBlend)
  392. {
  393. return partData.floatValue;
  394. }
  395. Debug.Log(id +": GetBodyBoneValue + " + partData.scaleChange + " " + partData.floatValue);
  396. if (partData.scaleChange.x == 1 || partData.scaleChange.y == 1 || partData.scaleChange.z == 1)
  397. {
  398. if (partData.floatValue == 1)
  399. {
  400. return 0.5f;
  401. }
  402. if (partData.floatValue < 1)
  403. {
  404. return (partData.floatValue - partData.minChangeValue) / (1 - partData.minChangeValue)/2;
  405. }
  406. if (partData.floatValue > 1)
  407. {
  408. return 0.5f + (partData.floatValue - 1) / (partData.maxChangeValue - 1)/2;
  409. }
  410. }
  411. if (partData.positionChange.x == 1 || partData.positionChange.y == 1 || partData.positionChange.z == 1)
  412. {
  413. if (partData.floatValue == 0)
  414. {
  415. return 0.5f;
  416. }
  417. if (partData.floatValue < 0)
  418. {
  419. return partData.floatValue / partData.maxChangeValue/2;
  420. }
  421. if (partData.floatValue > 0)
  422. {
  423. return 0.5f + partData.floatValue / partData.maxChangeValue / 2;
  424. }
  425. }
  426. if (partData.rotationChange.x == 1 || partData.rotationChange.y == 1 || partData.rotationChange.z == 1)
  427. {
  428. if (partData.floatValue == 0)
  429. {
  430. return 0.5f;
  431. }
  432. if (partData.floatValue < 0)
  433. {
  434. return partData.floatValue / partData.maxChangeValue / 2;
  435. }
  436. if (partData.floatValue > 0)
  437. {
  438. return 0.5f + partData.floatValue / partData.maxChangeValue / 2;
  439. }
  440. }
  441. return 0.5f;
  442. }
  443. /// <summary>
  444. /// 重置角色数据
  445. /// </summary>
  446. public void ResetRole()
  447. {
  448. if(testPlayer == null)
  449. {
  450. Debug.LogError("没有模型存在");
  451. return;
  452. }
  453. Debug.Log("重置模型");
  454. foreach (var item in bodyData.bodyList)
  455. {
  456. var key = item.Key;
  457. var value = item.Value;
  458. if(value.useBlend)
  459. {
  460. value.floatValue = 0;
  461. }
  462. else
  463. {
  464. value.floatValue = 1;
  465. }
  466. }
  467. //重置缩放
  468. foreach (var item in bodyData.orginLocalScaleList)
  469. {
  470. var key = item.Key;
  471. var value = item.Value;
  472. testPlayer.SetBoneScale(key, value);
  473. //testPlayer.SetBoneWorldScale(key, value);
  474. if (bodyData.changedScaleList.ContainsKey(key))
  475. {
  476. bodyData.changedScaleList[key] = bodyData.orginLocalScaleList[key];
  477. }
  478. bodyData.orginChangeScaleList[key] = new Vector3(1, 1, 1);
  479. bodyData.ChangedScaleParamsList[key] = new Vector3(1, 1, 1);
  480. }
  481. //重置旋转
  482. foreach (var item in bodyData.orginLocalRotationList)
  483. {
  484. var key = item.Key;
  485. var value = item.Value;
  486. testPlayer.SetBoneRot(key, value);
  487. }
  488. //重置位置
  489. foreach (var item in bodyData.orginLocalPositionList)
  490. {
  491. var key = item.Key;
  492. var value = item.Value;
  493. testPlayer.SetBonePos(key, value);
  494. }
  495. testPlayer.ResetAllBlendShape();
  496. }
  497. public void RefreshRoleBlendShape(string name,float value)
  498. {
  499. if (testPlayer == null)
  500. {
  501. Debug.LogError("没有模型存在");
  502. return;
  503. }
  504. testPlayer.SetBlendShape(name, value);
  505. }
  506. public void RefreshRoleBone()
  507. {
  508. if (testPlayer == null)
  509. {
  510. Debug.LogError("没有模型存在");
  511. return;
  512. }
  513. Debug.Log("刷新模型");
  514. //刷新缩放
  515. //foreach (var item in bodyData.orginLocalScaleList)
  516. //{
  517. // var key = item.Key;
  518. // var value = item.Value;
  519. // if(bodyData.changedScaleList.ContainsKey(key))
  520. // {
  521. // testPlayer.SetBoneScale(key, bodyData.changedScaleList[key]);
  522. // }
  523. // else
  524. // {
  525. // testPlayer.SetBoneScale(key, value);
  526. // }
  527. //}
  528. foreach (var item in bodyData.changedScaleList)
  529. {
  530. var key = item.Key;
  531. var value = item.Value;
  532. //testPlayer.SetBoneWorldScale(key, value, bodyData.orginLocalScaleList[key], bodyData.orginWorldScaleList[key]);
  533. testPlayer.SetBoneScale(key, value);
  534. }
  535. foreach (var item in bodyData.changedPositionList)
  536. {
  537. var key = item.Key;
  538. var value = item.Value;
  539. testPlayer.SetBonePos(key, value);
  540. }
  541. foreach (var item in bodyData.changedRotationList)
  542. {
  543. var key = item.Key;
  544. var value = item.Value;
  545. testPlayer.SetBoneRot(key, value);
  546. }
  547. }
  548. /// <summary>
  549. /// 旋转模特
  550. /// </summary>
  551. public void RotateModel(float offset)
  552. {
  553. if (testPlayer == null)
  554. {
  555. Debug.LogError("没有模型存在");
  556. return;
  557. }
  558. testPlayer.RotateSelf(offset);
  559. }
  560. public void ChangeCustomCamera(ECustomStyple type)
  561. {
  562. return;
  563. switch (type)
  564. {
  565. case ECustomStyple.None:
  566. break;
  567. case ECustomStyple.NieLian:
  568. Camera.main.transform.DOMove(new Vector3(-0.26f, 0.4f, -5), 0.3f);
  569. Camera.main.DOOrthoSize(0.25f, 0.3f);
  570. break;
  571. case ECustomStyple.Body:
  572. case ECustomStyple.Cloth:
  573. Camera.main.transform.DOMove(new Vector3(0, -0.24f, -5), 0.3f);
  574. Camera.main.DOOrthoSize(1.5f, 0.3f);
  575. break;
  576. case ECustomStyple.Ornament:
  577. break;
  578. default:
  579. break;
  580. }
  581. }
  582. /// <summary>
  583. /// 修改颜色
  584. /// </summary>
  585. /// <param name="id">对应部位id</param>
  586. /// <param name="color">颜色</param>
  587. public void ChangeColor(int id,Vector3 color)
  588. {
  589. testPlayer.ChangeColor(id,color);
  590. }
  591. public void ChangeClothing(int id)
  592. {
  593. Debug.Log("换衣服咯 : " + id);
  594. IDataTable<DRClothing> drCloth = GameEntry.DataTable.GetDataTable<DRClothing>();
  595. DRClothing clothdata = drCloth.GetDataRow(id);
  596. if(clothdata == null)
  597. {
  598. Debug.LogError("cloth " + id + "不存在");
  599. return;
  600. }
  601. var path = clothdata.Prefab;
  602. GameEntry.Resource.LoadAsset(AssetUtility.GetEntityAsset(path), new GameFramework.Resource.LoadAssetCallbacks(
  603. (assetName, asset, duration, userData) =>
  604. {
  605. GameObject go = GameObject.Instantiate((GameObject)asset, testPlayer.transform);
  606. go.transform.localPosition = Vector3.zero;
  607. go.transform.localRotation = Quaternion.identity;
  608. var component = testPlayer.GetComponent<CombineSkinMesh>();
  609. component.ChangeCloth((ClothType)clothdata.ParentStyple, go);
  610. }
  611. ));
  612. }
  613. /// <summary>
  614. /// 保存
  615. /// </summary>
  616. public void Save()
  617. {
  618. string bodySave = "";
  619. foreach (var item in bodyData.bodyList)
  620. {
  621. var key = item.Key;
  622. var value = item.Value;
  623. }
  624. }
  625. /// <summary>
  626. /// 加载
  627. /// </summary>
  628. public void Reload()
  629. {
  630. }
  631. }
  632. }