AMEventParameter.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text;
  5. using UnityEngine;
  6. using wf;
  7. [Serializable]
  8. public class AMEventParameter : ScriptableObject
  9. {
  10. public bool setBool(bool val_bool)
  11. {
  12. if (this.val_bool != val_bool)
  13. {
  14. this.val_bool = val_bool;
  15. return true;
  16. }
  17. return false;
  18. }
  19. public bool setInt(int val_int)
  20. {
  21. if (this.val_int != val_int)
  22. {
  23. this.val_int = val_int;
  24. return true;
  25. }
  26. return false;
  27. }
  28. public bool setFloat(float val_float)
  29. {
  30. if (this.val_float != val_float)
  31. {
  32. this.val_float = val_float;
  33. return true;
  34. }
  35. return false;
  36. }
  37. public bool setVector2(Vector2 val_vect2)
  38. {
  39. if (this.val_vect2 != val_vect2)
  40. {
  41. this.val_vect2 = val_vect2;
  42. return true;
  43. }
  44. return false;
  45. }
  46. public bool setVector3(Vector3 val_vect3)
  47. {
  48. if (this.val_vect3 != val_vect3)
  49. {
  50. this.val_vect3 = val_vect3;
  51. return true;
  52. }
  53. return false;
  54. }
  55. public bool setVector4(Vector4 val_vect4)
  56. {
  57. if (this.val_vect4 != val_vect4)
  58. {
  59. this.val_vect4 = val_vect4;
  60. return true;
  61. }
  62. return false;
  63. }
  64. public bool setColor(Color val_color)
  65. {
  66. if (this.val_color != val_color)
  67. {
  68. this.val_color = val_color;
  69. return true;
  70. }
  71. return false;
  72. }
  73. public bool setRect(Rect val_rect)
  74. {
  75. if (this.val_rect != val_rect)
  76. {
  77. this.val_rect = val_rect;
  78. return true;
  79. }
  80. return false;
  81. }
  82. public bool setString(string val_string)
  83. {
  84. if (this.val_string != val_string)
  85. {
  86. this.val_string = val_string;
  87. return true;
  88. }
  89. return false;
  90. }
  91. public bool setObject(UnityEngine.Object val_obj)
  92. {
  93. if (this.val_obj != val_obj)
  94. {
  95. this.val_obj = val_obj;
  96. return true;
  97. }
  98. return false;
  99. }
  100. public Type getParamType()
  101. {
  102. if (this.valueType == 13)
  103. {
  104. return typeof(bool);
  105. }
  106. if (this.valueType == 0 || this.valueType == 1)
  107. {
  108. return typeof(int);
  109. }
  110. if (this.valueType == 2 || this.valueType == 3)
  111. {
  112. return typeof(float);
  113. }
  114. if (this.valueType == 4)
  115. {
  116. return typeof(Vector2);
  117. }
  118. if (this.valueType == 5)
  119. {
  120. return typeof(Vector3);
  121. }
  122. if (this.valueType == 6)
  123. {
  124. return typeof(Vector4);
  125. }
  126. if (this.valueType == 7)
  127. {
  128. return typeof(Color);
  129. }
  130. if (this.valueType == 8)
  131. {
  132. return typeof(Rect);
  133. }
  134. if (this.valueType == 11)
  135. {
  136. return typeof(UnityEngine.Object);
  137. }
  138. if (this.valueType == 12)
  139. {
  140. if (this.lsArray.Count <= 0)
  141. {
  142. return typeof(object[]);
  143. }
  144. return this.lsArray[0].getParamType();
  145. }
  146. else
  147. {
  148. if (this.valueType == 9)
  149. {
  150. return typeof(string);
  151. }
  152. if (this.valueType == 10)
  153. {
  154. return typeof(char);
  155. }
  156. Debug.LogError("Animator: Type not found for Event Parameter.");
  157. return typeof(object);
  158. }
  159. }
  160. public void destroy()
  161. {
  162. foreach (AMEventParameter ameventParameter in this.lsArray)
  163. {
  164. ameventParameter.destroy();
  165. }
  166. UnityEngine.Object.DestroyImmediate(this);
  167. }
  168. public string getStringValue()
  169. {
  170. if (this.valueType == 13)
  171. {
  172. return this.val_bool.ToString().ToLower();
  173. }
  174. if (this.valueType == 9)
  175. {
  176. return "\"" + this.val_string + "\"";
  177. }
  178. if (this.valueType == 10)
  179. {
  180. if (this.val_string == null || this.val_string.Length <= 0)
  181. {
  182. return "''";
  183. }
  184. return "'" + this.val_string[0] + "'";
  185. }
  186. else
  187. {
  188. if (this.valueType == 0 || this.valueType == 1)
  189. {
  190. return this.val_int.ToString();
  191. }
  192. if (this.valueType == 2 || this.valueType == 3)
  193. {
  194. return this.val_float.ToString();
  195. }
  196. if (this.valueType == 4)
  197. {
  198. return this.val_vect2.ToString();
  199. }
  200. if (this.valueType == 5)
  201. {
  202. return this.val_vect3.ToString();
  203. }
  204. if (this.valueType == 6)
  205. {
  206. return this.val_vect4.ToString();
  207. }
  208. if (this.valueType == 7)
  209. {
  210. return this.val_color.ToString();
  211. }
  212. if (this.valueType == 8)
  213. {
  214. return this.val_rect.ToString();
  215. }
  216. if (this.valueType == 11)
  217. {
  218. if (!this.val_obj)
  219. {
  220. return "None";
  221. }
  222. return this.val_obj.name;
  223. }
  224. else
  225. {
  226. if (this.valueType == 12)
  227. {
  228. return "Array";
  229. }
  230. Debug.LogError("Animator: Type not found for Event Parameter.");
  231. return "object";
  232. }
  233. }
  234. }
  235. public void setValueType(Type t)
  236. {
  237. if (t == typeof(bool))
  238. {
  239. this.valueType = 13;
  240. }
  241. else if (t == typeof(string))
  242. {
  243. this.valueType = 9;
  244. }
  245. else if (t == typeof(char))
  246. {
  247. this.valueType = 10;
  248. }
  249. else if (t == typeof(int))
  250. {
  251. this.valueType = 0;
  252. }
  253. else if (t == typeof(long))
  254. {
  255. this.valueType = 1;
  256. }
  257. else if (t == typeof(float))
  258. {
  259. this.valueType = 2;
  260. }
  261. else if (t == typeof(double))
  262. {
  263. this.valueType = 3;
  264. }
  265. else if (t == typeof(Vector2))
  266. {
  267. this.valueType = 4;
  268. }
  269. else if (t == typeof(Vector3))
  270. {
  271. this.valueType = 5;
  272. }
  273. else if (t == typeof(Vector4))
  274. {
  275. this.valueType = 6;
  276. }
  277. else if (t == typeof(Color))
  278. {
  279. this.valueType = 7;
  280. }
  281. else if (t == typeof(Rect))
  282. {
  283. this.valueType = 8;
  284. }
  285. else if (t.IsArray)
  286. {
  287. this.valueType = 12;
  288. }
  289. else if (t.BaseType.BaseType == typeof(UnityEngine.Object))
  290. {
  291. this.valueType = 11;
  292. }
  293. else
  294. {
  295. this.valueType = 11;
  296. }
  297. }
  298. public object toObject()
  299. {
  300. if (this.valueType == 13)
  301. {
  302. return this.val_bool;
  303. }
  304. if (this.valueType == 9)
  305. {
  306. return this.val_string;
  307. }
  308. if (this.valueType == 10)
  309. {
  310. if (this.val_string == null || this.val_string.Length <= 0)
  311. {
  312. return '\0';
  313. }
  314. return this.val_string[0];
  315. }
  316. else
  317. {
  318. if (this.valueType == 0 || this.valueType == 1)
  319. {
  320. return this.val_int;
  321. }
  322. if (this.valueType == 2 || this.valueType == 3)
  323. {
  324. return this.val_float;
  325. }
  326. if (this.valueType == 4)
  327. {
  328. return this.val_vect2;
  329. }
  330. if (this.valueType == 5)
  331. {
  332. return this.val_vect3;
  333. }
  334. if (this.valueType == 6)
  335. {
  336. return this.val_vect4;
  337. }
  338. if (this.valueType == 7)
  339. {
  340. return this.val_color;
  341. }
  342. if (this.valueType == 8)
  343. {
  344. return this.val_rect;
  345. }
  346. if (this.valueType == 11)
  347. {
  348. return this.val_obj;
  349. }
  350. if (this.valueType == 12 && this.lsArray.Count > 0)
  351. {
  352. if (this.lsArray[0].valueType == 13)
  353. {
  354. bool[] array = new bool[this.lsArray.Count];
  355. for (int i = 0; i < this.lsArray.Count; i++)
  356. {
  357. array[i] = this.lsArray[i].val_bool;
  358. }
  359. return array;
  360. }
  361. if (this.lsArray[0].valueType == 9)
  362. {
  363. string[] array2 = new string[this.lsArray.Count];
  364. for (int j = 0; j < this.lsArray.Count; j++)
  365. {
  366. array2[j] = this.lsArray[j].val_string;
  367. }
  368. return array2;
  369. }
  370. if (this.lsArray[0].valueType == 10)
  371. {
  372. char[] array3 = new char[this.lsArray.Count];
  373. for (int k = 0; k < this.lsArray.Count; k++)
  374. {
  375. array3[k] = this.lsArray[k].val_string[0];
  376. }
  377. return array3;
  378. }
  379. if (this.lsArray[0].valueType == 0 || this.lsArray[0].valueType == 1)
  380. {
  381. int[] array4 = new int[this.lsArray.Count];
  382. for (int l = 0; l < this.lsArray.Count; l++)
  383. {
  384. array4[l] = this.lsArray[l].val_int;
  385. }
  386. return array4;
  387. }
  388. if (this.lsArray[0].valueType == 2 || this.lsArray[0].valueType == 3)
  389. {
  390. float[] array5 = new float[this.lsArray.Count];
  391. for (int m = 0; m < this.lsArray.Count; m++)
  392. {
  393. array5[m] = this.lsArray[m].val_float;
  394. }
  395. return array5;
  396. }
  397. if (this.lsArray[0].valueType == 4)
  398. {
  399. Vector2[] array6 = new Vector2[this.lsArray.Count];
  400. for (int n = 0; n < this.lsArray.Count; n++)
  401. {
  402. array6[n] = this.lsArray[n].val_vect2;
  403. }
  404. return array6;
  405. }
  406. if (this.lsArray[0].valueType == 5)
  407. {
  408. Vector3[] array7 = new Vector3[this.lsArray.Count];
  409. for (int num = 0; num < this.lsArray.Count; num++)
  410. {
  411. array7[num] = this.lsArray[num].val_vect3;
  412. }
  413. return array7;
  414. }
  415. if (this.lsArray[0].valueType == 6)
  416. {
  417. Vector4[] array8 = new Vector4[this.lsArray.Count];
  418. for (int num2 = 0; num2 < this.lsArray.Count; num2++)
  419. {
  420. array8[num2] = this.lsArray[num2].val_vect4;
  421. }
  422. return array8;
  423. }
  424. if (this.lsArray[0].valueType == 7)
  425. {
  426. Color[] array9 = new Color[this.lsArray.Count];
  427. for (int num3 = 0; num3 < this.lsArray.Count; num3++)
  428. {
  429. array9[num3] = this.lsArray[num3].val_color;
  430. }
  431. return array9;
  432. }
  433. if (this.lsArray[0].valueType == 8)
  434. {
  435. Rect[] array10 = new Rect[this.lsArray.Count];
  436. for (int num4 = 0; num4 < this.lsArray.Count; num4++)
  437. {
  438. array10[num4] = this.lsArray[num4].val_rect;
  439. }
  440. return array10;
  441. }
  442. if (this.lsArray[0].valueType == 11)
  443. {
  444. UnityEngine.Object[] array11 = new UnityEngine.Object[this.lsArray.Count];
  445. for (int num5 = 0; num5 < this.lsArray.Count; num5++)
  446. {
  447. array11[num5] = this.lsArray[num5].val_obj;
  448. }
  449. return array11;
  450. }
  451. }
  452. Debug.LogError("Animator: Type not found for Event Parameter.");
  453. return null;
  454. }
  455. }
  456. public AnimatorTimeline.JSONEventParameter toJSON()
  457. {
  458. AnimatorTimeline.JSONEventParameter jsoneventParameter = new AnimatorTimeline.JSONEventParameter();
  459. jsoneventParameter.valueType = this.valueType;
  460. if (this.valueType == 13)
  461. {
  462. jsoneventParameter.val_bool = this.val_bool;
  463. }
  464. if (this.valueType == 9)
  465. {
  466. jsoneventParameter.val_string = this.val_string;
  467. }
  468. if (this.valueType == 10)
  469. {
  470. if (this.val_string == null || this.val_string.Length <= 0)
  471. {
  472. jsoneventParameter.val_string = "\0";
  473. }
  474. jsoneventParameter.val_string = string.Empty + this.val_string[0];
  475. }
  476. if (this.valueType == 0 || this.valueType == 1)
  477. {
  478. jsoneventParameter.val_int = this.val_int;
  479. }
  480. if (this.valueType == 2 || this.valueType == 3)
  481. {
  482. jsoneventParameter.val_float = this.val_float;
  483. }
  484. if (this.valueType == 4)
  485. {
  486. AnimatorTimeline.JSONVector2 jsonvector = new AnimatorTimeline.JSONVector2();
  487. jsonvector.setValue(this.val_vect2);
  488. jsoneventParameter.val_vect2 = jsonvector;
  489. }
  490. if (this.valueType == 5)
  491. {
  492. AnimatorTimeline.JSONVector3 jsonvector2 = new AnimatorTimeline.JSONVector3();
  493. jsonvector2.setValue(this.val_vect3);
  494. jsoneventParameter.val_vect3 = jsonvector2;
  495. }
  496. if (this.valueType == 6)
  497. {
  498. AnimatorTimeline.JSONVector4 jsonvector3 = new AnimatorTimeline.JSONVector4();
  499. jsonvector3.setValue(this.val_vect4);
  500. jsoneventParameter.val_vect4 = jsonvector3;
  501. }
  502. if (this.valueType == 7)
  503. {
  504. AnimatorTimeline.JSONColor jsoncolor = new AnimatorTimeline.JSONColor();
  505. jsoncolor.setValue(this.val_color);
  506. jsoneventParameter.val_color = jsoncolor;
  507. }
  508. if (this.valueType == 8)
  509. {
  510. AnimatorTimeline.JSONRect jsonrect = new AnimatorTimeline.JSONRect();
  511. jsonrect.setValue(this.val_rect);
  512. jsoneventParameter.val_rect = jsonrect;
  513. }
  514. if (this.valueType == 11)
  515. {
  516. if (this.val_obj.GetType() != typeof(GameObject))
  517. {
  518. jsoneventParameter.val_obj_extra = this.val_obj.name;
  519. jsoneventParameter.val_obj = this.val_obj.GetType().Name;
  520. }
  521. else
  522. {
  523. jsoneventParameter.val_obj_extra = null;
  524. jsoneventParameter.val_obj = this.val_obj.name;
  525. }
  526. }
  527. if (this.valueType == 12 && this.lsArray.Count > 0)
  528. {
  529. AnimatorTimeline.JSONEventParameter[] array = new AnimatorTimeline.JSONEventParameter[this.lsArray.Count];
  530. for (int i = 0; i < this.lsArray.Count; i++)
  531. {
  532. array[i] = this.lsArray[i].toJSON();
  533. }
  534. jsoneventParameter.array = array;
  535. }
  536. return jsoneventParameter;
  537. }
  538. public object[] toArray()
  539. {
  540. object[] array = new object[this.lsArray.Count];
  541. for (int i = 0; i < this.lsArray.Count; i++)
  542. {
  543. array[i] = this.lsArray[i].toObject();
  544. }
  545. return array;
  546. }
  547. public bool isArray()
  548. {
  549. return this.lsArray.Count > 0;
  550. }
  551. public AMEventParameter CreateClone()
  552. {
  553. AMEventParameter ameventParameter = ScriptableObject.CreateInstance<AMEventParameter>();
  554. ameventParameter.val_bool = this.val_bool;
  555. ameventParameter.valueType = this.valueType;
  556. ameventParameter.val_int = this.val_int;
  557. ameventParameter.val_float = this.val_float;
  558. ameventParameter.val_vect2 = this.val_vect2;
  559. ameventParameter.val_vect3 = this.val_vect3;
  560. ameventParameter.val_vect4 = this.val_vect4;
  561. ameventParameter.val_color = this.val_color;
  562. ameventParameter.val_rect = this.val_rect;
  563. ameventParameter.val_string = this.val_string;
  564. ameventParameter.val_obj = this.val_obj;
  565. foreach (AMEventParameter ameventParameter2 in this.lsArray)
  566. {
  567. ameventParameter.lsArray.Add(ameventParameter2.CreateClone());
  568. }
  569. return ameventParameter;
  570. }
  571. public static AMEventParameter CreateFromStringData(string data_text)
  572. {
  573. AMEventParameter ameventParameter = ScriptableObject.CreateInstance<AMEventParameter>();
  574. string @string = Encoding.GetEncoding("UTF-8").GetString(Convert.FromBase64String(data_text));
  575. string[] array = @string.Split(new char[]
  576. {
  577. ':'
  578. });
  579. int num = 0;
  580. ameventParameter.val_bool = bool.Parse(array[num++]);
  581. ameventParameter.valueType = int.Parse(array[num++]);
  582. ameventParameter.val_int = int.Parse(array[num++]);
  583. ameventParameter.val_float = float.Parse(array[num++]);
  584. ameventParameter.val_vect2 = Parse.Vector2(array[num++]);
  585. ameventParameter.val_vect3 = Parse.Vector3(array[num++]);
  586. ameventParameter.val_vect4 = Parse.Vector4(array[num++]);
  587. ameventParameter.val_color = Parse.Color(array[num++]);
  588. ameventParameter.val_rect = default(Rect);
  589. ameventParameter.val_rect.x = float.Parse(array[num++]);
  590. ameventParameter.val_rect.y = float.Parse(array[num++]);
  591. ameventParameter.val_rect.width = float.Parse(array[num++]);
  592. ameventParameter.val_rect.height = float.Parse(array[num++]);
  593. ameventParameter.val_string = array[num++];
  594. ameventParameter.val_obj = null;
  595. ameventParameter.lsArray.Clear();
  596. int num2 = int.Parse(array[num++]);
  597. for (int i = 0; i < num2; i++)
  598. {
  599. ameventParameter.lsArray.Add(AMEventParameter.CreateFromStringData(array[num++]));
  600. }
  601. return ameventParameter;
  602. }
  603. public string ToStringData()
  604. {
  605. List<string> list = new List<string>();
  606. list.Add(this.val_bool.ToString());
  607. list.Add(this.valueType.ToString());
  608. list.Add(this.val_int.ToString());
  609. list.Add(this.val_float.ToString());
  610. list.Add(this.val_vect2.ToString("G"));
  611. list.Add(this.val_vect3.ToString("G"));
  612. list.Add(this.val_vect4.ToString("G"));
  613. list.Add(this.val_color.ToString("G"));
  614. list.Add(this.val_rect.x.ToString());
  615. list.Add(this.val_rect.y.ToString());
  616. list.Add(this.val_rect.width.ToString());
  617. list.Add(this.val_rect.height.ToString());
  618. list.Add(this.val_string);
  619. if (this.val_obj != null)
  620. {
  621. Debug.LogError("AMEventParameter::ToStringData\nオブジェクトの引数には対応していません\nnullで処理します");
  622. }
  623. list.Add(this.lsArray.Count.ToString());
  624. for (int i = 0; i < this.lsArray.Count; i++)
  625. {
  626. list.Add(this.lsArray[i].ToStringData());
  627. }
  628. string text = list[0];
  629. for (int j = 1; j < list.Count; j++)
  630. {
  631. text = text + ":" + list[j];
  632. }
  633. return Convert.ToBase64String(Encoding.GetEncoding("UTF-8").GetBytes(text));
  634. }
  635. public List<GameObject> getDependencies()
  636. {
  637. List<GameObject> list = new List<GameObject>();
  638. if (this.valueType == 11 && this.val_obj)
  639. {
  640. if (this.val_obj is GameObject)
  641. {
  642. list.Add((GameObject)this.val_obj);
  643. }
  644. else
  645. {
  646. list.Add((this.val_obj as Component).gameObject);
  647. }
  648. }
  649. else if (this.valueType == 12 && this.lsArray.Count > 0 && this.lsArray[0].valueType == 11)
  650. {
  651. foreach (AMEventParameter ameventParameter in this.lsArray)
  652. {
  653. if (ameventParameter.val_obj)
  654. {
  655. if (ameventParameter.val_obj is GameObject)
  656. {
  657. list.Add((GameObject)ameventParameter.val_obj);
  658. }
  659. else
  660. {
  661. list.Add((ameventParameter.val_obj as Component).gameObject);
  662. }
  663. }
  664. }
  665. }
  666. return list;
  667. }
  668. public bool updateDependencies(List<GameObject> newReferences, List<GameObject> oldReferences)
  669. {
  670. bool result = false;
  671. if (this.valueType == 11 && this.val_obj)
  672. {
  673. for (int i = 0; i < oldReferences.Count; i++)
  674. {
  675. if (this.val_obj is GameObject)
  676. {
  677. if (oldReferences[i] == this.val_obj)
  678. {
  679. this.val_obj = newReferences[i];
  680. result = true;
  681. break;
  682. }
  683. }
  684. else if (oldReferences[i] == (this.val_obj as Component).gameObject)
  685. {
  686. this.val_obj = newReferences[i].GetComponent(this.val_obj.GetType());
  687. result = true;
  688. break;
  689. }
  690. }
  691. }
  692. else if (this.valueType == 12 && this.lsArray.Count > 0 && this.lsArray[0].valueType == 11)
  693. {
  694. for (int j = 0; j < oldReferences.Count; j++)
  695. {
  696. foreach (AMEventParameter ameventParameter in this.lsArray)
  697. {
  698. if (ameventParameter.val_obj)
  699. {
  700. if (ameventParameter.val_obj is GameObject)
  701. {
  702. if (oldReferences[j] == ameventParameter.val_obj)
  703. {
  704. ameventParameter.val_obj = newReferences[j];
  705. result = true;
  706. break;
  707. }
  708. }
  709. else if (oldReferences[j] == (ameventParameter.val_obj as Component).gameObject)
  710. {
  711. ameventParameter.val_obj = newReferences[j].GetComponent(ameventParameter.val_obj.GetType());
  712. result = true;
  713. break;
  714. }
  715. }
  716. }
  717. }
  718. }
  719. return result;
  720. }
  721. public void Write(BinaryWriter binary)
  722. {
  723. binary.Write(this.valueType);
  724. if (this.isArray())
  725. {
  726. binary.Write(this.lsArray.Count);
  727. for (int i = 0; i < this.lsArray.Count; i++)
  728. {
  729. this.lsArray[i].Write(binary);
  730. }
  731. }
  732. else
  733. {
  734. AMEventParameter.ValueType valueType = (AMEventParameter.ValueType)this.valueType;
  735. if (valueType == AMEventParameter.ValueType.Integer || valueType == AMEventParameter.ValueType.Long)
  736. {
  737. binary.Write(this.val_int);
  738. }
  739. else if (valueType == AMEventParameter.ValueType.Float || valueType == AMEventParameter.ValueType.Double)
  740. {
  741. binary.Write(this.val_float);
  742. }
  743. else if (valueType == AMEventParameter.ValueType.Vector2)
  744. {
  745. binary.Write(this.val_vect2.x);
  746. binary.Write(this.val_vect2.y);
  747. }
  748. else if (valueType == AMEventParameter.ValueType.Vector3)
  749. {
  750. binary.Write(this.val_vect3.x);
  751. binary.Write(this.val_vect3.y);
  752. binary.Write(this.val_vect3.z);
  753. }
  754. else if (valueType == AMEventParameter.ValueType.Vector4)
  755. {
  756. binary.Write(this.val_vect4.x);
  757. binary.Write(this.val_vect4.y);
  758. binary.Write(this.val_vect4.z);
  759. binary.Write(this.val_vect4.w);
  760. }
  761. else if (valueType == AMEventParameter.ValueType.Color)
  762. {
  763. binary.Write(this.val_color.a);
  764. binary.Write(this.val_color.r);
  765. binary.Write(this.val_color.g);
  766. binary.Write(this.val_color.b);
  767. }
  768. else if (valueType == AMEventParameter.ValueType.Rect)
  769. {
  770. binary.Write(this.val_rect.xMin);
  771. binary.Write(this.val_rect.xMax);
  772. binary.Write(this.val_rect.yMin);
  773. binary.Write(this.val_rect.yMax);
  774. }
  775. else if (valueType == AMEventParameter.ValueType.String || valueType == AMEventParameter.ValueType.Char)
  776. {
  777. if (this.val_string == null)
  778. {
  779. this.val_string = string.Empty;
  780. }
  781. binary.Write(this.val_string);
  782. }
  783. else if (valueType == AMEventParameter.ValueType.Boolean)
  784. {
  785. binary.Write(this.val_bool);
  786. }
  787. else if (valueType == AMEventParameter.ValueType.Object)
  788. {
  789. string value = string.Empty;
  790. GameObject gameObject = this.val_obj as GameObject;
  791. NDebug.Assert(gameObject != null, "AMEventParameter error type.");
  792. value = UTY.GetObjectTreePath(gameObject);
  793. binary.Write(value);
  794. }
  795. }
  796. }
  797. public void Read(BinaryReader binary)
  798. {
  799. this.val_bool = false;
  800. this.valueType = 0;
  801. this.val_int = 0;
  802. this.val_float = 0f;
  803. this.val_vect2 = Vector2.zero;
  804. this.val_vect3 = Vector3.zero;
  805. this.val_vect4 = Vector4.zero;
  806. this.val_color = default(Color);
  807. this.val_rect = default(Rect);
  808. this.val_string = null;
  809. this.val_obj = null;
  810. this.lsArray.Clear();
  811. this.valueType = binary.ReadInt32();
  812. if (this.valueType == 12)
  813. {
  814. int num = binary.ReadInt32();
  815. for (int i = 0; i < num; i++)
  816. {
  817. AMEventParameter ameventParameter = new AMEventParameter();
  818. ameventParameter.Read(binary);
  819. this.lsArray.Add(ameventParameter);
  820. }
  821. }
  822. else
  823. {
  824. AMEventParameter.ValueType valueType = (AMEventParameter.ValueType)this.valueType;
  825. if (valueType == AMEventParameter.ValueType.Integer || valueType == AMEventParameter.ValueType.Long)
  826. {
  827. this.val_int = binary.ReadInt32();
  828. }
  829. else if (valueType == AMEventParameter.ValueType.Float || valueType == AMEventParameter.ValueType.Double)
  830. {
  831. this.val_float = binary.ReadSingle();
  832. }
  833. else if (valueType == AMEventParameter.ValueType.Vector2)
  834. {
  835. this.val_vect2.x = binary.ReadSingle();
  836. this.val_vect2.y = binary.ReadSingle();
  837. }
  838. else if (valueType == AMEventParameter.ValueType.Vector3)
  839. {
  840. this.val_vect3.x = binary.ReadSingle();
  841. this.val_vect3.y = binary.ReadSingle();
  842. this.val_vect3.z = binary.ReadSingle();
  843. }
  844. else if (valueType == AMEventParameter.ValueType.Vector4)
  845. {
  846. this.val_vect4.x = binary.ReadSingle();
  847. this.val_vect4.y = binary.ReadSingle();
  848. this.val_vect4.z = binary.ReadSingle();
  849. this.val_vect4.w = binary.ReadSingle();
  850. }
  851. else if (valueType == AMEventParameter.ValueType.Color)
  852. {
  853. this.val_color.a = binary.ReadSingle();
  854. this.val_color.r = binary.ReadSingle();
  855. this.val_color.g = binary.ReadSingle();
  856. this.val_color.b = binary.ReadSingle();
  857. }
  858. else if (valueType == AMEventParameter.ValueType.Rect)
  859. {
  860. this.val_rect.xMin = binary.ReadSingle();
  861. this.val_rect.xMax = binary.ReadSingle();
  862. this.val_rect.yMin = binary.ReadSingle();
  863. this.val_rect.yMax = binary.ReadSingle();
  864. }
  865. else if (valueType == AMEventParameter.ValueType.String || valueType == AMEventParameter.ValueType.Char)
  866. {
  867. this.val_string = binary.ReadString();
  868. }
  869. else if (valueType == AMEventParameter.ValueType.Boolean)
  870. {
  871. this.val_bool = binary.ReadBoolean();
  872. }
  873. else if (valueType == AMEventParameter.ValueType.Object)
  874. {
  875. string name = binary.ReadString();
  876. this.val_obj = GameObject.Find(name);
  877. }
  878. }
  879. }
  880. public bool val_bool;
  881. public int valueType;
  882. public int val_int;
  883. public float val_float;
  884. public Vector2 val_vect2;
  885. public Vector3 val_vect3;
  886. public Vector4 val_vect4;
  887. public Color val_color;
  888. public Rect val_rect;
  889. public string val_string;
  890. public UnityEngine.Object val_obj;
  891. public List<AMEventParameter> lsArray = new List<AMEventParameter>();
  892. public enum ValueType
  893. {
  894. Integer,
  895. Long,
  896. Float,
  897. Double,
  898. Vector2,
  899. Vector3,
  900. Vector4,
  901. Color,
  902. Rect,
  903. String,
  904. Char,
  905. Object,
  906. Array,
  907. Boolean
  908. }
  909. }