SceneCasinoShop.cs 13 KB

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