SceneCasinoShop.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using I2.Loc;
  6. using PlayerStatus;
  7. using UnityEngine;
  8. using wf;
  9. public class SceneCasinoShop : KasaSceneMgr<SceneCasinoShop>
  10. {
  11. public CasinoShopItem SelectTrywear
  12. {
  13. get
  14. {
  15. return this.m_SelectTrywear;
  16. }
  17. }
  18. protected override void Awake()
  19. {
  20. this.m_ScrollPanel = this.m_ShopItemUI.ScrollView.GetComponent<UIPanel>();
  21. GameMain.Instance.CharacterMgr.SetActiveMaid(CasinoDataMgr.Instance.DealerMaid, 0);
  22. this.m_TrywearMaid = CasinoDataMgr.Instance.DealerMaid;
  23. Facility.CostumeType typeCostume = CasinoDataMgr.Instance.CurrentCasino.typeCostume;
  24. if (typeCostume != Facility.CostumeType.Heroine)
  25. {
  26. if (typeCostume != Facility.CostumeType.Default)
  27. {
  28. if (typeCostume == Facility.CostumeType.Edit)
  29. {
  30. CasinoDataMgr.Instance.CurrentCasino.UpdateMaidCostumeToEditCostume(this.m_TrywearMaid, false);
  31. }
  32. }
  33. else
  34. {
  35. CasinoDataMgr.Instance.CurrentCasino.UpdateMaidCostumeToDefaultCostume(this.m_TrywearMaid);
  36. }
  37. CasinoDataMgr.Instance.DealerMaid.AllProcPropSeqStart();
  38. }
  39. this.m_TrywearMaid.Visible = true;
  40. this.m_TrywearMaid.EyeToCamera(Maid.EyeMoveType.目と顔を向ける, 0f);
  41. base.Awake();
  42. this.m_CamMoveSupport = base.GetComponent<WfCameraMoveSupport>();
  43. this.m_InfoData.UIobj = this.m_ItemInfoUI;
  44. this.m_InfoData.Icon = this.m_ItemInfoUI.transform.Find("Base/Icon").GetComponent<UI2DSprite>();
  45. this.m_InfoData.InfoLabel = this.m_ItemInfoUI.transform.Find("Base/Info").GetComponent<UILabel>();
  46. this.m_InfoData.Namelabel = this.m_ItemInfoUI.transform.Find("Base/Title").GetComponent<UILabel>();
  47. Localize component = this.m_InfoData.InfoLabel.GetComponent<Localize>();
  48. if (component == null)
  49. {
  50. this.m_InfoData.InfoLabel.gameObject.AddComponent<Localize>();
  51. }
  52. component = this.m_InfoData.Namelabel.GetComponent<Localize>();
  53. if (component == null)
  54. {
  55. this.m_InfoData.Namelabel.gameObject.AddComponent<Localize>();
  56. }
  57. NDebug.Assert(GameMain.Instance.ScriptMgr.adv_kag.tag_backup.ContainsKey("label"), "OK時のラベルが未指定です");
  58. this.m_JumpLabel = GameMain.Instance.ScriptMgr.adv_kag.tag_backup["label"];
  59. EventDelegate.Add(this.m_TrywearButton.onClick, new EventDelegate.Callback(this.TryWear));
  60. EventDelegate.Add(this.m_TrycancelButton.onClick, new EventDelegate.Callback(this.TryCancel));
  61. EventDelegate.Add(this.m_CamRecetButton.onClick, new EventDelegate.Callback(this.CamRecet));
  62. EventDelegate.Add(this.m_OkButton.onClick, new EventDelegate.Callback(this.ClickOKButton));
  63. this.m_TrywearButton.isEnabled = false;
  64. this.m_TrycancelButton.isEnabled = false;
  65. this.CreateCategoryUI();
  66. }
  67. private void Start()
  68. {
  69. this.m_CategoryUI.TabPanel.Select(this.m_ButtonCategoryPair.Keys.First<UIWFTabButton>());
  70. ExChangeUI instance = ExChangeUI.Instance;
  71. instance.FadeOutStartAction = (Action)Delegate.Combine(instance.FadeOutStartAction, new Action(this.UpdateUIState));
  72. ExChangeUI instance2 = ExChangeUI.Instance;
  73. instance2.FadeInStartAction = (Action)Delegate.Combine(instance2.FadeInStartAction, new Action(delegate()
  74. {
  75. this.m_NguiEnable = false;
  76. }));
  77. ExChangeUI instance3 = ExChangeUI.Instance;
  78. instance3.FadeOutStartAction = (Action)Delegate.Combine(instance3.FadeOutStartAction, new Action(delegate()
  79. {
  80. this.m_NguiEnable = true;
  81. }));
  82. this.UpdateUIState();
  83. base.StartCoroutine(this.ScrollRecet());
  84. }
  85. private void LateUpdate()
  86. {
  87. this.m_NguiCam.EnableProcess &= this.m_NguiEnable;
  88. }
  89. private IEnumerator ScrollRecet()
  90. {
  91. for (int i = 0; i < 5; i++)
  92. {
  93. yield return null;
  94. }
  95. this.m_ItemSrollBar.value = 0f;
  96. yield break;
  97. }
  98. protected override void LoadEnd()
  99. {
  100. GameMain.Instance.ScriptMgr.LoadMotionScript(0, false, "h_kaiwa_tati_001.ks", "*会話立ち待機", string.Empty, string.Empty, false, true, false);
  101. base.StartCoroutine(this.AnimateWait());
  102. }
  103. private IEnumerator AnimateWait()
  104. {
  105. for (int i = 0; i < 5; i++)
  106. {
  107. yield return null;
  108. }
  109. Transform head_bone = this.m_TrywearMaid.body0.GetBone("Bip01 Head");
  110. this.m_TargetPos = head_bone.position + this.m_HeadCamOffset;
  111. base.SetCamera();
  112. this.m_CamMoveSupport.SaveCameraPosition();
  113. base.LoadEnd();
  114. yield break;
  115. }
  116. private void CreateCategoryUI()
  117. {
  118. foreach (CasinoShopItem.Category category in (CasinoShopItem.Category[])Enum.GetValues(typeof(CasinoShopItem.Category)))
  119. {
  120. GameObject gameObject = Utility.CreatePrefab(this.m_CategoryUI.Grid.gameObject, "SceneCasinoShop/Prefab/CategoryUI", true);
  121. UILabel componentInChildren = gameObject.GetComponentInChildren<UILabel>();
  122. componentInChildren.text = ((category != CasinoShopItem.Category.Costume) ? "施設強化素材" : "コスチューム");
  123. Utility.SetLocalizeTerm(componentInChildren, (category != CasinoShopItem.Category.Costume) ? "SceneShop/メインカテゴリー/施設強化素材" : "SceneEdit/カテゴリー/サブ/コスチューム", false);
  124. UIWFTabButton componentInChildren2 = gameObject.GetComponentInChildren<UIWFTabButton>();
  125. this.m_ButtonCategoryPair.Add(componentInChildren2, category);
  126. EventDelegate.Add(componentInChildren2.onSelect, new EventDelegate.Callback(this.SelectCategory));
  127. }
  128. this.m_CategoryUI.Grid.repositionNow = true;
  129. this.m_CategoryUI.ScrollView.ResetPosition();
  130. this.m_CategoryUI.TabPanel.UpdateChildren();
  131. }
  132. private void SelectCategory()
  133. {
  134. IEnumerator enumerator = this.m_ShopItemUI.Grid.transform.GetEnumerator();
  135. try
  136. {
  137. while (enumerator.MoveNext())
  138. {
  139. object obj = enumerator.Current;
  140. Transform transform = (Transform)obj;
  141. UnityEngine.Object.Destroy(transform.gameObject);
  142. }
  143. }
  144. finally
  145. {
  146. IDisposable disposable;
  147. if ((disposable = (enumerator as IDisposable)) != null)
  148. {
  149. disposable.Dispose();
  150. }
  151. }
  152. this.m_TrywearButton.isEnabled = false;
  153. this.CreateItemUI();
  154. this.m_AllowposStart = this.m_CategoryAllow.transform.position;
  155. this.m_AllowposEnd = this.m_AllowposStart;
  156. this.m_AllowposEnd.y = UIWFTabButton.current.transform.position.y;
  157. base.StartCoroutine(KasaiUtility.TimeCroutine(this.m_AllowMove, new Action<float>(this.AllowMovement), null));
  158. }
  159. private void AllowMovement(float time)
  160. {
  161. float t = KasaiUtility.SinRate01(time, this.m_AllowMove, false, false);
  162. this.m_CategoryAllow.transform.position = Vector3.Lerp(this.m_AllowposStart, this.m_AllowposEnd, t);
  163. }
  164. private void CreateItemUI()
  165. {
  166. CasinoShopItem.Category category = this.m_ButtonCategoryPair[UIWFTabButton.current];
  167. this.m_ItemUIList.Clear();
  168. foreach (CasinoShopItem item_data in CasinoDataMgr.Instance.GetShopItem(category))
  169. {
  170. GameObject gameObject = Utility.CreatePrefab(this.m_ShopItemUI.Grid.gameObject, "SceneCasinoShop/Prefab/CasinoShopItem", true);
  171. CasinoItemUI component = gameObject.GetComponent<CasinoItemUI>();
  172. component.Init(item_data);
  173. this.m_ItemUIList.Add(component);
  174. }
  175. this.m_ShopItemUI.Grid.repositionNow = true;
  176. this.m_ShopItemUI.ScrollView.ResetPosition();
  177. this.m_ShopItemUI.TabPanel.UpdateChildren();
  178. }
  179. private void RecetTrywear(Action load_end = null)
  180. {
  181. Facility.CostumeType costume_type = CasinoDataMgr.Instance.CurrentCasino.typeCostume;
  182. MPN[] facilityCostumeEnableMPN = FacilityDataTable.GetFacilityCostumeEnableMPN();
  183. foreach (MPN mpn in facilityCostumeEnableMPN)
  184. {
  185. if (this.m_BackUpwear.ContainsKey(mpn))
  186. {
  187. this.m_TrywearMaid.SetProp(mpn, this.m_BackUpwear[mpn].strFileName, this.m_BackUpwear[mpn].nFileNameRID, false, false);
  188. }
  189. }
  190. this.m_TrywearMaid.body0.SetMaskMode(TBody.MaskMode.None);
  191. SceneEdit.AllProcPropSeqStart(this.m_TrywearMaid);
  192. if (costume_type != Facility.CostumeType.Heroine)
  193. {
  194. Action end_call = delegate()
  195. {
  196. if (costume_type != Facility.CostumeType.Default)
  197. {
  198. if (costume_type == Facility.CostumeType.Edit)
  199. {
  200. CasinoDataMgr.Instance.CurrentCasino.UpdateMaidCostumeToEditCostume(this.m_TrywearMaid, false);
  201. }
  202. }
  203. else
  204. {
  205. CasinoDataMgr.Instance.CurrentCasino.UpdateMaidCostumeToDefaultCostume(this.m_TrywearMaid);
  206. }
  207. SceneEdit.AllProcPropSeqStart(this.m_TrywearMaid);
  208. this.StartCoroutine(KasaiUtility.CharaLoadWait(load_end));
  209. };
  210. base.StartCoroutine(KasaiUtility.CharaLoadWait(end_call));
  211. }
  212. else
  213. {
  214. base.StartCoroutine(KasaiUtility.CharaLoadWait(load_end));
  215. }
  216. }
  217. private void TryWear()
  218. {
  219. if (this.m_TrywearMaid.IsBusy || this.m_SelectTrywear == null || !this.m_SelectTrywear.IsCategoryCostume)
  220. {
  221. return;
  222. }
  223. Facility.CostumeType typeCostume = CasinoDataMgr.Instance.CurrentCasino.typeCostume;
  224. MPN[] facilityCostumeEnableMPN = FacilityDataTable.GetFacilityCostumeEnableMPN();
  225. foreach (MPN mpn in facilityCostumeEnableMPN)
  226. {
  227. if (typeCostume != Facility.CostumeType.Heroine)
  228. {
  229. this.m_TrywearMaid.ResetProp(mpn, false);
  230. }
  231. if (this.m_TrywearItem == null)
  232. {
  233. if (!this.m_BackUpwear.ContainsKey(mpn))
  234. {
  235. MaidProp prop = this.m_TrywearMaid.GetProp(mpn);
  236. MaidProp maidProp = new MaidProp();
  237. maidProp.strFileName = prop.strFileName;
  238. maidProp.nFileNameRID = prop.nFileNameRID;
  239. this.m_BackUpwear.Add(mpn, maidProp);
  240. }
  241. }
  242. }
  243. this.m_TrywearItem = this.m_SelectTrywear;
  244. Action action = delegate()
  245. {
  246. this.m_TrywearItem.TryWear(this.m_TrywearMaid);
  247. SceneEdit.AllProcPropSeqStart(this.m_TrywearMaid);
  248. this.m_TrycancelButton.isEnabled = true;
  249. };
  250. if (typeCostume == Facility.CostumeType.Heroine)
  251. {
  252. action();
  253. }
  254. else
  255. {
  256. SceneEdit.AllProcPropSeqStart(this.m_TrywearMaid);
  257. base.StartCoroutine(KasaiUtility.CharaLoadWait(action));
  258. }
  259. }
  260. private void TryCancel()
  261. {
  262. if (this.m_TrywearMaid.IsBusy || this.m_TrywearItem == null || !this.m_TrywearItem.IsCategoryCostume)
  263. {
  264. return;
  265. }
  266. this.m_TrycancelButton.isEnabled = false;
  267. this.RecetTrywear(null);
  268. this.m_TrywearItem = null;
  269. this.m_BackUpwear.Clear();
  270. }
  271. private void CamRecet()
  272. {
  273. this.m_CamMoveSupport.ResetCamera();
  274. }
  275. private void ClickOKButton()
  276. {
  277. this.FadeOut();
  278. }
  279. protected override void FadeOutEnd()
  280. {
  281. if (this.m_TrywearItem != null)
  282. {
  283. this.RecetTrywear(new Action(base.FadeOutEnd));
  284. }
  285. else
  286. {
  287. base.FadeOutEnd();
  288. }
  289. }
  290. private void UpdateUIState()
  291. {
  292. ExChangeUI.Instance.SetButtonState(true);
  293. ExChangeUI.Instance.TextUIUpdate();
  294. ExChangeUI.Instance.UIStateUpdate();
  295. foreach (CasinoItemUI casinoItemUI in this.m_ItemUIList)
  296. {
  297. casinoItemUI.UIUpdate();
  298. }
  299. }
  300. public void ItemBuy(CasinoShopItem item_data)
  301. {
  302. Status status = GameMain.Instance.CharacterMgr.status;
  303. status.casinoCoin -= (long)item_data.Price;
  304. item_data.ItemBuy();
  305. this.UpdateUIState();
  306. string messageTerm = "SceneCasino/ダイアログ/{0}を購入しました";
  307. string[] array = new string[]
  308. {
  309. item_data.Name
  310. };
  311. if (Product.supportMultiLanguage)
  312. {
  313. array[0] = LocalizationManager.GetTranslation(item_data.NameTerm, true, 0, true, false, null, null);
  314. }
  315. GameMain.Instance.SysDlg.ShowFromLanguageTerm(messageTerm, array, SystemDialog.TYPE.OK, null, null);
  316. }
  317. public void SetTrywearItem(CasinoShopItem item_data)
  318. {
  319. this.m_SelectTrywear = item_data;
  320. this.m_TrywearButton.isEnabled = true;
  321. foreach (CasinoItemUI casinoItemUI in this.m_ItemUIList)
  322. {
  323. casinoItemUI.SwitchFrame();
  324. }
  325. }
  326. public void RecetTrywearItem()
  327. {
  328. this.m_SelectTrywear = null;
  329. this.m_TrywearButton.isEnabled = false;
  330. foreach (CasinoItemUI casinoItemUI in this.m_ItemUIList)
  331. {
  332. casinoItemUI.SwitchFrame();
  333. }
  334. }
  335. public void ShowItenInfo(CasinoShopItem item_data, Transform offset_base)
  336. {
  337. this.m_InfoData.UIobj.SetActive(true);
  338. this.m_InfoData.Icon.sprite2D = item_data.Icon;
  339. this.m_InfoData.InfoLabel.text = item_data.Document;
  340. Utility.SetLocalizeTerm(this.m_InfoData.InfoLabel, item_data.DocumentTerm, false);
  341. this.m_InfoData.Namelabel.text = item_data.Name;
  342. Utility.SetLocalizeTerm(this.m_InfoData.Namelabel, item_data.NameTerm, false);
  343. int num = Mathf.FloorToInt(this.m_ScrollPanel.height / this.m_ShopItemUI.Grid.cellHeight + 0.5f);
  344. int num2 = CasinoDataMgr.Instance.GetShopItem(item_data.MyCategory).Count - num;
  345. int num3 = num + Mathf.FloorToInt((float)num2 * this.m_ShopItemUI.ScrollView.verticalScrollBar.value) - 1;
  346. for (int i = 0; i < CasinoDataMgr.Instance.GetShopItem(item_data.MyCategory).Count; i++)
  347. {
  348. CasinoShopItem casinoShopItem = CasinoDataMgr.Instance.GetShopItem(item_data.MyCategory).ElementAt(i);
  349. if (casinoShopItem == item_data)
  350. {
  351. if (i >= num3 - 1)
  352. {
  353. this.m_InfoData.UIobj.transform.position = offset_base.TransformPoint(-this.m_OffsetInfo);
  354. }
  355. else
  356. {
  357. this.m_InfoData.UIobj.transform.position = offset_base.TransformPoint(this.m_OffsetInfo);
  358. }
  359. break;
  360. }
  361. }
  362. }
  363. public void HideItemInfo()
  364. {
  365. this.m_InfoData.UIobj.SetActive(false);
  366. }
  367. private WfCameraMoveSupport m_CamMoveSupport;
  368. [SerializeField]
  369. [Header("メイドの頭とのオフセット値")]
  370. private Vector3 m_HeadCamOffset = Vector3.zero;
  371. private Maid m_TrywearMaid;
  372. [SerializeField]
  373. [Header("各ボタン")]
  374. private UIButton m_TrywearButton;
  375. [SerializeField]
  376. private UIButton m_TrycancelButton;
  377. [SerializeField]
  378. private UIButton m_CamRecetButton;
  379. [SerializeField]
  380. private UIButton m_OkButton;
  381. [SerializeField]
  382. [Header("カテゴリー列挙用UI")]
  383. private SceneCasinoShop.ScrollUIData m_CategoryUI;
  384. [SerializeField]
  385. private GameObject m_CategoryAllow;
  386. [SerializeField]
  387. private float m_AllowMove = 0.5f;
  388. private Vector3 m_AllowposStart = Vector3.zero;
  389. private Vector3 m_AllowposEnd = Vector3.zero;
  390. [SerializeField]
  391. [Header("アイテム列挙用UI")]
  392. private SceneCasinoShop.ScrollUIData m_ShopItemUI;
  393. [SerializeField]
  394. private UIScrollBar m_ItemSrollBar;
  395. [SerializeField]
  396. [Header("アイテム説明用UI")]
  397. private GameObject m_ItemInfoUI;
  398. [SerializeField]
  399. private Vector3 m_OffsetInfo = Vector3.zero;
  400. [SerializeField]
  401. private UICamera m_NguiCam;
  402. private SceneCasinoShop.InfoUIData m_InfoData = new SceneCasinoShop.InfoUIData();
  403. private CasinoShopItem m_TrywearItem;
  404. private CasinoShopItem m_SelectTrywear;
  405. private Dictionary<MPN, MaidProp> m_BackUpwear = new Dictionary<MPN, MaidProp>();
  406. private Dictionary<UIWFTabButton, CasinoShopItem.Category> m_ButtonCategoryPair = new Dictionary<UIWFTabButton, CasinoShopItem.Category>();
  407. private List<CasinoItemUI> m_ItemUIList = new List<CasinoItemUI>();
  408. private UIPanel m_ScrollPanel;
  409. private bool m_NguiEnable = true;
  410. [Serializable]
  411. private class ScrollUIData
  412. {
  413. public UIGrid Grid;
  414. public UIScrollView ScrollView;
  415. public UIWFTabPanel TabPanel;
  416. }
  417. private class InfoUIData
  418. {
  419. public GameObject UIobj;
  420. public UI2DSprite Icon;
  421. public UILabel Namelabel;
  422. public UILabel InfoLabel;
  423. }
  424. private class BoughtData
  425. {
  426. public CasinoShopItem ItemData;
  427. public UIButton Button;
  428. public UISprite ButtonIcon;
  429. }
  430. }