/* Creat By LuoJiasi; Plz Put in DIY File; */ using System.Collections.Generic; using System.Text; using UnityEditor; using UnityEngine; using System.Collections; using System.IO; using System; using NUnit.Framework; using Thousandto.Core.Base; using Thousandto.Code.Center; using Thousandto.Code.Logic; using Thousandto.Core.Asset; using CoroutinePool = UnityEngine.Gonbest.MagicCube.CoroutinePool; namespace Assets.Editor.QATools { public class AutoTaskTest : EditorWindow { [MenuItem("Ares/测试工具/自动做任务")] static void Init() { var win = (AutoTaskTest)EditorWindow.GetWindow(typeof(AutoTaskTest)); win.Show(); win.titleContent = new GUIContent("自动做任务"); } #region 配置文件 protected string _now = DateTime.Now.ToString ("yyyy-MM-dd/") + DateTime.Now.ToString ("HH:mm:ss"); protected string _logplace = "D:/TestCase/AutoTaskResult.txt" ; //Log存储位置 protected int flag = 0;//测试标记:0初始,1开始,2结束 //测试结果记录到txt文件中,文件地址为_logplace protected void LogTest(string resultfile) { if (!File.Exists(_logplace)) { File.WriteAllText(_logplace, "[Test Start]\r\n"); } File.AppendAllText(_logplace, DateTime.Now.ToString ("yyyy-MM-dd/") + DateTime.Now.ToString ("HH:mm:ss") + "," + resultfile + "\r\n"); Debug.LogWarning(resultfile); } #endregion private void OnGUI() { if(GUILayout.Button("自动做任务")) { flag = 1; CoroutinePool.AddTask(AutoTask()); CoroutinePool.AddTask(RecordTask()); } if(GUILayout.Button("停止做任务")) { flag = 2; StopAction(); } } private IEnumerator RecordTask() { string nowTaskName = "初始化任务名称"; string nowLevel = "初始化当前等级"; yield return new WaitForSeconds(0.1f); while (flag == 1) { //持续记录当前任务名称 if (ActiveGO("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll")) { GameObject TaskGo = GameObject.Find("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll").transform.GetChild(0).GetChild(1).gameObject; if (TaskGo && (nowTaskName != TaskGo.GetComponent().text)) { nowTaskName = TaskGo.GetComponent().text; LogTest("当前任务," + nowTaskName); } } if (ActiveGO("UIMainForm/LeftTop/PlayerHead/Level/Level")) { if (nowLevel != GameObject.Find("UIMainForm/LeftTop/PlayerHead/Level/Level").GetComponent().text) { nowLevel = GameObject.Find("UIMainForm/LeftTop/PlayerHead/Level/Level").GetComponent().text; LogTest("当前等级," + nowLevel); } } yield return new WaitForSeconds(0.1f); } } private IEnumerator AutoTask() { LogTest("开始自动做任务"); yield return new WaitForSeconds(0.1f); int timenum = 0; //这里写登录部分,直到进入游戏。 //开始循环。 //根据目前界面上GameObject的情况,做某些操作。 //ClickBtn("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll/TaskItem"); ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); while (flag == 1) { //欢迎页 if (CheckGO("UIWeleComePanel/BackTex/Start")) { ClickBtn("UIWeleComePanel/BackTex/Start"); yield return new WaitForSeconds(1.0f); } //NPC对话 if (CheckGO("UINpcTalkForm/StoryLayer/Top/Continue")) { ClickBtn("UINpcTalkForm/StoryLayer/Top/Continue"); yield return new WaitForSeconds(1.0f); } //获得法宝 if (CheckGO("UIFabaoAnmiForm/Content/Btn")) { ClickBtn("UIFabaoAnmiForm/Content/Btn"); yield return new WaitForSeconds(1.0f); } //获得新模型 if (ActiveGO("UIModelViewForm/Center/Close")) { ClickBtn("UIModelViewForm/Center/Close"); yield return new WaitForSeconds(1.0f); } //引导点击任务 if (ActiveGO("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll")) { if (GameObject.Find("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll").transform.GetChild(0).GetChild(8).gameObject.activeSelf) { ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); yield return new WaitForSeconds(1.0f); } } //不跳过引导 /* //引导跳过 if (ActiveGO("UIGuildForm/Back/Jump")) { ClickBtn("UIGuildForm/Back/Jump"); yield return new WaitForSeconds(1.0f); ClickBtn("UIGuildForm/MsgBox/Back/OK"); } if (ActiveGO("UIGuideForm/Back/Jump")) { ClickBtn("UIGuideForm/Back/Jump"); yield return new WaitForSeconds(1.0f); ClickBtn("UIGuideForm/MsgBox/Back/OK"); } */ //一键熔炼 if (CheckGO("UIEquipSmeltForm")) { ClickBtn("UIEquipSmeltForm/Bottom/QuickButton"); yield return new WaitForSeconds(1.0f); ClickBtn("UIEquipSmeltForm/Close"); yield return new WaitForSeconds(1.0f); } //日常任务 if (CheckGO("UIDailyTaskForm/Bottom/GoTo")) { ClickBtn("UIDailyTaskForm/Bottom/GoTo"); yield return new WaitForSeconds(1.0f); } //假无限层 if (CheckGO("UIUnlimitBossForm/Center/CopyBtn")) { ClickBtn("UIUnlimitBossForm/Center/CopyBtn"); ClickBtn("UIUnlimitBossForm/Center/CloseBtn"); yield return new WaitForSeconds(1.0f); } //新道具获得Tips if (CheckGO("UIGetItemTIps/Container/Back/CloseBtn")) { ClickBtn("UIGetItemTIps/Container/Back/BtnUse"); yield return new WaitForSeconds(1.0f); ClickBtn("UIItemBatchForm/Container/Back/SureBtn"); ClickBtn("UITreasureChestsForm/Center/SureBtn"); yield return new WaitForSeconds(1.0f); } //新装备获取Tips if (ActiveGO("UIGetEquipTIps")) { ClickBtn("UIGetEquipTIps/Container/Back/BtnEquip"); yield return new WaitForSeconds(1.0f); } //可拍卖道具获取Tips if (ActiveGO("UIGetAuctionItemTIps")) { ClickBtn("UIGetAuctionItemTIps/Table/BtnUse"); ClickBtn("UIGetAuctionItemTIps/Table/CloseBtn"); yield return new WaitForSeconds(1.0f); } //首领宝箱Tips if (ActiveGO("UIBossBoxResultForm/OpenNextBtn")) { ClickBtn("UIBossBoxResultForm/OpenNextBtn"); ClickBtn("UIBossBoxResultForm/CloseBtn"); yield return new WaitForSeconds(1.0f); } //获取途径弹窗 if (ActiveGO("UIItemQuickGetForm/ClsoeBtn")) { ClickBtn("UIItemQuickGetForm/ClsoeBtn"); yield return new WaitForSeconds(1.0f); } //渡劫 if (ActiveGO("UIDuJieCopyMainForm/RightButtom/DuJieBtn")) { ClickBtn("UIDuJieCopyMainForm/RightButtom/DuJieBtn"); yield return new WaitForSeconds(25.0f); ClickBtn("UIDuJieCopyMainForm/RightTop/Leave"); } //境界提升提醒 if (CheckGO("UIRealmLevelUpForm/Center/SureBtn")) { ClickBtn("UIRealmLevelUpForm/Center/SureBtn"); yield return new WaitForSeconds(1.0f); } //境界 if (CheckGO("UIRealmForm")) { if (ActiveGO("UIRealmForm/Right/Offset/TaskRoot")) { if (ActiveGO("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/GetBtn")) { ClickBtn("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/GetBtn"); } if (ActiveGO("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/GoToBtn")) { string realmName = GameObject.Find("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/Desc").GetComponent().text; if (realmName == "穿戴1件5阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2000433;&additem 2002097"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } if (realmName == "穿戴1件6阶金色3星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2000553;&additem 2000554");//&additem 2000555;&additem 2000559;&additem 2000557;&additem 2000558; SendGM("&additem 2002217;&additem 2002218");//&additem 2002219;&additem 2002223;&additem 2002221;&additem 2002222; ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴1件7阶金色1星以上的装备 if (realmName == "穿戴1件7阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2000641;&additem 2000642;&additem 2000643;&additem 2000645;&additem 2000646;&additem 2000647"); SendGM("&additem 2002305;&additem 2002306;&additem 2002307;&additem 2002309;&additem 2002310;&additem 2002311"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴1件8阶金色1星以上的装备 if ((realmName == "穿戴1件8阶金色1星以上的装备")||(realmName == "穿戴2件8阶金色1星以上的装备")||(realmName == "穿戴3件8阶金色1星以上的装备")) { SendGM("&clearmybag"); SendGM("&additem 2000745;&additem 2000746;&additem 2000747;&additem 2000749;&additem 2000750;&additem 2000751"); SendGM("&additem 2002409;&additem 2002410;&additem 2002411;&additem 2002413;&additem 2002414;&additem 2002415"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴1件9阶金色1星以上的装备 if (realmName == "穿戴1件9阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2000849;&additem 2000850;&additem 2000851;&additem 2000853;&additem 2000854;&additem 2000855"); SendGM("&additem 2002513;&additem 2002514;&additem 2002515;&additem 2002517;&additem 2002518;&additem 2002519"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴6件10阶金色1星以上的装备 if (realmName == "穿戴6件10阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2000953;&additem 2000954;&additem 2000955;&additem 2000957;&additem 2000958;&additem 2000959"); SendGM("&additem 2002617;&additem 2002618;&additem 2002619;&additem 2002621;&additem 2002622;&additem 2002623"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴6件11阶金色1星以上的装备 if (realmName == "穿戴6件11阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2001057;&additem 2001058;&additem 2001059;&additem 2001061;&additem 2001062;&additem 2001063"); SendGM("&additem 2002721;&additem 2002722;&additem 2002723;&additem 2002725;&additem 2002726;&additem 2002727"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴6件12阶金色1星以上的装备 if (realmName == "穿戴6件12阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2001161;&additem 2001162;&additem 2001163;&additem 2001165;&additem 2001166;&additem 2001167"); SendGM("&additem 2002825;&additem 2002826;&additem 2002827;&additem 2002829;&additem 2002830;&additem 2002831"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴6件13阶金色1星以上的装备 if (realmName == "穿戴6件13阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2001265;&additem 2001266;&additem 2001267;&additem 2001269;&additem 2001270;&additem 2001271"); SendGM("&additem 2002929;&additem 2002930;&additem 2002931;&additem 2002933;&additem 2002934;&additem 2002935"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } //穿戴6件14阶金色1星以上的装备 if (realmName == "穿戴6件14阶金色1星以上的装备") { SendGM("&clearmybag"); SendGM("&additem 2001369;&additem 2001370;&additem 2001371;&additem 2001373;&additem 2001374;&additem 2001375"); SendGM("&additem 2003033;&additem 2003034;&additem 2003035;&additem 2003037;&additem 2003038;&additem 2003039"); ClickBtn("UIRealmForm/Top/Offset/CloseButton"); } if (realmName == "等级提升到150级") {SendGM("&setlevel 150");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到180级") {SendGM("&setlevel 180");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到200级") {SendGM("&setlevel 200");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到220级") {SendGM("&setlevel 220");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到240级") {SendGM("&setlevel 240");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到260级") {SendGM("&setlevel 260");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到280级") {SendGM("&setlevel 280");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到290级") {SendGM("&setlevel 290");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到300级") {SendGM("&setlevel 300");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到310级") {SendGM("&setlevel 310");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到320级") {SendGM("&setlevel 320");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到340级") {SendGM("&setlevel 340");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到370级") {SendGM("&setlevel 370");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到420级") {SendGM("&setlevel 420");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到480级") {SendGM("&setlevel 480");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到540级") {SendGM("&setlevel 540");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到600级") {SendGM("&setlevel 600");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "等级提升到650级") {SendGM("&setlevel 650");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "参与心魔幻境1次") { ClickBtn("UIRealmForm/Top/Offset/CloseButton"); yield return new WaitForSeconds(1.0f); ClickBtn("RightTop/TopMenu/Panel/0102/Btn"); yield return new WaitForSeconds(1.0f); ClickBtn("UICopyMapForm/UIListMenu/Table/001"); yield return new WaitForSeconds(1.0f); ClickBtn("DuoRenPanel/DescPanel/Down/EnterBtn"); }//参与锁灵台1次 if (realmName == "参与锁灵台1次") { ClickBtn("UIRealmForm/Top/Offset/CloseButton"); yield return new WaitForSeconds(1.0f); ClickBtn("RightTop/TopMenu/Panel/0102/Btn"); yield return new WaitForSeconds(1.0f); ClickBtn("UICopyMapForm/UIListMenu/Table/001"); yield return new WaitForSeconds(1.0f); ClickBtn("DuoRenPanel/UIListMenu/Table/001"); yield return new WaitForSeconds(1.0f); ClickBtn("DuoRenPanel/DescPanel/Down/EnterBtn"); }//击败{0}个晶甲和域首领 if (realmName == "击败1个晶甲和域首领") { ClickBtn("UIRealmForm/Top/Offset/CloseButton"); yield return new WaitForSeconds(1.0f); ClickBtn("RightTop/TopMenu/Panel/0103/Btn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIBossForm/Right/UIListMenu/Table/001"); yield return new WaitForSeconds(1.0f); ClickBtn("UISuitGemWorldBossForm/Bottom/GoBtn"); yield return new WaitForSeconds(20.0f); SendGM("&kill"); ClickBtn("UISuitGemWorldBossCopyForm/RightTop/Leave"); } if (realmName == "万妖卷到达10层") {SendGM("&setlayer 21");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达30层") {SendGM("&setlayer 31");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达35层") {SendGM("&setlayer 36");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达50层") {SendGM("&setlayer 51");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达60层") {SendGM("&setlayer 61");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达65层") {SendGM("&setlayer 66");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达70层") {SendGM("&setlayer 71");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达75层") {SendGM("&setlayer 76");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达80层") {SendGM("&setlayer 81");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "万妖卷到达90层") {SendGM("&setlayer 91");ClickBtn("UIRealmForm/Top/Offset/CloseButton");} if (realmName == "激活5阶或以上2件套") { SendGM("&clearmybag;&additem 24001;&additem 24002;&additem 24007;&additem 24008"); ClickBtn("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/GoToBtn"); yield return new WaitForSeconds(1.0f); } if ((realmName.Contains("击败"))&&(!realmName.Contains("晶甲和域首领"))) { ClickBtn("UIRealmForm/Top/Offset/CloseButton"); yield return new WaitForSeconds(1.0f); SendGM("&skiptime 1440"); yield return new WaitForSeconds(10.0f); ClickBtn("RightTop/TopMenu/Panel/0103/Btn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIBossForm/Right/UIListMenu/Table/006"); yield return new WaitForSeconds(1.0f); ClickBtn("UIStatureBossForm/Bottom/GoBtn"); yield return new WaitForSeconds(20.0f); ClickBtn("UIBossForm/Top/closeButton"); } ClickBtn("UIRealmForm/Right/Offset/TaskRoot/ListPanel/Grid/Item/GoToBtn"); yield return new WaitForSeconds(1.0f); } } //如果没在渡劫界面,就点击境界的渡劫按钮 if (ActiveGO("UIRealmForm/Center/BtnUp") && !ActiveGO("UIDuJieCopyMainForm")) { ClickBtn("UIRealmForm/Center/BtnUp"); yield return new WaitForSeconds(15.0f); } } //获取途径弹窗 if (CheckGO("UIItemQuickGetForm")) { string labelValue = GameObject.Find("UIItemQuickGetForm/Back/Name").GetComponent().text; if(labelValue == "经验值") //去万妖卷 { ClickBtn("UIItemQuickGetForm/Back/Close"); yield return new WaitForSeconds(1.0f); } ClickBtn("UIItemQuickGetForm/Back/Close"); yield return new WaitForSeconds(1.0f); } //首充 if (ActiveGO("UIFristChargeForm/CloseButton")) { ClickBtn("UIFristChargeForm/CloseButton"); } //仙盟欢迎 if (ActiveGO("UIGuildOpenForm/GoBtn")) { ClickBtn("UIGuildOpenForm/GoBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UICreateGuildForm/CloseBtn"); } //剑冢 if (ActiveGO("UIFlySwordGraveForm")) { yield return new WaitForSeconds(1.0f); ClickBtn("UIFlySwordGraveForm/SwordInfo/Right/Button"); //名剑认主按钮 yield return new WaitForSeconds(5.0f); ClickBtn("UIFlySwordGraveForm/RightTop/CloseBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIFlySwordGraveForm/Bottom/Button"); yield return new WaitForSeconds(0.1f); } //剑灵升级 if (ActiveGO("UISpriteGrowUpForm")) { yield return new WaitForSeconds(1.0f); ClickBtn("UISpriteGrowUpForm/UIListMenuRight/Table/001");//培养页签 yield return new WaitForSeconds(3.0f); ClickBtn("UISpriteGrowUpForm/Grow/Button");//升级 yield return new WaitForSeconds(3.0f); ClickBtn("UISpriteGrowUpForm/CloseBtn");//关闭 yield return new WaitForSeconds(3.0f); ClickBtn("UISpriteHomeForm/TopRight/CloseBtn");//关闭 } //古籍解封 if (ActiveGO("UILingtiOpenForm/OpenTrans")) { ClickBtn("UILingtiOpenForm/OpenTrans/ActiveBtn"); yield return new WaitForSeconds(2.0f); ClickBtn("UILingtiOpenForm/CloseBtn"); } //免费VIP界面 if (ActiveGO("UIFreeVIPForm/CloseBtn")) { ClickBtn("UIFreeVIPForm/CloseBtn"); yield return new WaitForSeconds(1.0f); } //灵体穿装备 if (ActiveGO("UILingTiForm/Center/EquipCells/2/RedPoint")) { ClickBtn("UILingTiForm/Center/EquipCells/2/Button"); yield return new WaitForSeconds(1.0f); ClickBtn("BagContainer/Grid/UIBagItem"); yield return new WaitForSeconds(1.0f); ClickBtn("BagPanel/Putin"); yield return new WaitForSeconds(1.0f); ClickBtn("UILingTiBaseForm/CloseBtn"); } //无限层-新手层 if (ActiveGO("UINewWorldBossForm/Bottom/GoBtn")) { ClickBtn("UINewWorldBossForm/Bottom/GoBtn"); yield return new WaitForSeconds(1.0f); } //传道 if (ActiveGO("UIChuanDaoForm/Bottom/GotoBtn")) { ClickBtn("UIChuanDaoForm/Bottom/GotoBtn"); yield return new WaitForSeconds(10.0f); } //拍卖3阶红色 if (ActiveGO("MaXPrice/BuyBtn")) { ClickBtn("MaXPrice/BuyBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIAuctionHouseForm/BuyPanel/OkBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIAuctionHouseForm/Back/CloseBtn"); } //拍卖上架 if (ActiveGO("UIAuctionHouseForm")) { ClickChildBtnByIndex("UIAuctionHouseForm/SellPanel/BagScroll/Grid","0"); yield return new WaitForSeconds(2.0f); ClickBtn("SellTipsPanel/BtnGrid/WorldSell"); yield return new WaitForSeconds(2.0f); ClickBtn("UIAuctionHouseForm/Back/CloseBtn"); } //单人副本 if (CheckGO("UICopyMapForm/DanRenPanel")) { ClickBtn("UICopyMapForm/DanRenPanel/TowerCopy/Down/EnterBtn"); ClickBtn("UICopyMapForm/DanRenPanel/ExpPanel/Down/EnterBtn"); ClickBtn("UICopyMapForm/DanRenPanel/StarCopy/Down/EnterBtn"); ClickBtn("UICopyMapForm/DanRenPanel/TJZMCopy/Down/EnterBtn"); ClickBtn("UICopyMapForm/Close"); } //组队副本 if (CheckGO("DuoRenPanel/DescPanel/Down/EnterBtn")) { ClickBtn("DuoRenPanel/DescPanel/Down/EnterBtn"); } //消息弹窗 if (CheckGO("UIMsgBoxForm")&&(GameObject.Find("UIMsgBoxForm/InformationText/Text"))) { string labelValue = GameObject.Find("UIMsgBoxForm/InformationText/Text").GetComponent().text; if(labelValue.Contains("即将面对的敌人战斗力高达")) //万妖卷 { ClickBtn("UIMsgBoxForm/Controller/Button_1"); } if(labelValue.Contains("更换的装备无法继承套装属性")) //换套装 { ClickBtn("UIMsgBoxForm/Controller/Button_2"); } if(labelValue.Contains("银元宝购买材料及装备")) { ClickBtn("UIMsgBoxForm/Controller/Button_2"); } } //技能一键升级 if (CheckGO("UIOccSkillForm/SkillPanel/Level/OnKeyUP")) { ClickBtn("UIOccSkillForm/SkillPanel/Level/OnKeyUP"); yield return new WaitForSeconds(1.0f); ClickBtn("UIOccSkillForm/SkillPanel/Skill1/PassIcon"); yield return new WaitForSeconds(1.0f); ClickBtn("PassTipsPanel/LevelUP/LevelUPBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIOccSkillForm/CloseBtn"); } //法宝升级+激活经验器灵 if (CheckGO("UIRealmStifleForm/Right/Train/AutoUpBtn/RedPoint")) { //SendGM("&additem 14 999999"); while(GameObject.Find("UIRealmStifleForm/Right/Train/AutoUpBtn/RedPoint").activeSelf) { ClickBtn("UIRealmStifleForm/Right/Train/AutoUpBtn"); yield return new WaitForSeconds(1.0f); } ClickBtn("UIRealmStifleForm/Left/IconTrans/1/Active");//激活经验器灵 ClickBtn("UINatureForm/CloseButton"); } //商城购买 if (CheckGO("UIShopMallForm/ShopPanel/BuyGo/BuyBtn")) { SendGM("&additem 12 999999"); ClickBtn("UIShopMallForm/ShopPanel/BuyGo/BuyBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIShopMallForm/ShopPanel/BuyComfirmGo/OK"); yield return new WaitForSeconds(1.0f); ClickBtn("UIShopMallForm/CloseBtn"); } //装备合成 if (CheckGO("UIEquipSynthForm/Center/EquipGo/SynBtn")) { SendGM("&additem 2000329 2;&additem 2001993 2"); GameObject Go = GameObject.Find("UIEquipSynthForm/Left/EquipRoot/Grid"); foreach (Transform child in Go.transform) { if (child.GetChild(2).gameObject.activeSelf) { UICamera.Notify(child.gameObject,"OnClick",null); yield return new WaitForSeconds(1.0f); ClickBtn("UIEquipSynthForm/Center/EquipGo/SynBtn"); yield return new WaitForSeconds(1.0f); } } ClickBtn("UILianQiForm/CloseBtn"); } //识海 if (CheckGO("UIPlayerShiHaiForm/Right/LevelUp")) { ClickBtn("UIPlayerShiHaiForm/Right/LevelUp"); yield return new WaitForSeconds(1.0f); ClickBtn("UIPlayerBaseForm/CloseBtn"); } //境界首领 if (CheckGO("UIStatureBossForm/Bottom/GoBtn")) { ClickBtn("UIStatureBossForm/Bottom/GoBtn"); ClickBtn("UIBossForm/Top/closeButton"); } //竞技场结算面板 if (CheckGO("UIArenaSXResultForm")) { ClickBtn("UIArenaSXResultForm/Center/QuitBtn"); } //竞技场 if (CheckGO("UIArenaShouXiForm")) { ClickBtn("UIArenaShouXiForm/Center/Item_1/ChallengeBtn"); } //宠物一键升级 if (ActiveGO("UIPetForm/ProPanel/Right/ProPanel/Bottom/OneKey")) { ClickBtn("UIPetForm/ProPanel/Right/ProPanel/Bottom/OneKey"); yield return new WaitForSeconds(1.0f); ClickBtn("UIPetForm/Close"); } //坐骑一键升级 if (ActiveGO("UIMountGrowUpForm/Right/Train/Bottom/OneKey")) { ClickBtn("UIMountGrowUpForm/Right/Train/Bottom/OneKey"); yield return new WaitForSeconds(1.0f); ClickBtn("UIMountForm/Top/closeButton"); } //装备强化 if (ActiveGO("UILianQiForgeStrengthForm/Right/OneKeyStrengthBtn")) { while (ActiveGO("UILianQiForgeStrengthForm/Right/OneKeyStrengthBtn/RedPoint")) { ClickBtn("UILianQiForgeStrengthForm/Right/OneKeyStrengthBtn"); yield return new WaitForSeconds(1.0f); } ClickBtn ("UILianQiForm/CloseBtn"); } //转职 if (CheckGO("UIChangeJobForm/Center/GoToBtn")) { ClickBtn("UIChangeJobForm/Center/GoToBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIChangeJobForm/CloseBtn"); } //洗髓 if (CheckGO("UIXiSuiForm/OneKeyBtn")) { ClickBtn("UIXiSuiForm/OneKeyBtn"); SendGM("&additem 1 99999"); yield return new WaitForSeconds(1.0f); ClickBtn("UIMsgBoxForm/Controller/Button_2"); yield return new WaitForSeconds(1.0f); ClickBtn("UIXiSuiForm/Left/FinishBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UIXiSuiForm/Close"); } //机缘寻宝 if (CheckGO("UITreasureFindForm/Left/BtnScrollView/Grid/TemplateBtn")) { SendGM("&additem 1 99999"); ClickBtn("UITreasureFindForm/Left/BtnScrollView/Grid/TemplateBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("BuyKeysPanel/BuyBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UITreasureFindForm/Left/BtnScrollView/Grid/TemplateBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UITreasureRewardForm/Center/Back1/CloseBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UITreasureHuntForm/CloseBtn"); } //套装 if (CheckGO("UIEquipSuitForm/Right/DuanZaoBtn")) { ClickBtn("UIEquipSuitForm/Right/DuanZaoBtn"); yield return new WaitForSeconds(1.0f); ClickBtnByIndex("UIEquipSuitForm/Left/ScrollView/0","1"); yield return new WaitForSeconds(1.0f); ClickBtn("UIEquipSuitForm/Right/DuanZaoBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("UILianQiForm/CloseBtn"); } //助战 神兽装备 if (ActiveGO("UIAssistFightingForm")) { for (int i = 0;i < 3;i++) { SendGM("&additem 3004001;&additem 3004002;&additem 3004003;&additem 3004004;&additem 3004005"); ClickBtnByIndex("MonsterPanel/MonsterScroll/Grid/Item",i.ToString()); yield return new WaitForSeconds(1.0f); ClickBtn("MonsterPanel/MonsterEquipBagBtn"); yield return new WaitForSeconds(1.0f); foreach(Transform equipItem in GameObject.Find("UIEquipBagPanel/Center/BagScrollView/RightGrid").transform) { if (equipItem.GetChild(2).gameObject.activeSelf) { UICamera.Notify(equipItem.gameObject,"OnClick",null); yield return new WaitForSeconds(1.0f); ClickBtn("UIMonsterEquipTipsForm/Right/Container/Bottom/MoreGrop/Table/EquipBtn"); yield return new WaitForSeconds(1.0f); } } ClickBtn("UIEquipBagPanel/Center/Button"); yield return new WaitForSeconds(1.0f); ClickBtn("MonsterPanel/AssistFightBtn"); yield return new WaitForSeconds(1.0f); } ClickBtn("UIAssistFightingForm/CloseBtn"); yield return new WaitForSeconds(1.0f); } //圣装 if (ActiveGO("UIHolyEquipForm")) { SendGM("&additem 4001311;&additem 4001312;&additem 4001313;&additem 4001314;&additem 4001315;&additem 4001316;&additem 4001317;&additem 4001318;&additem 4001319;&additem 4001320;&additem 4001321"); SendGM("&additem 4101311;&additem 4101312;&additem 4101313;&additem 4101314;&additem 4101315;&additem 4101316;&additem 4101317;&additem 4101318;&additem 4101319;&additem 4101320;&additem 4101321"); ClickBtn("UIHolyEquipForm/CloseBtn"); } //日常面板挨着做日常任务 if (ActiveGO("UIDailyActivityForm/Center")) { GameObject Go = GameObject.Find("UIDailyActivityForm/Center/DailyActivityRoot/ListPanel/Grid"); foreach (Transform child in Go.transform) { if (child.GetChild(7).gameObject.activeSelf) { UICamera.Notify(child.GetChild(7).gameObject,"OnClick",null); yield return new WaitForSeconds(1.0f); } } } //主线任务 if (ActiveGO("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll")) { GameObject Go = GameObject.Find("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll").transform.GetChild(0).GetChild(1).gameObject; string taskName = Go.GetComponent().text; if((taskName == "[突破境界]") && (!GameObject.Find("UIRealmForm"))) { if(timenum > 13) { ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); yield return new WaitForSeconds(1.0f); timenum = 0; } } if(taskName == "[碎片初现2]") { //SendGM("&addbuff 15"); ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); yield return new WaitForSeconds(5.0f); } //碎片初现11,进一次法宝,提升一下战力好过万妖卷10层 if((taskName == "[碎片初现11]")||(taskName == "[碎片初现10]")) { ClickBtn("RightTop/TopMenu/Panel/0002/Btn"); yield return new WaitForSeconds(1.0f); } if(taskName == "[引导一次去拍卖行卖]") { ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); yield return new WaitForSeconds(1.0f); ClickBtn("UIAuctionHouseForm/UIListMenuTop/Table/003"); yield return new WaitForSeconds(1.0f); ClickChildBtnByIndex("SellPanel/BagScroll/Grid","0"); yield return new WaitForSeconds(1.0f); ClickBtn("SellTipsPanel/BtnGrid/WorldSell"); yield return new WaitForSeconds(1.0f); ClickBtn("UIAuctionHouseForm/CloseBtn"); } if(taskName == "[升技能A第1次]") { ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); yield return new WaitForSeconds(1.0f); ClickBtn("UIOccSkillForm/SkillPanel/Level/OnKeyUP"); yield return new WaitForSeconds(1.0f); ClickBtn("Skill1/PassIcon"); yield return new WaitForSeconds(1.0f); ClickBtn("PassTipsPanel/LevelUP/LevelUPBtn"); yield return new WaitForSeconds(1.0f); ClickBtn("PassTipsPanel/Close"); yield return new WaitForSeconds(1.0f); ClickBtn("UIOccSkillForm/CloseBtn"); } } //LogTest("循环"); if((timenum > 13) && ActiveGO("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll")) { GameObject Go = GameObject.Find("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll").transform.GetChild(0).GetChild(6).GetChild(0).gameObject; //任务Type //GameObject Go = GameObject.Find("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll/TaskItem/Type/Value"); if (Go) { string taskType = Go.GetComponent().text; //if (taskType == "主") //{ ClickChildBtnByIndex("UIMainForm/LeftTop/TaskAndTeam/Back/TaskBack/Scroll","0"); timenum = 0; //} /* else { ClickBtn("UIMainForm/LeftTop/RealmRoot/Root/RealmShow"); timenum = 0; } */ } } timenum++; yield return new WaitForSeconds(1.0f); } } public bool CheckGO(string btnurl) { GameObject go = GameObject.Find (btnurl); if (go == null) { return false; } else { return true; } } public bool ActiveGO(string btnurl) { GameObject go = GameObject.Find (btnurl); if (go == null) { return false; } else if (!go.activeSelf) { return false; } else { return true; } } #region 操作 //点击按钮 public void ClickBtn(string file) { GameObject go = GameObject.Find (file); if (go == null) { LogTest ("【Block】,找不到" + file); } else if (go.activeSelf) { var btn = go.GetComponent(); btn.OnClick(); //UICamera.Notify(go,"OnClick",null); LogTest("点击," + file); } else { LogTest ("【Block】,未激活" + file); } } //点击包含Label名称为btnname的按钮,用于多个按钮有同样的名称,btnurl为按钮路径(通常有多个同路径按钮),btnname为子节点包含的label文本 public void ClickBtnByName(string btnurl, string btnname) { GameObject go = GameObject.Find(btnurl); if (go == null) { LogTest ("【Block】,找不到" + btnurl); return; } foreach (Transform child in go.transform.parent) { foreach (UILabel child_label in child.GetComponentsInChildren()) { if (child_label.text.Contains(btnname)) { UICamera.Notify(child.gameObject, "OnClick", null); LogTest("点击," + btnurl + "+" + btnname); return; } } } } //根据index点击btnurl的按钮 public void ClickBtnByIndex(string btnurl, string btnindex) { GameObject go = GameObject.Find(btnurl).transform.parent.GetChild(int.Parse(btnindex)).gameObject; if (go == null) { LogTest ("【Block】,找不到" + btnurl); return; } UICamera.Notify(go, "OnClick", null); LogTest("点击," + btnurl + "+" + btnindex); } //根据index点击子按钮 public void ClickChildBtnByIndex(string btnurl, string btnindex) { GameObject gofather = GameObject.Find(btnurl); if (gofather != null) { GameObject go = GameObject.Find(btnurl).transform.GetChild(int.Parse(btnindex)).gameObject; if (go == null) { LogTest ("【Block】,找不到" + btnurl); return; } UICamera.Notify(go, "OnClick", null); LogTest("点击," + btnurl + "+" + btnindex); } } //发送GM命令 public void SendGM(string GMString) { List gmlist = new List(GMString.Split(';')); foreach (string gm in gmlist) { MSG_Chat.ChatReqCS req = new MSG_Chat.ChatReqCS(); req.chattype = 0; req.recRoleId = 0; req.condition = gm; req.chatchannel = 0; req.Send(); LogTest(gm); } } //输入文本 public void Input(string inputUrl,string inputString) { GameObject go = GameObject.Find(inputUrl); if (go == null) { LogTest ("【Block】,找不到" + inputUrl); } else { UIInput name = go.GetComponent(); name.value = inputString; } } //打开菜单 public void OpenMenu() { GameObject go = GameObject.Find("UIMainForm/LeftButtom/MenuPanel"); if (go == null) { LogTest ("【Block】,找不到菜单按钮"); } else if (go.gameObject.transform.rotation.z == 0) { ClickBtn("UIMainForm/LeftButtom/MenuBtn"); } } //主角停止行动 public void StopAction() { LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer(); if (lp.IsXState(EntityStateID.PathMove)) { Debug.Log ("寻路中"); GameCenter.MapLogicSwitch.DoPlayerExitPrepare(); //lp.Stop_Action(); } } #endregion #region 断言 //断言文本 private void AssertText(string s1, string s2) { if (GameObject.Find(s1) != null) { UILabel ui = GameObject.Find(s1).GetComponent(); if (ui != null) { if (ui.text == s2) { LogTest("[Pass],在:" + s1 + "的文本是:" + s2); return; } else if (ui.text.Contains(s2)) { LogTest("[Pass],在:" + s1 + "包含文本:" + s2); return; } LogTest("【Fail】," + s1 + "不存在文本:" + s2); } else { foreach (Transform child in GameObject.Find(s1).transform.parent) { foreach (UILabel child_label in child.GetComponentsInChildren()) { if (child_label.text.Contains(s2)) { LogTest("[Pass],在:" + s1 + "的子路径包含文本:" + s2); return; } } } } } else { LogTest("【Block】,找不到: " + s1); return; } } //断言存在控件 private void AssertGO(string s1) { GameObject go = GameObject.Find (s1); if (go == null) { LogTest ("【Fail】,找不到:" + s1); } else { LogTest ("[Pass],找到:" + s1); } } //断言不存在控件 private void AssertNoGO(string s1) { GameObject go = GameObject.Find (s1); if (go == null) { LogTest ("[Pass],不存在:" + s1); } else { LogTest ("【Fail】,存在不该存在的:" + s1); } } #endregion } }