PhysicPlayEditor.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. using JamesGame;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5. public class PhysicPlayEditor : EditorWindow
  6. {
  7. private static string targetName;
  8. private static string isDone = string.Empty;
  9. private static bool isPhysicName = false;
  10. private static bool isPhysicRound = false;
  11. private static string oldLevelStr;
  12. private static string newLevelStr;
  13. private static string oldRoundStr;
  14. private static string newRoundStr;
  15. [MenuItem("NeoGame/物理玩法/创建空靶子")]
  16. public static void CreateBlankTarget()
  17. {
  18. var window = EditorWindow.GetWindow<PhysicPlayEditor>();
  19. isPhysicName = true;
  20. isPhysicRound = false;
  21. window.titleContent.text = "物理玩法";
  22. window.Show();
  23. }
  24. [MenuItem("NeoGame/物理玩法/添加无刚体靶子脚本(气球)")]
  25. public static void AttachBallonScriptAndSetting()
  26. {
  27. GameObject go = Selection.activeGameObject;
  28. if (go != null)
  29. {
  30. ChangeChildLayer(LayerMask.NameToLayer("Target"), go);
  31. NormalTarget td = go.GetComponent<NormalTarget>();
  32. if (td != null)
  33. {
  34. GameObject hitRoot = td.shape.center.gameObject;
  35. PhysicDestructAnim physicCtrl = hitRoot.AddComponent<PhysicDestructAnim>();
  36. td.shape.aniPlayer = physicCtrl;
  37. physicCtrl.model = UnityUtils.FindChild(hitRoot.transform, "model").gameObject;
  38. AutoFill(go, physicCtrl.model);
  39. }
  40. else
  41. {
  42. Debug.Log("要挂的东西上没有TargetData");
  43. }
  44. }
  45. else
  46. {
  47. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  48. }
  49. }
  50. [MenuItem("NeoGame/物理玩法/添加打碎靶子脚本(木箱,木棍)")]
  51. public static void AttachBreakScriptAndSetting()
  52. {
  53. GameObject go = Selection.activeGameObject;
  54. if (go != null)
  55. {
  56. PhysicDestructAnim ppb = AutoAttachParts(go);
  57. if (ppb != null)
  58. {
  59. AutoFill(go, ppb.model);
  60. }
  61. }
  62. else
  63. {
  64. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  65. }
  66. }
  67. [MenuItem("NeoGame/物理玩法/添加摔碎靶子脚本(冰块)")]
  68. public static void AttachDropBreakScriptAndSetting()
  69. {
  70. GameObject go = Selection.activeGameObject;
  71. if (go != null)
  72. {
  73. PhysicDestructAnim ppb = AutoAttachParts(go);
  74. if (ppb != null)
  75. {
  76. AutoFill(go, ppb.model);
  77. AddDropBreakScript(go, ppb.model);
  78. }
  79. }
  80. else
  81. {
  82. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  83. }
  84. }
  85. [MenuItem("NeoGame/物理玩法/添加不破碎靶子脚本(铁块)")]
  86. public static void AttachNoBreakScriptAndSetting()
  87. {
  88. GameObject go = Selection.activeGameObject;
  89. if (go != null)
  90. {
  91. PhysicDestructAnim ppb = AutoAttachParts(go);
  92. if(ppb != null)
  93. {
  94. AddCollusionScript(go, ppb.model);
  95. TargetCtrl tc = go.GetComponent<TargetCtrl>();
  96. if (tc != null)
  97. {
  98. GameObject.Destroy(tc);
  99. }
  100. }
  101. }
  102. else
  103. {
  104. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  105. }
  106. }
  107. [MenuItem("NeoGame/物理玩法/添加滚动靶子脚本(铁球)")]
  108. public static void AttachRollScriptAndSetting()
  109. {
  110. GameObject go = Selection.activeGameObject;
  111. if (go != null)
  112. {
  113. PhysicDestructAnim ppb = AutoAttachParts(go);
  114. if (ppb != null)
  115. {
  116. AddRollBreakScript(go, ppb.model);
  117. TargetCtrl tc = go.GetComponent<TargetCtrl>();
  118. if (tc != null)
  119. {
  120. DestroyImmediate(tc);
  121. }
  122. }
  123. }
  124. else
  125. {
  126. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  127. }
  128. }
  129. //跟冰块的不同在于,执行完脚本后要自己在prefab上设置爆炸范围和爆炸力
  130. [MenuItem("NeoGame/物理玩法/添加炸药桶靶子脚本")]
  131. public static void AttachBoomScriptAndSetting()
  132. {
  133. GameObject go = Selection.activeGameObject;
  134. if (go != null)
  135. {
  136. PhysicDestructAnim ppb = AutoAttachParts(go);
  137. if (ppb != null)
  138. {
  139. ppb.boomPower = 10f;
  140. ppb.boomRange = 10f;
  141. AutoFill(go, ppb.model);
  142. AddBoomScript(go, ppb.model);
  143. }
  144. }
  145. else
  146. {
  147. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  148. }
  149. }
  150. [MenuItem("NeoGame/物理玩法/添加人形靶子脚本")]
  151. public static void AttachBanditScriptAndSetting()
  152. {
  153. GameObject go = Selection.activeGameObject;
  154. if (go != null)
  155. {
  156. AutoAttachBandits(go);
  157. }
  158. else
  159. {
  160. EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  161. }
  162. }
  163. [MenuItem("NeoGame/物理玩法/移动关卡波次")]
  164. public static void MoveLevelRound()
  165. {
  166. var window = EditorWindow.GetWindow<PhysicPlayEditor>();
  167. isPhysicName = false;
  168. isPhysicRound = true;
  169. window.titleContent.text = "物理玩法";
  170. window.Show();
  171. }
  172. //[MenuItem("NeoGame/物理玩法/添加p")]
  173. //public static void AttachP()
  174. //{
  175. // GameObject go = Selection.activeGameObject;
  176. // if (go != null)
  177. // {
  178. // int characterControllerLayer = LayerMask.NameToLayer("ZombieCharacter");
  179. // int ragdollLayer = LayerMask.NameToLayer("ZombieRagdoll");
  180. // //puppet只能运行时脚本添加
  181. // TargetData td = go.GetComponent<TargetData>();
  182. // GameObject hitRoot = td.shape.center.gameObject;
  183. // Transform model = UnityUtils.FindChild(hitRoot.transform, "model");
  184. // PuppetMaster.SetUp(model.transform, characterControllerLayer, ragdollLayer);
  185. // }
  186. // else
  187. // {
  188. // EditorGUILayout.LabelField("选中刚要添加脚本的物体");
  189. // }
  190. //}
  191. private static void AutoAttachBandits(GameObject go)
  192. {
  193. //TargetData td = go.GetComponent<TargetData>();
  194. //if (td != null)
  195. //{
  196. // GameObject hitRoot = td.shape.center.gameObject;
  197. // PhysicPlayEnemyCtrl enemyCtrl = hitRoot.AddComponent<PhysicPlayEnemyCtrl>();
  198. // td.shape.aniPlayer = enemyCtrl;
  199. // Animator model = hitRoot.GetComponentInChildren<Animator>();
  200. // enemyCtrl.model = model.transform;
  201. // AutoPupuet(model);
  202. // AutoFill(go, null);
  203. // CloseRigi(go);
  204. //}
  205. //else
  206. //{
  207. // Debug.Log("要挂的东西上没有TargetData");
  208. //}
  209. }
  210. private static void CloseRigi(GameObject go)
  211. {
  212. Rigidbody[] rigis = go.GetComponentsInChildren<Rigidbody>();
  213. for (int i = 0;i < rigis.Length; ++i)
  214. {
  215. rigis[i].isKinematic = true;
  216. rigis[i].useGravity = false;
  217. }
  218. }
  219. private static PhysicDestructAnim AutoAttachParts(GameObject go)
  220. {
  221. ChangeChildLayer(LayerMask.NameToLayer("Target"), go);
  222. NormalTarget td = go.GetComponent<NormalTarget>();
  223. if (td != null)
  224. {
  225. GameObject hitRoot = td.shape.center.gameObject;
  226. PhysicDestructAnim physicCtrl = hitRoot.AddComponent<PhysicDestructAnim>();
  227. td.shape.aniPlayer = physicCtrl;
  228. physicCtrl.model = UnityUtils.FindChild(hitRoot.transform, "model").gameObject;
  229. physicCtrl.partsModel = UnityUtils.FindChild(hitRoot.transform, "partsModel").gameObject;
  230. AddRigiBody(physicCtrl.model, false);
  231. AddRigiBody(physicCtrl.partsModel, true);
  232. physicCtrl.partsModel.SetActive(false);
  233. return physicCtrl;
  234. }
  235. else
  236. {
  237. Debug.Log("要挂的东西上没有TargetData");
  238. return null;
  239. }
  240. }
  241. private static void AddCollusionScript(GameObject root, GameObject go)
  242. {
  243. for (int i = 0; i < go.transform.childCount; ++i)
  244. {
  245. Transform trans = go.transform.GetChild(i);
  246. if (trans != null)
  247. {
  248. Rigidbody rigi = trans.GetComponent<Rigidbody>();
  249. if (rigi != null)
  250. {
  251. PhysicTargetCollusionHandler ppb = trans.gameObject.AddComponent<PhysicTargetCollusionHandler>();
  252. ppb.breakCtrl = root.GetComponentInChildren<PhysicDestructAnim>();
  253. }
  254. }
  255. }
  256. }
  257. private static void AddDropBreakScript(GameObject root, GameObject go)
  258. {
  259. for (int i = 0; i < go.transform.childCount; ++i)
  260. {
  261. Transform trans = go.transform.GetChild(i);
  262. if (trans != null)
  263. {
  264. Rigidbody rigi = trans.GetComponent<Rigidbody>();
  265. if (rigi != null)
  266. {
  267. PhysicPlayDropBreakHandler ppb = trans.gameObject.AddComponent<PhysicPlayDropBreakHandler>();
  268. ppb.breakCtrl = root.GetComponentInChildren<PhysicDestructAnim>();
  269. }
  270. }
  271. }
  272. }
  273. private static void AddRollBreakScript(GameObject root, GameObject go)
  274. {
  275. for (int i = 0; i < go.transform.childCount; ++i)
  276. {
  277. Transform trans = go.transform.GetChild(i);
  278. if (trans != null)
  279. {
  280. Rigidbody rigi = trans.GetComponent<Rigidbody>();
  281. if (rigi != null)
  282. {
  283. PhysicTargetRollCollusionHandler ppb = trans.gameObject.AddComponent<PhysicTargetRollCollusionHandler>();
  284. ppb.breakCtrl = root.GetComponentInChildren<PhysicDestructAnim>();
  285. }
  286. }
  287. }
  288. }
  289. private static void AddBoomScript(GameObject root, GameObject go)
  290. {
  291. for (int i = 0; i < go.transform.childCount; ++i)
  292. {
  293. Transform trans = go.transform.GetChild(i);
  294. if (trans != null)
  295. {
  296. Rigidbody rigi = trans.GetComponent<Rigidbody>();
  297. if (rigi != null)
  298. {
  299. PhysicPlayBoomCollusionHandler ppb = trans.gameObject.AddComponent<PhysicPlayBoomCollusionHandler>();
  300. ppb.breakCtrl = root.GetComponentInChildren<PhysicDestructAnim>();
  301. }
  302. }
  303. }
  304. }
  305. private static void AddRigiBody(GameObject go, bool isFragment)
  306. {
  307. for (int i = 0; i < go.transform.childCount; ++i)
  308. {
  309. Transform trans = go.transform.GetChild(i);
  310. if (trans != null)
  311. {
  312. MeshRenderer mr = trans.GetComponent<MeshRenderer>();
  313. if (mr != null)
  314. {
  315. Rigidbody rigi = mr.gameObject.AddComponent<Rigidbody>();
  316. rigi.isKinematic = true;
  317. rigi.useGravity = false;
  318. }
  319. if (isFragment)
  320. {
  321. trans.gameObject.layer = LayerMask.NameToLayer("Fragment");
  322. }
  323. }
  324. }
  325. }
  326. private static void AutoPupuet(Animator model)
  327. {
  328. //if (model.isHuman)
  329. //{
  330. // BipedRagdollReferences r = BipedRagdollReferences.FromAvatar(model);
  331. // BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(r);
  332. // BipedRagdollCreator.Create(r, options);
  333. //}
  334. //else
  335. //{
  336. // BipedReferences r = new BipedReferences();
  337. // BipedReferences.AutoDetectReferences(ref r, model.transform.parent, BipedReferences.AutoDetectParams.Default);
  338. // if (r.isFilled)
  339. // {
  340. // BipedRagdollReferences references = BipedRagdollReferences.FromBipedReferences(r);
  341. // BipedRagdollCreator.Options options = BipedRagdollCreator.AutodetectOptions(references);
  342. // BipedRagdollCreator.Create(references, options);
  343. // }
  344. //}
  345. //int characterControllerLayer = LayerMask.NameToLayer("ZombieCharacter");
  346. //int ragdollLayer = LayerMask.NameToLayer("ZombieRagdoll");
  347. ////puppet只能运行时脚本添加
  348. //PuppetMaster.SetUp(model.transform, characterControllerLayer, ragdollLayer);
  349. }
  350. private static void AutoFill(GameObject go, GameObject findObj)
  351. {
  352. TargetRendererCtrl targetRender = go.GetComponent<TargetRendererCtrl>();
  353. if (targetRender != null)
  354. {
  355. targetRender.GenerateRenders();
  356. }
  357. TargetCtrl tc = go.GetComponent<TargetCtrl>();
  358. if (tc != null)
  359. {
  360. tc.colliders.Clear();
  361. if (findObj == null)
  362. {
  363. findObj = tc.gameObject;
  364. }
  365. var colliders = findObj.transform.GetComponentsInChildren<Collider>();
  366. foreach (var col in colliders)
  367. {
  368. int score;
  369. if (!int.TryParse(col.name, out score))
  370. {
  371. score = 0;
  372. }
  373. tc.colliders.Add(new TargetScoreCollider
  374. {
  375. collider = col,
  376. score = score,
  377. });
  378. }
  379. }
  380. else
  381. {
  382. Debug.Log("要挂的东西上没有TargetController");
  383. }
  384. }
  385. void OnGUI()
  386. {
  387. GUILayout.BeginVertical();
  388. GUILayout.Space(10);
  389. if (isPhysicName)
  390. {
  391. targetName = EditorGUILayout.TextField("靶子名称", targetName);
  392. EditorGUILayout.Space();
  393. if (GUILayout.Button("创建"))
  394. {
  395. CreateTargetObject();
  396. }
  397. }
  398. if (isPhysicRound)
  399. {
  400. oldLevelStr = EditorGUILayout.TextField("旧关卡", oldLevelStr);
  401. oldRoundStr = EditorGUILayout.TextField("旧波次", oldRoundStr);
  402. newLevelStr = EditorGUILayout.TextField("新关卡", newLevelStr);
  403. newRoundStr = EditorGUILayout.TextField("新波次", newRoundStr);
  404. EditorGUILayout.Space();
  405. //if (GUILayout.Button("互换"))
  406. //{
  407. // ChangeRoundObject();
  408. //}
  409. //if (GUILayout.Button("插入"))
  410. //{
  411. // InsertRoundObject();
  412. //}
  413. }
  414. EditorGUILayout.Space();
  415. if (!string.IsNullOrEmpty(isDone))
  416. {
  417. EditorGUILayout.LabelField("结果:"+ isDone);
  418. }
  419. GUILayout.EndVertical();
  420. }
  421. private void CreateTargetObject()
  422. {
  423. GameObject go = CreateGo(targetName, null);
  424. GameObject topRoot = CreateGo("top_root", go.transform);
  425. GameObject root = CreateGo("root", topRoot.transform);
  426. GameObject hitRoot = CreateGo("hit_root", root.transform);
  427. GameObject splashSound = CreateGo("splashSound", hitRoot.transform);
  428. GameObject splashEffect = CreateGo("splashEffect", hitRoot.transform);
  429. GameObject modelObj = CreateGo("model", hitRoot.transform);
  430. GameObject partsModelObj = CreateGo("partsModel", hitRoot.transform);
  431. GameObject modelCenter = CreateGo("modelCenter", hitRoot.transform);
  432. GameObject score = CreateGo("score", hitRoot.transform);
  433. NormalTarget td = go.AddComponent<NormalTarget>();
  434. TargetExt tsd = new TargetExt();
  435. tsd.center = hitRoot.transform;
  436. tsd.HitDeathNode = root;
  437. tsd.EventNodeName = topRoot;
  438. td.shape = tsd;
  439. //TargetRendererGather tr = go.AddComponent<TargetRendererGather>();
  440. TargetCtrl tc = go.AddComponent<TargetCtrl>();
  441. isDone = "完成";
  442. }
  443. private GameObject CreateGo(string objName, Transform objParent)
  444. {
  445. GameObject obj = new GameObject();
  446. obj.name = objName;
  447. obj.transform.SetParent(objParent);
  448. obj.transform.localPosition = Vector3.zero;
  449. obj.transform.localRotation = Quaternion.identity;
  450. obj.transform.localScale = Vector3.one;
  451. return obj;
  452. }
  453. private static void ChangeChildLayer(int layerIndex, GameObject go)
  454. {
  455. Transform[] tranList = go.GetComponentsInChildren<Transform>();
  456. foreach (Transform tran in tranList)
  457. {
  458. tran.gameObject.layer = layerIndex;
  459. }
  460. }
  461. ////未写完
  462. //private static void ChangeRoundObject()
  463. //{
  464. // int oldLevel = int.Parse(oldLevelStr);
  465. // int newLevel = int.Parse(newLevelStr);
  466. // int oldRound = int.Parse(oldRoundStr);
  467. // int newRound = int.Parse(newRoundStr);
  468. // var levelData = DataManager.Instance.csvData.GetLevelByID(oldLevel);
  469. // //获取旧的波次的靶子信息
  470. // List<int> oldRoundTargets = null;
  471. // var oldLevelData = DataManager.Instance.csvData.GetLevelByID(oldLevel);
  472. // Dictionary<int, List<int>> oldRoundDict = RoundTarget.GetRoundTargetDict(oldLevelData.roundTargetIds);
  473. // if (oldRoundDict.ContainsKey(oldRound))
  474. // {
  475. // oldRoundTargets = oldRoundDict[oldRound];
  476. // }
  477. // if (oldRoundTargets != null && oldRoundTargets.Count > 0)
  478. // {
  479. // //看targetGroup中是否有重复的targetID的靶子,重复的最好人工解决
  480. // for (int i = 0; i < oldRoundTargets.Count; ++i)
  481. // {
  482. // int targetID = oldRoundTargets[i];
  483. // bool flag = IsUniqueInTargetGroup(oldLevel, targetID);
  484. // if (!flag)
  485. // {
  486. // isDone = "有相同targetID在targetGroup中,需要人工手动处理";
  487. // return;
  488. // }
  489. // }
  490. // }
  491. // //获取新的波次的靶子信息
  492. // List<int> newRoundTargets = null;
  493. // var newLevelData = DataManager.Instance.csvData.GetLevelByID(newLevel);
  494. // Dictionary<int, List<int>> newRoundDict = RoundTarget.GetRoundTargetDict(newLevelData.roundTargetIds);
  495. // if (newRoundDict.ContainsKey(newRound))
  496. // {
  497. // newRoundTargets = newRoundDict[oldRound];
  498. // }
  499. // if (newRoundTargets != null && newRoundTargets.Count > 0)
  500. // {
  501. // //看targetGroup中是否有重复的targetID的靶子,重复的最好人工解决
  502. // for (int i = 0; i < newRoundTargets.Count; ++i)
  503. // {
  504. // int targetID = newRoundTargets[i];
  505. // bool flag = IsUniqueInTargetGroup(newLevel, targetID);
  506. // if (!flag)
  507. // {
  508. // isDone = "有相同targetID在targetGroup中,需要人工手动处理";
  509. // return;
  510. // }
  511. // }
  512. // }
  513. // isDone = "完成";
  514. //}
  515. ////未测试
  516. //private static void InsertRoundObject()
  517. //{
  518. // int oldLevel = int.Parse(oldLevelStr);
  519. // int newLevel = int.Parse(newLevelStr);
  520. // int oldRound = int.Parse(oldRoundStr);
  521. // int newRound = int.Parse(newRoundStr);
  522. // //获取旧的波次的靶子信息
  523. // List<int> oldRoundTargets = null;
  524. // var oldLevelData = DataManager.Instance.csvData.GetLevelByID(oldLevel);
  525. // Dictionary<int, List<int>> oldRoundDict = RoundTarget.GetRoundTargetDict(oldLevelData.roundTargetIds);
  526. // if (oldRoundDict.ContainsKey(oldRound))
  527. // {
  528. // oldRoundTargets = oldRoundDict[oldRound];
  529. // }
  530. // if (oldRoundTargets != null && oldRoundTargets.Count > 0)
  531. // {
  532. // //看targetGroup中是否有重复的targetID的靶子,重复的最好人工解决
  533. // for (int i = 0; i < oldRoundTargets.Count; ++i)
  534. // {
  535. // int targetID = oldRoundTargets[i];
  536. // bool flag = IsUniqueInTargetGroup(oldLevel, targetID);
  537. // if (!flag)
  538. // {
  539. // isDone = "有相同targetID在targetGroup中,需要人工手动处理";
  540. // return;
  541. // }
  542. // }
  543. // //在targetgroup中追加要加入的波次的靶子id
  544. // var gameDataDir = ConfigEditor.GAME_DATA_DIR;
  545. // Dictionary<int, TargetGroupDefine> targetGroups = GetTargetGroupDict();
  546. // for (int i = 0; i < oldRoundTargets.Count; ++i)
  547. // {
  548. // int targetID = oldRoundTargets[i];
  549. // TargetGroupDefine tg = new TargetGroupDefine();
  550. // tg.ID = curMaxTargetGroupID + i + 1;
  551. // tg.TargetID = targetID;
  552. // tg.GroupID = newLevel;
  553. // targetGroups.Add(tg.ID, tg);
  554. // }
  555. // DataWriter.SaveTargetGroupData(gameDataDir, "TargetGroup", targetGroups);
  556. // //把旧的关卡的波次的targetobject添加到新的关卡的指定的波次中,自动将波次后的信息延后
  557. // var newLevelData = DataManager.Instance.csvData.GetLevelByID(newLevel);
  558. // Dictionary<int, List<int>> newRoundDict = RoundTarget.GetRoundTargetDict(newLevelData.roundTargetIds);
  559. // Dictionary<int, List<int>> rebuildRoundDict = new Dictionary<int, List<int>>();
  560. // foreach (var item in newRoundDict)
  561. // {
  562. // if (item.Key < newRound)
  563. // {
  564. // rebuildRoundDict.Add(item.Key, item.Value);
  565. // }
  566. // else
  567. // {
  568. // rebuildRoundDict.Add(item.Key + 1, item.Value);
  569. // }
  570. // }
  571. // rebuildRoundDict.Add(newRound, oldRoundTargets);
  572. // newLevelData.roundTargetIds = RoundTarget.GetTargetDictStr(rebuildRoundDict);
  573. // //挪动旧关卡的关联的刚体信息,与新关卡的关联刚体信息合并
  574. // Dictionary<int, List<int>> oldOpenRigiBodys = TargetOpenRigiBody.GetTargetRigiBodyDict(oldLevelData.openRigiBody);
  575. // Dictionary<int, List<int>> newOpenRigiBodys = TargetOpenRigiBody.GetTargetRigiBodyDict(newLevelData.openRigiBody);
  576. // foreach (int targetID in oldRoundTargets)
  577. // {
  578. // newOpenRigiBodys.Add(targetID, oldOpenRigiBodys[targetID]);
  579. // }
  580. // newLevelData.openRigiBody = TargetOpenRigiBody.GetTargetRigiBodyList(newOpenRigiBodys);
  581. // //挪动旧关卡的关联的移动信息,与新关卡的关联移动信息合并
  582. // Dictionary<int, List<int>> oldMoveRigiBodys = TargetOpenRigiBody.GetTargetRigiBodyDict(oldLevelData.moveRigiBody);
  583. // Dictionary<int, List<int>> newMoveRigiBodys = TargetOpenRigiBody.GetTargetRigiBodyDict(newLevelData.moveRigiBody);
  584. // foreach (int targetID in oldRoundTargets)
  585. // {
  586. // newMoveRigiBodys.Add(targetID, oldMoveRigiBodys[targetID]);
  587. // }
  588. // newLevelData.moveRigiBody = TargetOpenRigiBody.GetTargetRigiBodyList(newMoveRigiBodys);
  589. // Dictionary<int, LevelDefine> levelCfgs = GetLevelDict();
  590. // DataWriter.SaveLevelData(gameDataDir, "Level", levelCfgs);
  591. // }
  592. // isDone = "完成";
  593. //}
  594. //private static bool IsUniqueInTargetGroup(int levelID, int targetID)
  595. //{
  596. // bool result = true;
  597. // var targetGroups = DataManager.Instance.csvData.TargetGroup;
  598. // foreach (var cfg in targetGroups)
  599. // {
  600. // if (cfg.TargetID == targetID && cfg.GroupID == levelID)
  601. // {
  602. // result = false;
  603. // break;
  604. // }
  605. // }
  606. // return result;
  607. //}
  608. //private static int curMaxTargetGroupID = 0;
  609. //private static Dictionary<int, TargetGroupDefine> GetTargetGroupDict()
  610. //{
  611. // Dictionary<int, TargetGroupDefine> targetGroupCfgs = new Dictionary<int, TargetGroupDefine>();
  612. // var rawCfgs = DataManager.Instance.csvData.TargetGroup;
  613. // foreach (var cfg in rawCfgs)
  614. // {
  615. // targetGroupCfgs.Add(cfg.ID, cfg);
  616. // if (cfg.ID > curMaxTargetGroupID)
  617. // {
  618. // curMaxTargetGroupID = cfg.ID;
  619. // }
  620. // }
  621. // return targetGroupCfgs;
  622. //}
  623. //private static Dictionary<int, LevelDefine> GetLevelDict()
  624. //{
  625. // Dictionary<int, LevelDefine> levelCfgs = new Dictionary<int, LevelDefine>();
  626. // var rawCfgs = DataManager.Instance.csvData.Level;
  627. // foreach (var cfg in rawCfgs)
  628. // {
  629. // levelCfgs.Add(cfg.ID, cfg);
  630. // }
  631. // return levelCfgs;
  632. //}
  633. }