AMCameraSwitcherAction.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class AMCameraSwitcherAction : AMAction
  6. {
  7. public override string ToString(int codeLanguage, int frameRate)
  8. {
  9. if (this.endFrame == -1 || !this.hasStartTarget() || this.targetsAreEqual())
  10. {
  11. return null;
  12. }
  13. bool flag = this.cameraFadeType == 5;
  14. string text;
  15. if (codeLanguage == 0)
  16. {
  17. text = string.Concat(new object[]
  18. {
  19. "AMTween.CameraFade (AMTween.Fade.",
  20. Enum.GetName(typeof(AMTween.Fade), this.cameraFadeType),
  21. ", ",
  22. (!flag && !this.still).ToString().ToLower(),
  23. ", ",
  24. this.getParametersString(codeLanguage),
  25. ", AMTween.Hash (\"delay\", ",
  26. base.getWaitTime(frameRate, 0f),
  27. "f, \"time\", ",
  28. this.getTime(frameRate),
  29. "f, "
  30. });
  31. if (!flag)
  32. {
  33. text = text + base.getEaseString(codeLanguage) + ", ";
  34. }
  35. if (this.isReversed())
  36. {
  37. text += "\"reversed\", true, ";
  38. }
  39. if (AMCameraFade.needsTexture(this.cameraFadeType))
  40. {
  41. text = text + "\"texture\", AMTween.LoadTexture2D(\"" + this.irisShape.name + "\"), ";
  42. }
  43. if (!flag)
  44. {
  45. if (this.startTargetType == 0)
  46. {
  47. if (this.startCamera)
  48. {
  49. text = text + "\"camera1\", GameObject.Find(\"" + this.startCamera.gameObject.name + "\").camera, ";
  50. }
  51. else
  52. {
  53. text += "\"camera1\", null /* Missing Camera */";
  54. }
  55. }
  56. else
  57. {
  58. string text2 = text;
  59. text = string.Concat(new object[]
  60. {
  61. text2,
  62. "\"color1\", new Color(",
  63. this.startColor.r,
  64. "f, ",
  65. this.startColor.g,
  66. "f, ",
  67. this.startColor.b,
  68. "f, ",
  69. this.startColor.a,
  70. "f), "
  71. });
  72. }
  73. }
  74. if (this.endTargetType == 0)
  75. {
  76. if (this.endCamera)
  77. {
  78. text = text + "\"camera2\", GameObject.Find(\"" + this.endCamera.gameObject.name + "\").camera";
  79. }
  80. else
  81. {
  82. text += "\"camera2\", null /* Missing Camera */";
  83. }
  84. }
  85. else
  86. {
  87. string text2 = text;
  88. text = string.Concat(new object[]
  89. {
  90. text2,
  91. "\"color2\", new Color(",
  92. this.endColor.r,
  93. "f, ",
  94. this.endColor.g,
  95. "f, ",
  96. this.endColor.b,
  97. "f, ",
  98. this.endColor.a,
  99. "f)"
  100. });
  101. }
  102. if ((!flag && this.startTargetType == 0) || this.endTargetType == 0)
  103. {
  104. text += ", \"allcameras\", csCameras";
  105. }
  106. text += "));";
  107. }
  108. else
  109. {
  110. text = string.Concat(new object[]
  111. {
  112. "AMTween.CameraFade (AMTween.Fade.",
  113. Enum.GetName(typeof(AMTween.Fade), this.cameraFadeType),
  114. ", ",
  115. (!flag && !this.still).ToString().ToLower(),
  116. ", ",
  117. this.getParametersString(codeLanguage),
  118. ", {\"delay\": ",
  119. base.getWaitTime(frameRate, 0f),
  120. ", \"time\": ",
  121. this.getTime(frameRate),
  122. ", "
  123. });
  124. if (!flag)
  125. {
  126. text = text + base.getEaseString(codeLanguage) + ", ";
  127. }
  128. if (this.isReversed())
  129. {
  130. text += "\"reversed\": true, ";
  131. }
  132. if (AMCameraFade.needsTexture(this.cameraFadeType))
  133. {
  134. text = text + "\"texture\": AMTween.LoadTexture2D(\"" + this.irisShape.name + "\"), ";
  135. }
  136. if (!flag)
  137. {
  138. if (this.startTargetType == 0)
  139. {
  140. if (this.startCamera)
  141. {
  142. text = text + "\"camera1\": GameObject.Find(\"" + this.startCamera.gameObject.name + "\").camera, ";
  143. }
  144. else
  145. {
  146. text += "\"camera1\", null /* Missing Camera */";
  147. }
  148. }
  149. else
  150. {
  151. string text2 = text;
  152. text = string.Concat(new object[]
  153. {
  154. text2,
  155. "\"color1\": Color(",
  156. this.startColor.r,
  157. ", ",
  158. this.startColor.g,
  159. ", ",
  160. this.startColor.b,
  161. ", ",
  162. this.startColor.a,
  163. "), "
  164. });
  165. }
  166. }
  167. if (this.endTargetType == 0)
  168. {
  169. if (this.endCamera)
  170. {
  171. text = text + "\"camera2\", GameObject.Find(\"" + this.endCamera.gameObject.name + "\").camera";
  172. }
  173. else
  174. {
  175. text += "\"camera2\", null /* Missing Camera */";
  176. }
  177. }
  178. else
  179. {
  180. string text2 = text;
  181. text = string.Concat(new object[]
  182. {
  183. text2,
  184. "\"color2\": Color(",
  185. this.endColor.r,
  186. ", ",
  187. this.endColor.g,
  188. ", ",
  189. this.endColor.b,
  190. ", ",
  191. this.endColor.a,
  192. ")"
  193. });
  194. }
  195. if ((!flag && this.startTargetType == 0) || this.endTargetType == 0)
  196. {
  197. text += ", \"allcameras\", csCameras";
  198. }
  199. text += "));";
  200. }
  201. return text;
  202. }
  203. public void execute(int frameRate, float delay, Camera[] allCameras)
  204. {
  205. if (this.endFrame == -1 || !this.hasTargets() || this.targetsAreEqual())
  206. {
  207. return;
  208. }
  209. float[] array = this.cameraFadeParameters.ToArray();
  210. Hashtable hashtable = new Hashtable();
  211. hashtable.Add("time", this.getTime(frameRate));
  212. hashtable.Add("delay", base.getWaitTime(frameRate, delay));
  213. if (this.easeType == 32)
  214. {
  215. hashtable.Add("easecurve", base.easeCurve);
  216. }
  217. else
  218. {
  219. hashtable.Add("easetype", (AMTween.EaseType)this.easeType);
  220. }
  221. hashtable.Add("reversed", AMTween.isTransitionReversed(this.cameraFadeType, array));
  222. hashtable.Add("allcameras", allCameras);
  223. if (this.startTargetType == 0)
  224. {
  225. hashtable.Add("camera1", this.startCamera);
  226. }
  227. else
  228. {
  229. hashtable.Add("color1", this.startColor);
  230. }
  231. if (this.endTargetType == 0)
  232. {
  233. hashtable.Add("camera2", this.endCamera);
  234. }
  235. else
  236. {
  237. hashtable.Add("color2", this.endColor);
  238. }
  239. if (AMCameraFade.needsTexture(this.cameraFadeType))
  240. {
  241. hashtable.Add("texture", this.irisShape);
  242. }
  243. AMTween.CameraFade(this.cameraFadeType, !this.still, array, hashtable);
  244. }
  245. public string getParametersString(int codeLanguage)
  246. {
  247. string str = string.Empty;
  248. str += ((codeLanguage != 0) ? "[" : "new float[]{");
  249. for (int i = 0; i < this.cameraFadeParameters.Count; i++)
  250. {
  251. str += this.cameraFadeParameters[i].ToString();
  252. if (codeLanguage == 0)
  253. {
  254. str += "f";
  255. }
  256. if (i <= this.cameraFadeParameters.Count - 2)
  257. {
  258. str += ", ";
  259. }
  260. }
  261. return str + ((codeLanguage != 0) ? "]" : "}");
  262. }
  263. public override int getNumberOfFrames()
  264. {
  265. return this.endFrame - this.startFrame;
  266. }
  267. public float getTime(int frameRate)
  268. {
  269. return (float)this.getNumberOfFrames() / (float)frameRate;
  270. }
  271. public bool hasTargets()
  272. {
  273. return this.hasStartTarget() && this.hasEndTarget();
  274. }
  275. public bool hasStartTarget()
  276. {
  277. return this.startTargetType != 0 || this.startCamera;
  278. }
  279. public bool hasEndTarget()
  280. {
  281. return this.endFrame != -1 && (this.endTargetType != 0 || this.endCamera);
  282. }
  283. public bool targetsAreEqual()
  284. {
  285. return this.startTargetType == this.endTargetType && (this.startTargetType != 0 || !(this.startCamera != this.endCamera)) && (this.startTargetType != 1 || !(this.startColor != this.endColor));
  286. }
  287. public string getStartTargetName()
  288. {
  289. if (this.startTargetType != 0)
  290. {
  291. return "Color";
  292. }
  293. if (this.startCamera)
  294. {
  295. return this.startCamera.gameObject.name;
  296. }
  297. return "None";
  298. }
  299. public string getEndTargetName()
  300. {
  301. if (this.endTargetType != 0)
  302. {
  303. return "Color";
  304. }
  305. if (this.endCamera)
  306. {
  307. return this.endCamera.gameObject.name;
  308. }
  309. return "None";
  310. }
  311. public bool isReversed()
  312. {
  313. return AMTween.isTransitionReversed(this.cameraFadeType, this.cameraFadeParameters.ToArray());
  314. }
  315. public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
  316. {
  317. if (this.endFrame == -1 || !this.hasTargets() || this.targetsAreEqual())
  318. {
  319. return null;
  320. }
  321. AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
  322. jsonaction.method = "camerafade";
  323. jsonaction.delay = base.getWaitTime(frameRate, 0f);
  324. jsonaction.time = this.getTime(frameRate);
  325. base.setupJSONActionEase(jsonaction);
  326. jsonaction.ints = new int[]
  327. {
  328. this.cameraFadeType,
  329. this.startTargetType,
  330. this.endTargetType
  331. };
  332. List<string> list = new List<string>();
  333. List<AnimatorTimeline.JSONColor> list2 = new List<AnimatorTimeline.JSONColor>();
  334. if (this.startTargetType == 0)
  335. {
  336. list.Add(this.startCamera.gameObject.name);
  337. list2.Add(null);
  338. }
  339. else
  340. {
  341. AnimatorTimeline.JSONColor jsoncolor = new AnimatorTimeline.JSONColor();
  342. jsoncolor.setValue(this.startColor);
  343. list2.Add(jsoncolor);
  344. list.Add(null);
  345. }
  346. if (this.endTargetType == 0)
  347. {
  348. list.Add(this.endCamera.gameObject.name);
  349. list2.Add(null);
  350. }
  351. else
  352. {
  353. AnimatorTimeline.JSONColor jsoncolor2 = new AnimatorTimeline.JSONColor();
  354. jsoncolor2.setValue(this.endColor);
  355. list2.Add(jsoncolor2);
  356. list.Add(null);
  357. }
  358. jsonaction.strings = list.ToArray();
  359. jsonaction.colors = list2.ToArray();
  360. jsonaction.bools = new bool[]
  361. {
  362. this.isReversed(),
  363. !this.still
  364. };
  365. if (AMCameraFade.needsTexture(this.cameraFadeType))
  366. {
  367. jsonaction.stringsExtra = new string[]
  368. {
  369. this.irisShape.name
  370. };
  371. }
  372. jsonaction.floats = this.cameraFadeParameters.ToArray();
  373. return jsonaction;
  374. }
  375. public int endFrame;
  376. public int cameraFadeType;
  377. public List<float> cameraFadeParameters;
  378. public Texture2D irisShape;
  379. public bool still;
  380. public int startTargetType;
  381. public int endTargetType;
  382. public Camera startCamera;
  383. public Camera endCamera;
  384. public Color startColor;
  385. public Color endColor;
  386. }