private void CollectFoods(GameObject foodSet = null)
 {
     GameObject[] foods = null;
     if (foodSet == null)
     {
         foods = GameObject.FindGameObjectsWithTag("Goods");
     }
     else
     {
         foods = new GameObject[foodSet.transform.childCount];
         for (int i = 0; i < foods.Length; i++)
         {
             foods[i] = foodSet.transform.GetChild(i).gameObject;
         }
     }
     condition             = new TaskCondition();
     condition.collectType = typeof(Food);
     condition.collectNum  = Random.Range(1, 10);
     for (int i = 0; i < condition.collectNum; i++)
     {
         foods[i].transform.position  = Random.insideUnitCircle * 3;
         foods[i].transform.position += foodSet == null ? Vector3.right * 3 : foodSet.transform.position;
         foods[i].SetActive(true);
     }
     OtherTool.SetText("ContentText", string.Format("任务内容:收集{0}个食物", condition.collectNum));
     workers = new GameObject[] { GameObject.Find("Sirika") };
 }
Exemple #2
0
    //构造函数
    public Task(string taskID)
    {
        this.taskID = taskID;
        //从XML文件中文本读入任务信息
        XElement xe = TaskManager.Instance.rootElement.Element(taskID);

        taskName = xe.Element("taskName").Value;
        caption  = xe.Element("caption").Value;
        //获取完成条件元素
        IEnumerable <XElement> a = xe.Elements("conditionID");
        IEnumerator <XElement> b = xe.Elements("conditionTargetAmount").GetEnumerator();

        IEnumerable <XElement> c = xe.Elements("rewardItemID");
        IEnumerator <XElement> d = xe.Elements("rewardAmount").GetEnumerator();
        IEnumerator <XElement> e = xe.Elements("rewardItemName").GetEnumerator();
        IEnumerator <XElement> f = xe.Elements("ItemMaxNum").GetEnumerator();

        foreach (var s in a)
        {
            b.MoveNext();
            TaskCondition tc = new TaskCondition(int.Parse(s.Value), 0, int.Parse(b.Current.Value));
            taskConditions.Add(tc);
        }
        foreach (var s in c)
        {
            d.MoveNext();
            e.MoveNext();
            f.MoveNext();
            ContainerItem cIt = new ContainerItem(int.Parse(s.Value), e.Current.Value, int.Parse(d.Current.Value), int.Parse(f.Current.Value));
            taskRewards.Add(cIt);
        }
    }
Exemple #3
0
    public List <TaskReward> taskRewards       = new List <TaskReward>();    //任务奖励



    //根据taskNum读取XML,实现初始化
    public Task(string taskID)
    {
        this.taskID = taskID;
        XElement xe = TaskManager.Instance.rootElement.Element(taskID);

        taskName = xe.Element("taskName").Value;
        caption  = xe.Element("caption").Value;

        IEnumerable <XElement> a = xe.Elements("conditionID");
        IEnumerator <XElement> b = xe.Elements("conditionTargetAmount").GetEnumerator();

        IEnumerable <XElement> c = xe.Elements("rewardID");
        IEnumerator <XElement> d = xe.Elements("rewardAmount").GetEnumerator();


        foreach (var s in a)
        {
            int number = Random.Range(1, 9);
            b.MoveNext();
            TaskCondition tc = new TaskCondition(s.Value, 0, int.Parse(b.Current.Value) * number);
            taskConditions.Add(tc);
        }

        foreach (var s in c)
        {
            d.MoveNext();
            int        numbers = Random.Range(1, 9);
            TaskReward tr      = new TaskReward(s.Value, int.Parse(d.Current.Value) * numbers);
            taskRewards.Add(tr);
        }
    }
 /// <summary>
 /// Condition the specified builder and function.
 /// </summary>
 /// <returns>The condition.</returns>
 /// <param name="builder">Builder.</param>
 /// <param name="function">Function.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public static TaskBuilder <T> Condition <T>
 (
     this TaskBuilder <T> builder,
     TaskCondition <T> .Delegate function
 )
 {
     return(builder.Push(new TaskCondition <T>(function)));
 }
Exemple #5
0
 public static void GetTaskData(TaskCondition tc)
 {
     Process p = new Process();
     p.StartInfo.CreateNoWindow = true;
     p.StartInfo.Arguments = tc.ToString();
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.FileName = Path;
     p.Start();
     p.WaitForExit();
 }
