SceneUserEditMain.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. GameMain.Instance.CharacterMgr.SwapNewManBody(0, false);
  136. Maid man = GameMain.Instance.CharacterMgr.GetMan(0);
  137. this.manController = new PhotoManEditManager.Controller(man);
  138. man.Visible = true;
  139. man.AllProcProp();
  140. man.body0.SetChinkoVisible(false);
  141. string fn = "man_porse01.anm";
  142. man.CrossFade(fn, false, true, false, 0f, 1f);
  143. this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName;
  144. string b = man.GetProp("head").nFileNameRID.ToString();
  145. UIWFTabButton[] componentsInChildren = this.HeadItemTabPanel.GetComponentsInChildren<UIWFTabButton>();
  146. foreach (UIWFTabButton uiwftabButton in componentsInChildren)
  147. {
  148. if (uiwftabButton.name == b)
  149. {
  150. this.HeadItemTabPanel.Select(uiwftabButton);
  151. break;
  152. }
  153. }
  154. string b2 = man.GetProp("body").nFileNameRID.ToString();
  155. UIWFTabButton[] componentsInChildren2 = this.BodyItemTabPanel.GetComponentsInChildren<UIWFTabButton>();
  156. foreach (UIWFTabButton uiwftabButton2 in componentsInChildren2)
  157. {
  158. if (uiwftabButton2.name == b2)
  159. {
  160. this.BodyItemTabPanel.Select(uiwftabButton2);
  161. break;
  162. }
  163. }
  164. this.alphaSlider.value = (float)this.manController.alpha / 100f;
  165. this.alphaLabel.text = this.manController.alpha.ToString();
  166. this.abdomenSlider.value = this.manController.fat;
  167. float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero) * 100f;
  168. this.abdomenLabel.text = num.ToString();
  169. this.colorPalette.SetColor(this.manController.color);
  170. uGUITutorialPanel.OpenTutorial("SceneUserEdit", null, false);
  171. }
  172. public void UpdateBodyColorNumText()
  173. {
  174. if (this.manController == null)
  175. {
  176. return;
  177. }
  178. float[] array = new float[]
  179. {
  180. this.manController.color.r,
  181. this.manController.color.g,
  182. this.manController.color.b
  183. };
  184. for (int i = 0; i < this.colorLabels.Length; i++)
  185. {
  186. float num = (float)System.Math.Round((double)array[i], 4, MidpointRounding.AwayFromZero);
  187. int num2 = (int)(num * 255f);
  188. this.colorLabels[i].text = num2.ToString();
  189. }
  190. }
  191. protected override bool IsCallFadeIn()
  192. {
  193. this.fadeWaitCount++;
  194. return 2 < this.fadeWaitCount && this.completedSetUp;
  195. }
  196. private void OnChangePlayerName()
  197. {
  198. GameMain.Instance.CharacterMgr.status.playerName = this.playerNameInput.value;
  199. if (this.playerNameInput.value != GameMain.Instance.CharacterMgr.status.playerName)
  200. {
  201. this.playerNameInput.value = GameMain.Instance.CharacterMgr.status.playerName;
  202. }
  203. }
  204. public void OnSelectManHeadItem()
  205. {
  206. UIWFSelectButton current = UIWFSelectButton.current;
  207. if (this.manController == null || !current.isSelected)
  208. {
  209. return;
  210. }
  211. bool flag = false;
  212. int num = int.Parse(current.name);
  213. List<SceneEdit.SMenuItem>[] array = new List<SceneEdit.SMenuItem>[]
  214. {
  215. this.manEditManager.man_head_menu_list,
  216. this.manEditManager.man_body_menu_list
  217. };
  218. foreach (List<SceneEdit.SMenuItem> list in array)
  219. {
  220. foreach (SceneEdit.SMenuItem smenuItem in list)
  221. {
  222. if (num == smenuItem.m_nMenuFileRID)
  223. {
  224. this.manController.SetMenu(smenuItem);
  225. flag = (smenuItem.m_mpn == MPN.head);
  226. break;
  227. }
  228. }
  229. }
  230. if (!flag)
  231. {
  232. string fn = "man_porse01.anm";
  233. this.manController.man.CrossFade(fn, false, true, false, 0f, 1f);
  234. }
  235. }
  236. public override void Update()
  237. {
  238. base.Update();
  239. if (this.manController == null)
  240. {
  241. return;
  242. }
  243. if (this.manController.alpha.ToString() != this.alphaLabel.text)
  244. {
  245. this.alphaSlider.value = (float)this.manController.alpha / 100f;
  246. }
  247. }
  248. private void OnChangeAlphaSlider()
  249. {
  250. if (this.manController == null)
  251. {
  252. return;
  253. }
  254. int alpha = (int)System.Math.Ceiling((double)(this.alphaSlider.value * 100f));
  255. this.manController.alpha = alpha;
  256. this.alphaLabel.text = alpha.ToString();
  257. }
  258. private void OnChangeAbdomenSlider()
  259. {
  260. if (this.manController == null)
  261. {
  262. return;
  263. }
  264. this.manController.fat = (float)System.Math.Round((double)this.abdomenSlider.value, 2, MidpointRounding.AwayFromZero);
  265. float num = (float)System.Math.Round((double)this.manController.fat, 2, MidpointRounding.AwayFromZero);
  266. float num2 = num * 100f;
  267. this.abdomenLabel.text = num2.ToString();
  268. }
  269. private void OnChangeBodyColor(Color color)
  270. {
  271. if (this.manController == null)
  272. {
  273. return;
  274. }
  275. this.manController.color = color;
  276. color = this.manController.color;
  277. float[] array = new float[]
  278. {
  279. color.r,
  280. color.g,
  281. color.b
  282. };
  283. for (int i = 0; i < this.colorSliders.Length; i++)
  284. {
  285. List<EventDelegate> onChange = this.colorSliders[i].onChange;
  286. this.colorSliders[i].onChange = new List<EventDelegate>();
  287. this.colorSliders[i].value = array[i];
  288. this.colorSliders[i].onChange = onChange;
  289. }
  290. this.UpdateBodyColorNumText();
  291. }
  292. private void OnChangeSingleBodyColor()
  293. {
  294. if (this.manController == null)
  295. {
  296. return;
  297. }
  298. Color color = new Color(this.colorSliders[0].value, this.colorSliders[1].value, this.colorSliders[2].value);
  299. this.manController.color = color;
  300. color = this.manController.color;
  301. List<Action<Color>> onChangeValue = this.colorPalette.onChangeValue;
  302. this.colorPalette.onChangeValue = new List<Action<Color>>();
  303. this.colorPalette.SetColor(color);
  304. this.colorPalette.onChangeValue = onChangeValue;
  305. this.UpdateBodyColorNumText();
  306. }
  307. protected override void OnFinish()
  308. {
  309. if (this.manController != null && this.manController.man != null)
  310. {
  311. this.manController.man.Visible = false;
  312. }
  313. base.parent_mgr.CallScreen("Move");
  314. }
  315. public void OnClickOK()
  316. {
  317. this.Finish();
  318. }
  319. [SerializeField]
  320. private string bgmFile = "BGM009.ogg";
  321. [SerializeField]
  322. private UIInput playerNameInput;
  323. [SerializeField]
  324. private UIButton playerNameRandomButton;
  325. [SerializeField]
  326. private UIWFTabPanel HeadItemTabPanel;
  327. [SerializeField]
  328. private UIWFTabPanel BodyItemTabPanel;
  329. [SerializeField]
  330. private UISlider alphaSlider;
  331. [SerializeField]
  332. private UILabel alphaLabel;
  333. [SerializeField]
  334. private UISlider abdomenSlider;
  335. [SerializeField]
  336. private UILabel abdomenLabel;
  337. [SerializeField]
  338. private ColorrPaletteParts colorPalette;
  339. [SerializeField]
  340. private UISlider[] colorSliders;
  341. [SerializeField]
  342. private UILabel[] colorLabels;
  343. [SerializeField]
  344. private UIButton okButton;
  345. private PhotoManEditManager manEditManager;
  346. private PhotoManEditManager.Controller manController;
  347. private int fadeWaitCount;
  348. private bool calledOnCallEvent;
  349. private bool completedSetUp;
  350. }