SceneUserEditMain.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using com.workman.cm3d2.scene.dailyEtc;
  5. using UnityEngine;
  6. using wf;
  7. public class SceneUserEditMain : WfScreenChildren
  8. {
  9. public override void Awake()
  10. {
  11. base.Awake();
  12. NDebug.Assert(this.colorSliders.Length == 3, "colorSliders配列は3つ,RGBとして設定してください");
  13. EventDelegate.Add(this.playerNameInput.onChange, new EventDelegate.Callback(this.OnChangePlayerName));
  14. EventDelegate.Add(this.alphaSlider.onChange, new EventDelegate.Callback(this.OnChangeAlphaSlider));
  15. EventDelegate.Add(this.abdomenSlider.onChange, new EventDelegate.Callback(this.OnChangeAbdomenSlider));
  16. this.colorPalette.onChangeValue.Clear();
  17. this.colorPalette.onChangeValue.Add(new Action<Color>(this.OnChangeBodyColor));
  18. foreach (UISlider uislider in this.colorSliders)
  19. {
  20. EventDelegate.Add(uislider.onChange, new EventDelegate.Callback(this.OnChangeSingleBodyColor));
  21. }
  22. EventDelegate.Add(this.playerNameRandomButton.onClick, delegate()
  23. {
  24. this.playerNameInput.RemoveFocus();
  25. this.playerNameInput.value = MaidRandomName.GetPlayerName();
  26. });
  27. EventDelegate.Add(this.okButton.onClick, new EventDelegate.Callback(this.OnClickOK));
  28. }
  29. public void Start()
  30. {
  31. GameMain.Instance.StartCoroutine(this.SetupManEditManager());
  32. }
  33. public void OnDestroy()
  34. {
  35. if (this.manEditManager != null)
  36. {
  37. this.manEditManager.Destroy();
  38. this.manEditManager = null;
  39. }
  40. if (GameMain.Instance.MainCamera != null)
  41. {
  42. GameMain.Instance.MainCamera.SetTargetOffset(Vector3.zero, false);
  43. }
  44. }
  45. private IEnumerator SetupManEditManager()
  46. {
  47. GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay();
  48. GameMain.Instance.LoadIcon.force_draw_new = true;
  49. do
  50. {
  51. yield return null;
  52. }
  53. while (!GameMain.Instance.MenuDataBase.JobFinished());
  54. GameMain.Instance.LoadIcon.force_draw_new = false;
  55. this.manEditManager = new PhotoManEditManager();
  56. List<SceneEdit.SMenuItem>[] itemLists = new List<SceneEdit.SMenuItem>[]
  57. {
  58. this.manEditManager.man_head_menu_list,
  59. this.manEditManager.man_body_menu_list
  60. };
  61. UIWFTabPanel[] tagetPanels = new UIWFTabPanel[]
  62. {
  63. this.HeadItemTabPanel,
  64. this.BodyItemTabPanel
  65. };
  66. EventDelegate.Callback[] callBackFunctions = new EventDelegate.Callback[]
  67. {
  68. new EventDelegate.Callback(this.OnSelectManHeadItem),
  69. new EventDelegate.Callback(this.OnSelectManHeadItem)
  70. };
  71. for (int i = 0; i < itemLists.Length; i++)
  72. {
  73. UIWFTabPanel uiwftabPanel = tagetPanels[i];
  74. EventDelegate.Callback callback = callBackFunctions[i];
  75. foreach (SceneEdit.SMenuItem smenuItem in itemLists[i])
  76. {
  77. GameObject gameObject = Utility.CreatePrefab(uiwftabPanel.gameObject, "ScenePhotoMode/EditItemIcon", true);
  78. if (smenuItem.m_texIconRef != null)
  79. {
  80. Sprite sprite2D = Sprite.Create(smenuItem.m_texIconRef, new Rect(0f, 0f, (float)smenuItem.m_texIconRef.width, (float)smenuItem.m_texIconRef.height), default(Vector2));
  81. UI2DSprite componentInChildren = gameObject.GetComponentInChildren<UI2DSprite>();
  82. componentInChildren.sprite2D = sprite2D;
  83. componentInChildren.SetDimensions(smenuItem.m_texIconRef.width, smenuItem.m_texIconRef.height);
  84. UISprite component = UTY.GetChildObject(gameObject, "Frame", false).GetComponent<UISprite>();
  85. component.SetDimensions(74, 74);
  86. }
  87. UIWFTabButton component2 = gameObject.GetComponent<UIWFTabButton>();
  88. component2.name = smenuItem.m_nMenuFileRID.ToString();
  89. EventDelegate.Add(component2.onSelect, callback);
  90. }
  91. Utility.ResetNGUI(uiwftabPanel.GetComponent<UIGrid>());
  92. Utility.ResetNGUI(uiwftabPanel.transform.parent.GetComponent<UIScrollView>());
  93. uiwftabPanel.UpdateChildren();
  94. }
  95. do
  96. {
  97. yield return null;
  98. }
  99. while (!this.calledOnCallEvent && GameMain.Instance.CharacterMgr.IsBusy());
  100. this.CallAfter();
  101. this.completedSetUp = true;
  102. yield break;
  103. }
  104. protected override void OnCall()
  105. {
  106. this.calledOnCallEvent = true;
  107. }
  108. protected void CallAfter()
  109. {
  110. this.fadeWaitCount = 0;
  111. GameMain.Instance.MainLight.Reset();
  112. GameMain.Instance.CharacterMgr.ResetCharaPosAll();
  113. GameMain.Instance.CharacterMgr.DeactivateCharaAll();
  114. GameUtility.ResetCameraZero();
  115. if (!(base.parent_mgr as SceneUserEditManager).isFirstEdist)
  116. {
  117. this.playerNameInput.GetComponent<BoxCollider>().enabled = false;
  118. this.playerNameRandomButton.gameObject.SetActive(false);
  119. }
  120. if (GameMain.Instance.CharacterMgr.status.isDaytime)
  121. {
  122. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg);
  123. }
  124. else
  125. {
  126. GameMain.Instance.BgMgr.ChangeBg(DailyAPI.nightBg);
  127. }
  128. GameMain.Instance.SoundMgr.PlayBGM(this.bgmFile, 0.5f, true);
  129. CameraMain mainCamera = GameMain.Instance.MainCamera;
  130. mainCamera.Reset(CameraMain.CameraType.Target, true);
  131. mainCamera.SetTargetPos(new Vector3(0.08306749f, 1.299064f, 0.0249091f), true);
  132. mainCamera.SetDistance(2.2f, true);
  133. mainCamera.SetAroundAngle(new Vector2(177.9044f, 2.546583f), true);
  134. mainCamera.SetTargetOffset(new Vector3((float)Screen.width / 3f * 2f - (float)Screen.width / 2f, 0f, 0f), false);
  135. Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
  136. this.manController = new PhotoManEditManager.Controller(man);
  137. man.Visible = true;
  138. man.AllProcProp();
  139. man.body0.SetChinkoVisible(false);
  140. string fn = "man_porse01.anm";
  141. man.CrossFade(fn, false, true, false, 0f, 1f);
  142. this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName;
  143. string b = man.GetProp("head").nFileNameRID.ToString();
  144. UIWFTabButton[] componentsInChildren = this.HeadItemTabPanel.GetComponentsInChildren<UIWFTabButton>();
  145. foreach (UIWFTabButton uiwftabButton in componentsInChildren)
  146. {
  147. if (uiwftabButton.name == b)
  148. {
  149. this.HeadItemTabPanel.Select(uiwftabButton);
  150. break;
  151. }
  152. }
  153. string b2 = man.GetProp("body").nFileNameRID.ToString();
  154. UIWFTabButton[] componentsInChildren2 = this.BodyItemTabPanel.GetComponentsInChildren<UIWFTabButton>();
  155. foreach (UIWFTabButton uiwftabButton2 in componentsInChildren2)
  156. {
  157. if (uiwftabButton2.name == b2)
  158. {
  159. this.BodyItemTabPanel.Select(uiwftabButton2);
  160. break;
  161. }
  162. }
  163. this.alphaSlider.value = (float)this.manController.alpha / 100f;
  164. this.alphaLabel.text = this.manController.alpha.ToString();
  165. this.abdomenSlider.value = this.manController.fat;
  166. float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero) * 100f;
  167. this.abdomenLabel.text = num.ToString();
  168. this.colorPalette.SetColor(this.manController.color);
  169. uGUITutorialPanel.OpenTutorial("SceneUserEdit", null, false);
  170. }
  171. public void UpdateBodyColorNumText()
  172. {
  173. if (this.manController == null)
  174. {
  175. return;
  176. }
  177. float[] array = new float[]
  178. {
  179. this.manController.color.r,
  180. this.manController.color.g,
  181. this.manController.color.b
  182. };
  183. for (int i = 0; i < this.colorLabels.Length; i++)
  184. {
  185. float num = (float)System.Math.Round((double)array[i], 4, MidpointRounding.AwayFromZero);
  186. int num2 = (int)(num * 255f);
  187. this.colorLabels[i].text = num2.ToString();
  188. }
  189. }
  190. protected override bool IsCallFadeIn()
  191. {
  192. this.fadeWaitCount++;
  193. return 2 < this.fadeWaitCount && this.completedSetUp;
  194. }
  195. private void OnChangePlayerName()
  196. {
  197. GameMain.Instance.CharacterMgr.status.playerName = this.playerNameInput.value;
  198. if (this.playerNameInput.value != GameMain.Instance.CharacterMgr.status.playerName)
  199. {
  200. this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName;
  201. }
  202. }
  203. public void OnSelectManHeadItem()
  204. {
  205. UIWFSelectButton current = UIWFSelectButton.current;
  206. if (this.manController == null || !current.isSelected)
  207. {
  208. return;
  209. }
  210. bool flag = false;
  211. int num = int.Parse(current.name);
  212. List<SceneEdit.SMenuItem>[] array = new List<SceneEdit.SMenuItem>[]
  213. {
  214. this.manEditManager.man_head_menu_list,
  215. this.manEditManager.man_body_menu_list
  216. };
  217. foreach (List<SceneEdit.SMenuItem> list in array)
  218. {
  219. foreach (SceneEdit.SMenuItem smenuItem in list)
  220. {
  221. if (num == smenuItem.m_nMenuFileRID)
  222. {
  223. this.manController.SetMenu(smenuItem);
  224. flag = (smenuItem.m_mpn == MPN.head);
  225. break;
  226. }
  227. }
  228. }
  229. if (!flag)
  230. {
  231. string fn = "man_porse01.anm";
  232. this.manController.man.CrossFade(fn, false, true, false, 0f, 1f);
  233. }
  234. }
  235. public override void Update()
  236. {
  237. base.Update();
  238. if (this.manController == null)
  239. {
  240. return;
  241. }
  242. if (this.manController.alpha.ToString() != this.alphaLabel.text)
  243. {
  244. this.alphaSlider.value = (float)this.manController.alpha / 100f;
  245. }
  246. }
  247. private void OnChangeAlphaSlider()
  248. {
  249. if (this.manController == null)
  250. {
  251. return;
  252. }
  253. int alpha = (int)System.Math.Ceiling((double)(this.alphaSlider.value * 100f));
  254. this.manController.alpha = alpha;
  255. this.alphaLabel.text = alpha.ToString();
  256. }
  257. private void OnChangeAbdomenSlider()
  258. {
  259. if (this.manController == null)
  260. {
  261. return;
  262. }
  263. this.manController.fat = (float)System.Math.Round((double)this.abdomenSlider.value, 2, MidpointRounding.AwayFromZero);
  264. float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero);
  265. float num2 = num * 100f;
  266. this.abdomenLabel.text = num2.ToString();
  267. }
  268. private void OnChangeBodyColor(Color color)
  269. {
  270. if (this.manController == null)
  271. {
  272. return;
  273. }
  274. this.manController.color = color;
  275. color = this.manController.color;
  276. float[] array = new float[]
  277. {
  278. color.r,
  279. color.g,
  280. color.b
  281. };
  282. for (int i = 0; i < this.colorSliders.Length; i++)
  283. {
  284. List<EventDelegate> onChange = this.colorSliders[i].onChange;
  285. this.colorSliders[i].onChange = new List<EventDelegate>();
  286. this.colorSliders[i].value = array[i];
  287. this.colorSliders[i].onChange = onChange;
  288. }
  289. this.UpdateBodyColorNumText();
  290. }
  291. private void OnChangeSingleBodyColor()
  292. {
  293. if (this.manController == null)
  294. {
  295. return;
  296. }
  297. Color color = new Color(this.colorSliders[0].value, this.colorSliders[1].value, this.colorSliders[2].value);
  298. this.manController.color = color;
  299. color = this.manController.color;
  300. List<Action<Color>> onChangeValue = this.colorPalette.onChangeValue;
  301. this.colorPalette.onChangeValue = new List<Action<Color>>();
  302. this.colorPalette.SetColor(color);
  303. this.colorPalette.onChangeValue = onChangeValue;
  304. this.UpdateBodyColorNumText();
  305. }
  306. protected override void OnFinish()
  307. {
  308. if (this.manController != null && this.manController.man != null)
  309. {
  310. this.manController.man.Visible = false;
  311. }
  312. base.parent_mgr.CallScreen("Move");
  313. }
  314. public void OnClickOK()
  315. {
  316. this.Finish();
  317. }
  318. [SerializeField]
  319. private string bgmFile = "BGM009.ogg";
  320. [SerializeField]
  321. private UIInput playerNameInput;
  322. [SerializeField]
  323. private UIButton playerNameRandomButton;
  324. [SerializeField]
  325. private UIWFTabPanel HeadItemTabPanel;
  326. [SerializeField]
  327. private UIWFTabPanel BodyItemTabPanel;
  328. [SerializeField]
  329. private UISlider alphaSlider;
  330. [SerializeField]
  331. private UILabel alphaLabel;
  332. [SerializeField]
  333. private UISlider abdomenSlider;
  334. [SerializeField]
  335. private UILabel abdomenLabel;
  336. [SerializeField]
  337. private ColorrPaletteParts colorPalette;
  338. [SerializeField]
  339. private UISlider[] colorSliders;
  340. [SerializeField]
  341. private UILabel[] colorLabels;
  342. [SerializeField]
  343. private UIButton okButton;
  344. private PhotoManEditManager manEditManager;
  345. private PhotoManEditManager.Controller manController;
  346. private int fadeWaitCount;
  347. private bool calledOnCallEvent;
  348. private bool completedSetUp;
  349. }