Exemple #6
0
    public static void GetTaskData(TaskCondition tc)
    {
        Process p = new Process();

        p.StartInfo.CreateNoWindow  = true;
        p.StartInfo.Arguments       = tc.ToString();
        p.StartInfo.UseShellExecute = false;
        p.StartInfo.FileName        = GetPath();
        p.Start();
        p.WaitForExit();
    }
Exemple #7
0
    //根据taskId读取json,实现初始化
    public TaskInfo(string taskID, int curComplete = 0, bool isGetReward = false)
    {
        this.taskID = taskID;

        JsonData json = GetTaskJson(taskID);

        taskName = json.TryGetString("taskName");
        icon     = json.TryGetString("taskIcon");
        string conditionId = json.TryGetString("conditionId");
        string rewardId    = json.TryGetString("rewardId");

        taskCondition = new TaskCondition(conditionId, curComplete, int.Parse(json.TryGetString("conditionCount")));
        taskReward    = new TaskReward(rewardId, int.Parse(json.TryGetString("rewardCount")), isGetReward);
    }
Exemple #8
0
        /**任务寻路
         * @param taskId 任务ID
         * @param index  指定条件索引(0:当前条件寻路,0>:指定条件索引寻路)
         * **/
        public void createTaskPath(String taskId, int index = 0)
        {
            Task task = TaskExecute.instance.get(taskId);

            if (task == null)
            {
                return;
            }

            //不可接、未领取、已完成的任务,则自动寻路到NPC前
            if (task.state != TaskConst.STATE_DOING)
            {
                createPath(TO_NPC, task.curNpc());
                //Log.info(this, "-createTaskPath() 自动寻路到NPC:" + task.curNpc() + " 跟前!");
                return;
            }

            //已接未完成,根据条件追踪。index==0:当前首个可追踪条件,index>0:指定追踪索引
            TaskCondition conditon = index < 1 ? task.curCondition() : task.getCondition(index);

            if (conditon == null)
            {
                return;
            }
            switch (conditon.sort)
            {
            //杀怪
            case TaskConst.C_3:
                createPath(TO_MONSTER, conditon.mapId, conditon.targetId);
                break;

            //采集物品|收集物品
            case TaskConst.C_4:
            case TaskConst.C_5:
                createPath(TO_SCENE, conditon.mapId);
                break;
            }
        }
