SceneCasinoShop.cs 13 KB

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