GMPanelView.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. using FairyGUI;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using cfg.GfgCfg;
  6. using UI.RoleInfo;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class GMPanelView : BaseWindow
  11. {
  12. private UI_GMPanelUI _ui;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. }
  19. _ui = null;
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_GMPanelUI.PACKAGE_NAME;
  26. _ui = UI_GMPanelUI.Create();
  27. this.viewCom = _ui.target;
  28. this.viewCom.Center();
  29. this.modal = true;
  30. _ui.m_ComBtn.m_btnGetAllDressUpItem.onClick.Add(OnClickBtnGetAllDressUpItem);
  31. _ui.m_ComBtn.m_btnGetAllCardItem.onClick.Add(OnClickBtnGetAllCardItem);
  32. _ui.m_ComBtn.m_btnSetLv.onClick.Add(OnClickBtnSetLv);
  33. _ui.m_ComBtn.m_btnSetChapter.onClick.Add(OnClickBtnSetChapter);
  34. _ui.m_ComBtn.m_btnAll.onClick.Add(OnClickBtnAll);
  35. _ui.m_ComBtn.m_btnArenaGrade.onClick.Add(OnClickBtnArenaGrade);
  36. _ui.m_ComBtn.m_btnLeagueSkill.onClick.Add(OnClickBtnLeagueSkill);
  37. _ui.m_ComBtn.m_btnAnswerStart.onClick.Add(OnClickBtnStart);
  38. _ui.m_ComBtn.m_btnAnswerEnd.onClick.Add(OnClickBtnEnd);
  39. _ui.m_ComBtn.m_btnAnswerActiveEnd.onClick.Add(OnClickBtnActiveEnd);
  40. _ui.m_ComBtn.m_btnAddLeagueNum.onClick.Add(OnClickBtnLeagueAddNum);
  41. _ui.m_ComBtn.m_btnSetLeaguNum.onClick.Add(OnClickBtnLeagueSetNum);
  42. _ui.m_ComBtn.m_btnMaxFightSpeed.onClick.Add(OnClickBtnMaxFightSpeed);
  43. _ui.m_ComBtn.m_btnCardMaterials.onClick.Add(OnClickBtnMaterials);
  44. _ui.m_ComBtn.m_btnGetSuit.onClick.Add(OnClickBtnGetSuit);
  45. _ui.m_ComBtn.m_btnWealth.onClick.Add(OnClickBtnWealth);
  46. _ui.m_btnAddItem.onClick.Add(OnClickBtnAddItem);
  47. _ui.m_btnGM.onClick.Add(OnClickBtnGM);
  48. _ui.m_btnAddNum.onClick.Add(OnClickBtnAddCount);
  49. _ui.m_btnSetNum.onClick.Add(OnClickBtnSetCount);
  50. _ui.m_ComBtn.m_btnTeaPartyStart.onClick.Add(OnClickBtnTeaPartyStart);
  51. _ui.m_ComBtn.m_btnShareTest1.onClick.Add(OnClickShareTest1);
  52. _ui.m_ComBtn.m_btnShareTest2.onClick.Add(OnClickShareTest2);
  53. _ui.m_ComBtn.m_btnShareTest3.onClick.Add(OnClickShareTest3);
  54. var dataArray = CommonDataManager.Tables.TblRoleLevelCfg.DataList;
  55. RoleLevelCfg maxLvlCfg = dataArray[dataArray.Count - 1];
  56. _ui.m_ComBtn.m_txtRoleLv.text = maxLvlCfg.Id + "";
  57. }
  58. protected override void OnShown()
  59. {
  60. base.OnShown();
  61. _ui.m_ComBtn.m_c1.selectedIndex = 0;
  62. _ui.m_ComBtn.m_txtArenaGrade.text = "";
  63. _ui.m_ComBtn.m_txtArenaRank.text = "";
  64. InitChapterText();
  65. }
  66. protected override void OnHide()
  67. {
  68. base.OnHide();
  69. }
  70. private void OnClickBtnGetAllDressUpItem()
  71. {
  72. GMController.GetAllDressUpItem().Coroutine();
  73. }
  74. private void OnClickBtnWealth(EventContext context = null)
  75. {
  76. AddItemByGM(ConstItemID.POWER, 10000);
  77. AddItemByGM(ConstItemID.GOLD, 10000);
  78. AddItemByGM(ConstItemID.DIAMOND_RED, 10000);
  79. }
  80. private void OnClickBtnLeagueSetNum(EventContext context)
  81. {
  82. var setType = _ui.m_ComBtn.m_SetLeagueNumType.text;
  83. var setNum = _ui.m_ComBtn.m_SetNum.text;
  84. GMController.SendGMCommand($"setLeagueValue 0 {setType} {setNum}", "").Coroutine();
  85. }
  86. private void OnClickBtnLeagueAddNum(EventContext context)
  87. {
  88. var addType = _ui.m_ComBtn.m_AddLeagueNumType.text;
  89. var addNum = _ui.m_ComBtn.m_AddNum.text;
  90. GMController.SendGMCommand($"setLeagueValue 1 {addType} {addNum}", "").Coroutine();
  91. }
  92. private void OnClickBtnGetAllCardItem()
  93. {
  94. GMController.GetAllCardItem().Coroutine();
  95. }
  96. private void OnClickBtnAddItem(EventContext context)
  97. {
  98. string content = _ui.m_inputItem.text;
  99. string[] infos = Regex.Split(content, " ");
  100. if (infos.Length < 2)
  101. {
  102. PromptController.Instance.ShowFloatTextPrompt("请按照指定格式输入物品信息", MessageType.ERR);
  103. return;
  104. }
  105. int itemId = int.Parse(infos[0]);
  106. int itemNum = int.Parse(infos[1]);
  107. AddItemByGM(itemId, itemNum);
  108. }
  109. private void AddItemByGM(int itemId, int itemNum)
  110. {
  111. if (itemId > 0 && itemNum != 0)
  112. {
  113. string messageSuc;
  114. if (itemNum > 0)
  115. {
  116. messageSuc = "已获得物品" + itemId + "*" + itemNum;
  117. }
  118. else
  119. {
  120. messageSuc = "已扣除物品" + itemId + "*" + itemNum;
  121. }
  122. GMController.SendGMCommand($"getItem {itemId} {itemNum}", messageSuc).Coroutine();
  123. }
  124. else
  125. {
  126. PromptController.Instance.ShowFloatTextPrompt("请按照指定格式输入物品信息", MessageType.ERR);
  127. }
  128. }
  129. private void OnClickBtnSetLv()
  130. {
  131. int tmp;
  132. if (!int.TryParse(_ui.m_ComBtn.m_txtRoleLv.text, out tmp))
  133. {
  134. PromptController.Instance.ShowFloatTextPrompt("请输入数字");
  135. return;
  136. }
  137. string lv = _ui.m_ComBtn.m_txtRoleLv.text;
  138. string messageSuc = "等级提升至" + lv;
  139. GMController.SendGMCommand("lv " + lv, messageSuc).Coroutine();
  140. }
  141. private void OnClickBtnSetChapter()
  142. {
  143. int tmp;
  144. int tmp1;
  145. if (!int.TryParse(_ui.m_ComBtn.m_txtChapter.text, out tmp) ||
  146. !int.TryParse(_ui.m_ComBtn.m_txtChapterLv.text, out tmp1))
  147. {
  148. PromptController.Instance.ShowFloatTextPrompt("请输入数字");
  149. return;
  150. }
  151. string content = _ui.m_ComBtn.m_txtChapter.text + " " + _ui.m_ComBtn.m_txtChapterLv.text;
  152. string messageSuc = string.Format("当前关卡第{0}章第{1}关", _ui.m_ComBtn.m_txtChapter.text,
  153. _ui.m_ComBtn.m_txtChapterLv.text);
  154. if (_ui.m_ComBtn.m_txtChapter.text == "99" || _ui.m_ComBtn.m_txtChapterLv.text == "99")
  155. {
  156. SkipAllChapter();
  157. }
  158. else
  159. {
  160. GMController.SendGMCommand("chapter " + content, messageSuc).Coroutine();
  161. }
  162. ActivitySProxy.ReqGetNewPlayerBonusStatus().Coroutine();
  163. MainStorySProxy.GetStoryBonusDate().Coroutine();
  164. }
  165. private async void SkipAllChapter()
  166. {
  167. List<StoryChapterCfg> chapterList = CommonDataManager.Tables.TblStoryChapterCfg.DataList
  168. .Where(a => a.SubType == 1).ToList();
  169. foreach (var item in chapterList)
  170. {
  171. List<StoryLevelCfg> levelList = CommonDataManager.Tables.TblStoryLevelCfg.DataList
  172. .Where(a => a.Type == 1 &&
  173. a.SubType == 1 &&
  174. a.ChapterId == item.Id).ToList();
  175. foreach (var level in levelList)
  176. {
  177. M2C_FinishInstanceZonesFightLevel response = null;
  178. response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(
  179. new C2M_FinishInstanceZonesFightLevel()
  180. {
  181. LevelCfgId = level.Id,
  182. Score = 99999,
  183. NpcScore = 0,
  184. UseRecommend = false
  185. });
  186. }
  187. }
  188. }
  189. private async void OnClickBtnSkipCheckOpen()
  190. {
  191. int isSkip = GameGlobal.skipCheckOpen == false ? 1 : 0;
  192. bool result = await StorageSProxy.ReqSetClientValue(ConstStorageId.SKIP_CHECK_OPEN, isSkip);
  193. if (result)
  194. {
  195. GameGlobal.skipCheckOpen = !GameGlobal.skipCheckOpen;
  196. PromptController.Instance.ShowFloatTextPrompt("已开启跳过功能开启检测");
  197. }
  198. }
  199. private async void OnClickBtnArenaGrade()
  200. {
  201. string gm = string.Format("SetArenaRank|{0}|{1}", _ui.m_ComBtn.m_txtArenaGrade.text,
  202. _ui.m_ComBtn.m_txtArenaRank.text);
  203. bool result = await GMController.SendGMCommand(gm, "修改成功");
  204. if (result)
  205. {
  206. ArenaDataManager.Instance.Grade = int.Parse(_ui.m_ComBtn.m_txtArenaGrade.text);
  207. ArenaDataManager.Instance.Rank = int.Parse(_ui.m_ComBtn.m_txtArenaRank.text);
  208. ArenaDataManager.Instance.TryUpdateHighest();
  209. }
  210. }
  211. private void OnClickBtnStart()
  212. {
  213. GMController.SendGMCommand("League|StartQuestion", "开始答题").Coroutine();
  214. }
  215. private void OnClickBtnEnd()
  216. {
  217. GMController.SendGMCommand("League|EndQuestion", "结束答题").Coroutine();
  218. }
  219. private void OnClickBtnActiveEnd()
  220. {
  221. GMController.SendGMCommand("League|CloseQuestion", "活动结束").Coroutine();
  222. }
  223. private void OnClickBtnTeaPartyStart()
  224. {
  225. GMController.SendGMCommand("League|TeaPartyStart", "茶话会开始").Coroutine();
  226. }
  227. private async void OnClickBtnLeagueSkill()
  228. {
  229. int _type = int.Parse(_ui.m_ComBtn.m_txtskillType.text);
  230. List<LeagueSkillCfg> skillCfgs = CommonDataManager.Tables.TblLeagueSkillCfg.DataList
  231. .Where(a => a.Type == _type).ToList();
  232. for (int i = 0; i < skillCfgs.Count; i++)
  233. {
  234. int skillId = skillCfgs[i].Id;
  235. if (SkillDataManager.Instance.LeagueSkillDatas.ContainsKey(_type) &&
  236. SkillDataManager.Instance.LeagueSkillDatas[_type].IndexOf(skillId) >= 0)
  237. {
  238. continue;
  239. }
  240. LeagueSkillCfg skillCfg = CommonDataManager.Tables.TblLeagueSkillCfg.GetOrDefault(skillId);
  241. // List<LeagueSkillCfg> lastSkillCfgs = LeagueSkillCfgArray.Instance.GetCfgsBytypeAndlayer(_type, skillCfg.layer - 1);
  242. // for (int j = 0; j < lastSkillCfgs.Count; j++)
  243. // {
  244. // if (!SkillDataManager.Instance.LeagueSkillDatas.ContainsKey(_type) || SkillDataManager.Instance.LeagueSkillDatas[_type].IndexOf(lastSkillCfgs[j].id) < 0)
  245. // {
  246. // return;
  247. // }
  248. // }
  249. long needCount = skillCfg.Consume[0].Count;
  250. long hasCount = ItemDataManager.GetItemNum(skillCfg.Consume[0].ItemId);
  251. if (hasCount < needCount)
  252. {
  253. PromptController.Instance.ShowFloatTextPrompt("消耗不足");
  254. break;
  255. }
  256. await SkillSProxy.ReqActiveSkill(SkillType.LeagueSkill, skillId);
  257. }
  258. PromptController.Instance.ShowFloatTextPrompt("学习结束");
  259. }
  260. private async void OnClickBtnAll()
  261. {
  262. bool result = await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_SKIP_GUIDE, 2);
  263. if (result)
  264. {
  265. GameGlobal.skipGuide = true;
  266. }
  267. OnClickBtnGetAllDressUpItem();
  268. OnClickBtnGetAllCardItem();
  269. OnClickBtnSetLv();
  270. InitChapterText();
  271. OnClickBtnSetChapter();
  272. OnClickBtnSkipCheckOpen();
  273. OnClickBtnMaterials();
  274. OnClickBtnWealth();
  275. }
  276. private void InitChapterText()
  277. {
  278. var chapterCount =
  279. CommonDataManager.Tables.TblStoryChapterCfg.DataList.Count(a =>
  280. a.SubType == ConstInstanceZonesSubType.Normal);
  281. _ui.m_ComBtn.m_txtChapter.text = "" + chapterCount;
  282. StoryChapterCfg storyChapterCfg =
  283. CommonDataManager.Tables.TblStoryChapterCfg.DataList.Where(a =>
  284. a.SubType == ConstInstanceZonesSubType.Normal && a.Order == chapterCount).ToList()[0];
  285. _ui.m_ComBtn.m_txtChapterLv.text = "" + storyChapterCfg.LevelCount;
  286. }
  287. private void OnClickBtnMaxFightSpeed()
  288. {
  289. FightDataManager.Instance.maxFightSpeed = 8;
  290. }
  291. private void OnClickBtnMaterials()
  292. {
  293. List<ItemCfg> itemCfgs = CommonDataManager.Tables.TblItemCfg.DataList
  294. .Where(a => a.ItemType == ConstItemType.ITEM).ToList();
  295. for (int i = 0; i < itemCfgs.Count; i++)
  296. {
  297. string content = string.Format("{0} {1}", itemCfgs[i].Id, 1000);
  298. string successMessage = string.Format("已获取 【{0} * {1}】", itemCfgs[i].Name, 1000);
  299. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  300. }
  301. }
  302. private void OnClickBtnGetSuit()
  303. {
  304. int suitId = int.Parse(_ui.m_ComBtn.m_txtSuitId.text);
  305. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId);
  306. if (suitCfg == null)
  307. {
  308. PromptController.Instance.ShowFloatTextPrompt("套装配置不存在");
  309. }
  310. for (int i = 0; i < suitCfg.Parts.Count; i++)
  311. {
  312. string content = string.Format("{0} {1}", suitCfg.Parts[i], 1);
  313. string name = CommonDataManager.Tables.TblItemCfg.GetOrDefault(suitCfg.Parts[i]).Name;
  314. string successMessage = string.Format("已获取 【{0} * {1}】", name, 1000);
  315. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  316. }
  317. for (int i = 0; i < suitCfg.PartsOptional.Count; i++)
  318. {
  319. string content = string.Format("{0} {1}", suitCfg.PartsOptional[i], 1);
  320. string name = CommonDataManager.Tables.TblItemCfg.GetOrDefault(suitCfg.PartsOptional[i]).Name;
  321. string successMessage = string.Format("已获取 【{0} * {1}】", name, 1000);
  322. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  323. }
  324. }
  325. private void OnClickBtnGM(EventContext context)
  326. {
  327. string content = _ui.m_inputGM.text;
  328. string[] infos = Regex.Split(content, " ");
  329. if (infos.Length < 2)
  330. {
  331. PromptController.Instance.ShowFloatTextPrompt("请按照指定格式输入物品信息", MessageType.ERR);
  332. return;
  333. }
  334. switch (infos[0])
  335. {
  336. case "cjstime":
  337. if (infos[1].Length != 10)
  338. {
  339. PromptController.Instance.ShowFloatTextPrompt("请输入以秒为单位的正确的时间戳");
  340. return;
  341. }
  342. LuckyBoxDataManager.Instance.startTime = int.Parse(infos[1]);
  343. PromptController.Instance.ShowFloatTextPrompt("设置成功");
  344. break;
  345. case "cjetime":
  346. if (infos[1].Length != 10)
  347. {
  348. PromptController.Instance.ShowFloatTextPrompt("请输入以秒为单位的正确的时间戳");
  349. return;
  350. }
  351. LuckyBoxDataManager.Instance.endTime = int.Parse(infos[1]);
  352. PromptController.Instance.ShowFloatTextPrompt("设置成功");
  353. break;
  354. default:
  355. GMController.SendGMCommand(content, "设置成功").Coroutine();
  356. break;
  357. }
  358. }
  359. //设置计数值
  360. private void OnClickBtnSetCount(EventContext context)
  361. {
  362. var roleNumType = _ui.m_RoleNumType.text;
  363. if (string.IsNullOrEmpty(roleNumType)) return;
  364. var num = _ui.m_Num.text;
  365. if (string.IsNullOrEmpty(num)) return;
  366. GMController.SendGMCommand($"setNum {roleNumType} {num}", "").Coroutine();
  367. }
  368. //添加计数值
  369. private void OnClickBtnAddCount(EventContext context)
  370. {
  371. var roleNumType = _ui.m_AddRoleNumType.text;
  372. if (string.IsNullOrEmpty(roleNumType)) return;
  373. var num = _ui.m_AddNum.text;
  374. if (string.IsNullOrEmpty(num)) return;
  375. GMController.SendGMCommand($"addNum {roleNumType} {num}", "").Coroutine();
  376. }
  377. private void OnClickShareTest1(EventContext context = null)
  378. {
  379. }
  380. private void OnClickShareTest2(EventContext context = null)
  381. {
  382. }
  383. private void OnClickShareTest3(EventContext context = null)
  384. {
  385. ShareDataManager.Instance.CaptureCameraToImage();
  386. }
  387. }
  388. }