Exemple #9
0
        /**任务寻路
         * @param taskId 任务ID
         * @param index  指定条件索引(0:当前条件寻路,0>:指定条件索引寻路)
         * **/
        public void createTaskPath(String taskId, int index = 0)
        {  //com.u3d.bases.task
            com.u3d.bases.task.Task task = TaskExecute.instance.get(taskId);
            if (task == null)
            {
                return;
            }

            //不可接、未领取、已完成的任务,则自动寻路到NPC前
            if (task.state != TaskConst.STATE_DOING)
            {
                createPath(TO_NPC, task.curNpc());
                Log.info(this, "-createTaskPath() 自动寻路到NPC:" + task.curNpc() + " 跟前!");
                return;
            }

            //已接未完成,根据条件追踪。index==0:当前首个可追踪条件,index>0:指定追踪索引
            TaskCondition conditon = index < 1 ? task.curCondition() : task.getCondition(index);

            if (conditon == null)
            {
                return;
            }
            switch (conditon.sort)
            {
            //采集(直接跳转到指定场景)
            case TaskConst.C_4:
                //AppFacde.instance.getControl(MapControl.
                break;

            //到副本
            case TaskConst.C_3:
            case TaskConst.C_5:
            case TaskConst.C_9:
                createPath(TO_COPY, conditon.backupId);
                break;
            }
        }
    public void LoadMissions(XmlDocument xmlDoc)
    {
        var selectedNodes =
            xmlDoc.SelectNodes("//level/missions/mission");

        foreach (XmlNode currentNode in selectedNodes)
        {
            newMission = new Mission
            {
                id            = currentNode.Attributes["id"].Value,
                description   = currentNode.Attributes["description"].Value,
                prerequisites = currentNode.Attributes["prerequisites"].Value
            };

            newMission.MissionTasks = new List <MissionTask>();


            var selectedTask =
                xmlDoc.SelectNodes(string.Format("//level/missions/mission[@id='{0}']/tasks/task", newMission.id));

            foreach (XmlNode currentTask in selectedTask)
            {
                newMissionTask = new MissionTask
                {
                    id          = currentTask.Attributes["id"].Value,
                    description = currentTask.Attributes["description"].Value
                };
                newMissionTask.TaskConditions = new List <TaskCondition>();

                var selectedTaskConditions = xmlDoc.SelectNodes(string.Format("//level/missions/mission[@id='{0}']/tasks/task[@id='{1}']/conditions/condition", newMission.id, newMissionTask.id));
                foreach (XmlNode currentTaskCondition in selectedTaskConditions)
                {
                    newTaskCondition = new TaskCondition
                    {
                        Type = (TaskCondition.TaskConditionType)Enum.Parse(typeof(TaskCondition.TaskConditionType),
                                                                           currentTaskCondition.Attributes["type"].Value),
                        uniqueObjectNameFrom = currentTaskCondition.Attributes["uniqueObjectNameFrom"].Value,
                        uniqueObjectNameTo   = currentTaskCondition.Attributes["uniqueObjectNameTo"].Value
                    };
                    newMissionTask.TaskConditions.Add(newTaskCondition);
                }

                newMissionTask.TaskActions = new List <TaskAction>();

                var selectedTaskActions = xmlDoc.SelectNodes(string.Format("//level/missions/mission[@id='{0}']/tasks/task[@id='{1}']/actions/action", newMission.id, newMissionTask.id));
                foreach (XmlNode currentTaskCondition in selectedTaskActions)
                {
                    newTaskAction = new TaskAction
                    {
                        Type = (TaskAction.TaskActionType)Enum.Parse(typeof(TaskAction.TaskActionType),
                                                                     currentTaskCondition.Attributes["type"].Value),
                        uniqueObjectNameFrom = currentTaskCondition.Attributes["uniqueObjectNameFrom"].Value,
                        uniqueObjectNameTo   = currentTaskCondition.Attributes["uniqueObjectNameTo"].Value,
                        Quantity             = Convert.ToSingle(currentTaskCondition.Attributes["quantity"].Value)
                    };

                    newMissionTask.TaskActions.Add(newTaskAction);
                }
                newMission.MissionTasks.Add(newMissionTask);
            }

            Game.Instance().CurrentLevel.Missions.Add(newMission);
        }
    }
Exemple #11
0
    public void AddContiditions(int id, int nowAmount, int targetAmount)
    {
        TaskCondition taskCondition = new TaskCondition(id, nowAmount, targetAmount);

        taskConditions.Add(taskCondition);
    }
Exemple #12
0
 private void parseCondition(string str)
 {
     string[] strs = str.Split(',');
     condition = new TaskCondition(strs);
 }
Exemple #13
0
    private void AddCondition(TaskConfig.TaskFinishCondition condition)
    {
        TaskCondition cond = null;

        switch (condition.condition)
        {
        case EnumTaskCondition.MoodValue:
        {
            IFactroyCondition factroy = new MoodFactoryCondition();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.EnergyValue:
        {
            IFactroyCondition factroy = new EnergFactoryCondition();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.FinishAllEvent:
        {
            IFactroyCondition factroy = new FinishAllEventFactroyCondition();
            cond = factroy.CreateCondition(condition.value);
        } break;

        case EnumTaskCondition.ConsumeGold:
        {
            IFactroyCondition factroy = new ConsumeGoldConditionFactroy();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.ChooseGoodAnswer:
        {
            IFactroyCondition factroy = new ChooseGoodAnswerFactroy();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.Gift:
        {
            IFactroyCondition factroy = new GiftFactroy();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.DateScore:
        {
            IFactroyCondition factroy = new DateScoreFactroy();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.FinishSceneEvent:
        {
            IFactroyCondition factroy = new FinishSceneEventFactroy();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        case EnumTaskCondition.None:
        {
            IFactroyCondition factroy = new NoneConditionFactory();
            cond = factroy.CreateCondition(condition.value);
        }
        break;

        default:
            break;
        }
        if (cond != null)
        {
            cond.m_targetID      = taskTargetID;
            cond.m_taskCondition = condition.condition;
            cond.m_curValue      = condition.progress;
        }
        m_taskCondition.Add(cond);
    }