Exemplo n.º 1
0
        public static List <ExeTask> getTaskLstFromFile()
        {
            List <ExeTask> lst  = new List <ExeTask>();
            string         path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\自动任务.txt";

            string[] strs = File.ReadAllLines(path, System.Text.Encoding.Default);
            int      i    = 0;

            try
            {
                for ( ; i < strs.Length; i++)
                {
                    string str = strs[i];
                    if (!string.IsNullOrEmpty(str))
                    {
                        ExeTask task = (ExeTask)JsonManager.JsonToObject(str, typeof(ExeTask));
                        if (task != null)
                        {
                            lst.Add(task);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleLog.Instance.writeInformationLog(ex.Message + "\r\n" + ex.StackTrace);
            }
            return(lst);
        }
Exemplo n.º 2
0
        public bool ExecuteTask(ref RoleSel role)
        {
            // 从自动任务文档中查找解决方案
            //List<TaskObj> lst = null;
            //TaskObj.getTasklistFromTxt(txtpath, ref lst);
            //TaskObj tobj = lst.Find(delegate(TaskObj user) { return user.TaskName == task.taskName; });

            //Dictionary<string, string> querylst = new Dictionary<string,string>();
            //if (!string.IsNullOrEmpty(tobj.TargetID))
            //    querylst.Add(tobj.TargetStr, tobj.TargetID);
            //else
            //    querylst.Add(tobj.TargetStr, task.areaId.ToString());
            Task curtask = m_client.RefreshCurTask();

            if (curtask != null)
            {
                role.CurTask = curtask;
            }
            Task task = role.CurTask;

            ExeTask curtaskInfo = m_lst.Find(x => x.taskInfo.taskId == task.taskId);

            if (curtaskInfo == null)
            {
                ConsoleLog.Instance.writeInformationLog("未找到当前任务信息,结束");
                return(false);
            }

            ConsoleLog.Instance.writeInformationLog("当前任务=" + task.taskName + ";" + task.introLong);
            for (int i = 0; i < curtaskInfo.stepList.Count; i++)
            {
                TaskStep step = curtaskInfo.stepList[i];
                if (step.time > 0 && step.time < 2 * 60 * 1000)
                {
                    Thread.Sleep(step.time);
                }

                if (step.Cmd != "player@setPlayerNameAndPic")
                {
                    Command cmd = new Command(step.Cmd, step.CmdStr);
                    m_client.Send(cmd.outputarr);
                }
                else
                {
                    string  RoleName1 = RoleName.RandomName();
                    string  str       = "playerName=" + RoleName1 + "&pic=2&up=0";
                    Command cmd       = new Command(step.Cmd, str);
                    m_client.Send(cmd.outputarr);
                }
            }

            return(true);
        }