GMPanelView.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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.GetGroup1BySubType(1);
  168. foreach (var item in chapterList)
  169. {
  170. List<StoryLevelCfg> levelList = CommonDataManager.Tables.TblStoryLevelCfg.DataList
  171. .Where(a => a.Type == 1 &&
  172. a.SubType == 1 &&
  173. a.ChapterId == item.Id).ToList();
  174. foreach (var level in levelList)
  175. {
  176. M2C_FinishInstanceZonesFightLevel response = null;
  177. response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(
  178. new C2M_FinishInstanceZonesFightLevel()
  179. {
  180. LevelCfgId = level.Id,
  181. Score = 99999,
  182. NpcScore = 0,
  183. UseRecommend = false
  184. });
  185. }
  186. }
  187. }
  188. private async void OnClickBtnSkipCheckOpen()
  189. {
  190. int isSkip = GameGlobal.skipCheckOpen == false ? 1 : 0;
  191. bool result = await StorageSProxy.ReqSetClientValue(ConstStorageId.SKIP_CHECK_OPEN, isSkip);
  192. if (result)
  193. {
  194. GameGlobal.skipCheckOpen = !GameGlobal.skipCheckOpen;
  195. PromptController.Instance.ShowFloatTextPrompt("已开启跳过功能开启检测");
  196. }
  197. }
  198. private async void OnClickBtnArenaGrade()
  199. {
  200. string gm = string.Format("SetArenaRank|{0}|{1}", _ui.m_ComBtn.m_txtArenaGrade.text,
  201. _ui.m_ComBtn.m_txtArenaRank.text);
  202. bool result = await GMController.SendGMCommand(gm, "修改成功");
  203. if (result)
  204. {
  205. ArenaDataManager.Instance.Grade = int.Parse(_ui.m_ComBtn.m_txtArenaGrade.text);
  206. ArenaDataManager.Instance.Rank = int.Parse(_ui.m_ComBtn.m_txtArenaRank.text);
  207. ArenaDataManager.Instance.TryUpdateHighest();
  208. }
  209. }
  210. private void OnClickBtnStart()
  211. {
  212. GMController.SendGMCommand("League|StartQuestion", "开始答题").Coroutine();
  213. }
  214. private void OnClickBtnEnd()
  215. {
  216. GMController.SendGMCommand("League|EndQuestion", "结束答题").Coroutine();
  217. }
  218. private void OnClickBtnActiveEnd()
  219. {
  220. GMController.SendGMCommand("League|CloseQuestion", "活动结束").Coroutine();
  221. }
  222. private void OnClickBtnTeaPartyStart()
  223. {
  224. GMController.SendGMCommand("League|TeaPartyStart", "茶话会开始").Coroutine();
  225. }
  226. private async void OnClickBtnLeagueSkill()
  227. {
  228. int _type = int.Parse(_ui.m_ComBtn.m_txtskillType.text);
  229. List<LeagueSkillCfg> skillCfgs = CommonDataManager.Tables.TblLeagueSkillCfg.GetGroup1ByType(_type);
  230. for (int i = 0; i < skillCfgs.Count; i++)
  231. {
  232. int skillId = skillCfgs[i].Id;
  233. if (SkillDataManager.Instance.LeagueSkillDatas.ContainsKey(_type) &&
  234. SkillDataManager.Instance.LeagueSkillDatas[_type].IndexOf(skillId) >= 0)
  235. {
  236. continue;
  237. }
  238. LeagueSkillCfg skillCfg = CommonDataManager.Tables.TblLeagueSkillCfg.GetOrDefault(skillId);
  239. // List<LeagueSkillCfg> lastSkillCfgs = LeagueSkillCfgArray.Instance.GetCfgsBytypeAndlayer(_type, skillCfg.layer - 1);
  240. // for (int j = 0; j < lastSkillCfgs.Count; j++)
  241. // {
  242. // if (!SkillDataManager.Instance.LeagueSkillDatas.ContainsKey(_type) || SkillDataManager.Instance.LeagueSkillDatas[_type].IndexOf(lastSkillCfgs[j].id) < 0)
  243. // {
  244. // return;
  245. // }
  246. // }
  247. long needCount = skillCfg.Consume[0].Count;
  248. long hasCount = ItemDataManager.GetItemNum(skillCfg.Consume[0].ItemId);
  249. if (hasCount < needCount)
  250. {
  251. PromptController.Instance.ShowFloatTextPrompt("消耗不足");
  252. break;
  253. }
  254. await SkillSProxy.ReqActiveSkill(SkillType.LeagueSkill, skillId);
  255. }
  256. PromptController.Instance.ShowFloatTextPrompt("学习结束");
  257. }
  258. private async void OnClickBtnAll()
  259. {
  260. bool result = await StorageSProxy.ReqSetClientValue(ConstStorageId.STORAGE_SKIP_GUIDE, 2);
  261. if (result)
  262. {
  263. GameGlobal.skipGuide = true;
  264. }
  265. OnClickBtnGetAllDressUpItem();
  266. OnClickBtnGetAllCardItem();
  267. OnClickBtnSetLv();
  268. InitChapterText();
  269. OnClickBtnSetChapter();
  270. OnClickBtnSkipCheckOpen();
  271. OnClickBtnMaterials();
  272. OnClickBtnWealth();
  273. }
  274. private void InitChapterText()
  275. {
  276. var chapterCount = CommonDataManager.Tables.TblStoryChapterCfg
  277. .GetGroup1BySubType(ConstInstanceZonesSubType.Normal).Count;
  278. _ui.m_ComBtn.m_txtChapter.text = "" + chapterCount;
  279. StoryChapterCfg storyChapterCfg =
  280. CommonDataManager.Tables.TblStoryChapterCfg.GetGroup1BySubTypeAndOrder(ConstInstanceZonesSubType.Normal,
  281. chapterCount)[0];
  282. _ui.m_ComBtn.m_txtChapterLv.text = "" + storyChapterCfg.LevelCount;
  283. }
  284. private void OnClickBtnMaxFightSpeed()
  285. {
  286. FightDataManager.Instance.maxFightSpeed = 8;
  287. }
  288. private void OnClickBtnMaterials()
  289. {
  290. List<ItemCfg> itemCfgs = CommonDataManager.Tables.TblItemCfg.GetGroup1ByItemType(ConstItemType.ITEM);
  291. for (int i = 0; i < itemCfgs.Count; i++)
  292. {
  293. string content = string.Format("{0} {1}", itemCfgs[i].Id, 1000);
  294. string successMessage = string.Format("已获取 【{0} * {1}】", itemCfgs[i].Name, 1000);
  295. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  296. }
  297. }
  298. private void OnClickBtnGetSuit()
  299. {
  300. int suitId = int.Parse(_ui.m_ComBtn.m_txtSuitId.text);
  301. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitId);
  302. if (suitCfg == null)
  303. {
  304. PromptController.Instance.ShowFloatTextPrompt("套装配置不存在");
  305. }
  306. for (int i = 0; i < suitCfg.Parts.Count; i++)
  307. {
  308. string content = string.Format("{0} {1}", suitCfg.Parts[i], 1);
  309. string name = CommonDataManager.Tables.TblItemCfg.GetOrDefault(suitCfg.Parts[i]).Name;
  310. string successMessage = string.Format("已获取 【{0} * {1}】", name, 1000);
  311. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  312. }
  313. for (int i = 0; i < suitCfg.PartsOptional.Count; i++)
  314. {
  315. string content = string.Format("{0} {1}", suitCfg.PartsOptional[i], 1);
  316. string name = CommonDataManager.Tables.TblItemCfg.GetOrDefault(suitCfg.PartsOptional[i]).Name;
  317. string successMessage = string.Format("已获取 【{0} * {1}】", name, 1000);
  318. GMController.SendGMCommand("getItem " + content, successMessage).Coroutine();
  319. }
  320. }
  321. private void OnClickBtnGM(EventContext context)
  322. {
  323. string content = _ui.m_inputGM.text;
  324. string[] infos = Regex.Split(content, " ");
  325. if (infos.Length < 2)
  326. {
  327. PromptController.Instance.ShowFloatTextPrompt("请按照指定格式输入物品信息", MessageType.ERR);
  328. return;
  329. }
  330. switch (infos[0])
  331. {
  332. case "cjstime":
  333. if (infos[1].Length != 10)
  334. {
  335. PromptController.Instance.ShowFloatTextPrompt("请输入以秒为单位的正确的时间戳");
  336. return;
  337. }
  338. LuckyBoxDataManager.Instance.startTime = int.Parse(infos[1]);
  339. PromptController.Instance.ShowFloatTextPrompt("设置成功");
  340. break;
  341. case "cjetime":
  342. if (infos[1].Length != 10)
  343. {
  344. PromptController.Instance.ShowFloatTextPrompt("请输入以秒为单位的正确的时间戳");
  345. return;
  346. }
  347. LuckyBoxDataManager.Instance.endTime = int.Parse(infos[1]);
  348. PromptController.Instance.ShowFloatTextPrompt("设置成功");
  349. break;
  350. default:
  351. GMController.SendGMCommand(content, "设置成功").Coroutine();
  352. break;
  353. }
  354. }
  355. //设置计数值
  356. private void OnClickBtnSetCount(EventContext context)
  357. {
  358. var roleNumType = _ui.m_RoleNumType.text;
  359. if (string.IsNullOrEmpty(roleNumType)) return;
  360. var num = _ui.m_Num.text;
  361. if (string.IsNullOrEmpty(num)) return;
  362. GMController.SendGMCommand($"setNum {roleNumType} {num}", "").Coroutine();
  363. }
  364. //添加计数值
  365. private void OnClickBtnAddCount(EventContext context)
  366. {
  367. var roleNumType = _ui.m_AddRoleNumType.text;
  368. if (string.IsNullOrEmpty(roleNumType)) return;
  369. var num = _ui.m_AddNum.text;
  370. if (string.IsNullOrEmpty(num)) return;
  371. GMController.SendGMCommand($"addNum {roleNumType} {num}", "").Coroutine();
  372. }
  373. private void OnClickShareTest1(EventContext context = null)
  374. {
  375. }
  376. private void OnClickShareTest2(EventContext context = null)
  377. {
  378. }
  379. private void OnClickShareTest3(EventContext context = null)
  380. {
  381. ShareDataManager.Instance.CaptureCameraToImage();
  382. }
  383. }
  384. }