TutorialPanel.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections.Generic;
  3. using PlayerStatus;
  4. using UnityEngine;
  5. using wf;
  6. public class TutorialPanel : MonoBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.current_page_ = 0;
  11. this.main_panel_ = base.gameObject.GetComponent<UIPanel>();
  12. this.sprite_ = UTY.GetChildObject(base.gameObject, "Image", false).GetComponent<UI2DSprite>();
  13. this.ok_button_ = UTY.GetChildObject(base.gameObject, "OK", false).GetComponent<UIButton>();
  14. EventDelegate.Add(this.ok_button_.onClick, new EventDelegate.Callback(this.OnClickNext));
  15. this.image_set_dic_.Add(TutorialPanel.ImageSet.MainMenu, new string[]
  16. {
  17. "cm3d2_tutorial_hirumenu00"
  18. });
  19. this.image_set_dic_.Add(TutorialPanel.ImageSet.Schedule, new string[]
  20. {
  21. "cm3d2_tutorial_schedule00"
  22. });
  23. this.image_set_dic_.Add(TutorialPanel.ImageSet.Yotogi, new string[]
  24. {
  25. "cm3d2_tutorial_skillselect00",
  26. "cm3d2_tutorial_skillselect01"
  27. });
  28. this.image_set_dic_.Add(TutorialPanel.ImageSet.Edit, new string[]
  29. {
  30. "cm3d2_tutorial_maidpoint"
  31. });
  32. this.image_set_dic_.Add(TutorialPanel.ImageSet.DeskCustom, new string[]
  33. {
  34. "cm3d2_tutorial_deskcustom"
  35. });
  36. this.image_set_dic_.Add(TutorialPanel.ImageSet.PhotoMode, new string[]
  37. {
  38. "cm3d2_tutorial_bg"
  39. });
  40. this.ok_button_.gameObject.SetActive(true);
  41. }
  42. public void Start()
  43. {
  44. this.CheckCallAwake();
  45. if (base.gameObject.activeSelf)
  46. {
  47. base.gameObject.SetActive(false);
  48. }
  49. }
  50. public void OnDestroy()
  51. {
  52. this.DestroyImage();
  53. }
  54. public void Reset()
  55. {
  56. this.CheckCallAwake();
  57. this.DestroyImage();
  58. iTween.Stop(base.gameObject);
  59. this.ok_button_.isEnabled = false;
  60. this.main_panel_.alpha = 0f;
  61. base.gameObject.SetActive(false);
  62. }
  63. public void SetImage(TutorialPanel.ImageSet image_set, bool absolut_call = false)
  64. {
  65. if (!absolut_call)
  66. {
  67. return;
  68. }
  69. string flagName = "__チュートリアルフラグ_" + image_set.ToString();
  70. Status status = GameMain.Instance.CharacterMgr.status;
  71. if (this.image_set_dic_.ContainsKey(image_set))
  72. {
  73. if (status.GetFlag(flagName) == 0 || absolut_call)
  74. {
  75. this.SetImage(this.image_set_dic_[image_set]);
  76. if (image_set == TutorialPanel.ImageSet.PhotoMode)
  77. {
  78. GameObject childObject = UTY.GetChildObject(base.gameObject, "PhotoPanel", false);
  79. childObject.SetActive(true);
  80. if (UTY.GetChildObject(childObject, "RightPanel", true) == null)
  81. {
  82. GameObject gameObject = Utility.CreatePrefab(childObject, "SceneTutorial/PhotoTutorialRightPanel", true);
  83. gameObject.name = "RightPanel";
  84. gameObject.SetActive(true);
  85. gameObject.transform.localPosition = Vector3.zero;
  86. GameObject childObject2 = UTY.GetChildObject(gameObject, "Field/Contents/Parent/Space", false);
  87. List<GameObject> list = new List<GameObject>();
  88. int num = 0;
  89. for (;;)
  90. {
  91. GameObject childObject3 = UTY.GetChildObject(childObject2, "Btn" + (num + 1).ToString(), true);
  92. if (childObject3 == null)
  93. {
  94. break;
  95. }
  96. childObject3.SetActive(true);
  97. list.Add(childObject3);
  98. num++;
  99. }
  100. UIGrid component = UTY.GetChildObject(childObject, "LeftPanel/Contents/UnitParent", false).GetComponent<UIGrid>();
  101. string[] array = new string[]
  102. {
  103. "このヘルプについて",
  104. "メイドを配置・選択をする",
  105. "メイドの移動や表示設定",
  106. "メイドのモーションを設定する",
  107. "メイドの表情を設定する",
  108. "メイドにアイテムを持たせる",
  109. "背景を変更する",
  110. "背景にオブジェクトを追加・削除する",
  111. "背景やオブジェクトの移動・表示設定",
  112. "ポーズエディットを開始する",
  113. "ポーズを編集する",
  114. "指先ブレンドを使う",
  115. "ショートカット一覧"
  116. };
  117. for (int i = 0; i < list.Count; i++)
  118. {
  119. GameObject gameObject2 = Utility.CreatePrefab(component.gameObject, "SceneTutorial/PhotModeTutorialItemBtn", true);
  120. gameObject2.GetComponentInChildren<UILabel>().text = array[i];
  121. gameObject2.GetComponent<PhotoTutorialButton>().SetTarget(list[i]);
  122. }
  123. component.Reposition();
  124. NGUITools.FindInParents<UIScrollView>(component.transform).ResetPosition();
  125. }
  126. UTY.GetChildObject(base.gameObject, "PhotoPanel/LeftPanel/Contents/UnitParent", false).GetComponent<UIGrid>().GetChild(0).GetComponent<PhotoTutorialButton>().OnClickEvent();
  127. }
  128. else
  129. {
  130. UTY.GetChildObject(base.gameObject, "PhotoPanel", false).gameObject.SetActive(false);
  131. }
  132. }
  133. status.SetFlag(flagName, 1);
  134. }
  135. }
  136. public void SetImage(string[] file_name_array)
  137. {
  138. this.CheckCallAwake();
  139. if (file_name_array == null || file_name_array.Length == 0)
  140. {
  141. return;
  142. }
  143. base.gameObject.SetActive(true);
  144. this.ok_button_.isEnabled = false;
  145. this.main_panel_.alpha = 0f;
  146. this.file_name_array_ = new string[file_name_array.Length];
  147. file_name_array.CopyTo(this.file_name_array_, 0);
  148. this.current_page_ = -1;
  149. this.OnClickNext();
  150. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  151. {
  152. "easetype",
  153. iTween.EaseType.easeOutQuad,
  154. "from",
  155. 0f,
  156. "to",
  157. 1f,
  158. "time",
  159. 0.5f,
  160. "delay",
  161. 0,
  162. "onUpdate",
  163. "OnUpdateFade",
  164. "onComplete",
  165. "OnFadeInEnd"
  166. }));
  167. }
  168. private void OnFadeInEnd()
  169. {
  170. this.ok_button_.isEnabled = true;
  171. }
  172. private bool SetPage(int page)
  173. {
  174. if (this.file_name_array_ == null || this.file_name_array_.Length <= page || page < 0)
  175. {
  176. return false;
  177. }
  178. this.DestroyImage();
  179. string text = string.Empty + this.file_name_array_[page] + ".tex";
  180. if (GameUty.FileSystem.IsExistentFile(text))
  181. {
  182. Texture2D texture2D = ImportCM.CreateTexture(text);
  183. Sprite sprite = Sprite.Create(texture2D, new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), default(Vector2));
  184. sprite.name = text;
  185. this.sprite_.sprite2D = sprite;
  186. this.sprite_.SetDimensions(texture2D.width, texture2D.height);
  187. UISprite component = this.ok_button_.gameObject.GetComponent<UISprite>();
  188. if (page == this.file_name_array_.Length - 1)
  189. {
  190. if (this.ok_button_.normalSprite != "cm3d2_common_okbuttom")
  191. {
  192. this.ok_button_.normalSprite = "cm3d2_common_okbuttom";
  193. }
  194. }
  195. else if (this.ok_button_.normalSprite != "cm3d2_common_nextbuttom")
  196. {
  197. this.ok_button_.normalSprite = "cm3d2_common_nextbuttom";
  198. }
  199. return true;
  200. }
  201. return false;
  202. }
  203. private void CheckCallAwake()
  204. {
  205. if (this.sprite_ == null)
  206. {
  207. this.Awake();
  208. }
  209. }
  210. private void OnClickNext()
  211. {
  212. this.current_page_++;
  213. if (!this.SetPage(this.current_page_))
  214. {
  215. this.ok_button_.isEnabled = false;
  216. iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
  217. {
  218. "easetype",
  219. iTween.EaseType.easeOutQuad,
  220. "from",
  221. 1f,
  222. "to",
  223. 0f,
  224. "time",
  225. 0.5f,
  226. "delay",
  227. 0,
  228. "onUpdate",
  229. "OnUpdateFade",
  230. "onComplete",
  231. "Reset"
  232. }));
  233. }
  234. }
  235. private void OnUpdateFade(float val)
  236. {
  237. if (base.gameObject.activeSelf)
  238. {
  239. this.main_panel_.alpha = val;
  240. }
  241. }
  242. private void DestroyImage()
  243. {
  244. if (this.sprite_ != null && this.sprite_.sprite2D != null && this.sprite_.sprite2D.texture != null)
  245. {
  246. UnityEngine.Object.DestroyImmediate(this.sprite_.sprite2D.texture);
  247. }
  248. }
  249. private Dictionary<TutorialPanel.ImageSet, string[]> image_set_dic_ = new Dictionary<TutorialPanel.ImageSet, string[]>();
  250. private int current_page_;
  251. private string[] file_name_array_;
  252. private UIPanel main_panel_;
  253. private UI2DSprite sprite_;
  254. private UIButton ok_button_;
  255. public enum ImageSet
  256. {
  257. MainMenu,
  258. Trophy,
  259. Schedule,
  260. Yotogi,
  261. CompetitiveShow,
  262. Edit,
  263. DeskCustom,
  264. PhotoMode
  265. }
  266. }