SceneUserEditMain.cs 10 KB

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