Exemplo n.º 1
0
 /// <summary>
 /// 任务放异
 /// </summary>
 /// <param name="note">角色信息</param>
 /// <param name="task">任务</param>
 /// <returns></returns>
 public static bool TaskGiveup(PlayerBusiness pb, Task task, bool isremove = true)
 {
     PlayerEx burden = pb.B0;
     Variant v = task.Value;
     //完成条件
     IList finish = v["Finish"] as IList;
     foreach (Variant k in finish)
     {
         string goodsid = k.GetStringOrDefault("GoodsID");
         int Cur = k.GetIntOrDefault("Cur");
         if (Cur == 0) continue;
         switch (k.GetIntOrDefault("Type"))
         {
             case 10006:
                 Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
                 Variant vn = new Variant();
                 vn.Add("Number1", Cur);
                 dic.Add(goodsid, vn);
                 if (BurdenManager.IsFullBurden(burden, dic))
                     return true;
                 pb.AddGoods(dic, GoodsSource.TaskGiveup);
                 break;
             case 10003:
             case 10009:
             case 10010:
                 BurdenManager.Remove(burden, goodsid, Cur);
                 break;
         }
         k["Cur"] = 0;
     }
     v["Status"] = 0;
     if (isremove)
     {
         task.Save();
     }
     pb.Call(TaskCommand.GiveupR, true, task.ID);
     return false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 任务更新
        /// </summary>
        /// <param name="note"></param>
        /// <param name="gc"></param>
        /// <param name="task"></param>
        public static void UpdateFinishTask(UserNote note, GameConfig gc, Task task)
        {
            IList npcs = gc.Value.GetValue<IList>("NPCBaseInfo");
            Variant npcA = npcs[0] as Variant;//接任务NPC
            Variant npcB = npcs[1] as Variant;//领奖NPC
            IList finish = task.Value.GetValue<IList>("Finish");
            int status = task.Value.GetIntOrDefault("Status");
            if (status == 0)
            {
                //接任务的NPC
                string npcid = npcA.GetStringOrDefault("NPCID");
                //接任务
                if (!TaskBusiness.TaskNpcCheck(note.Player, TaskCommand.UpdateTaskR, npcid))
                {
                    note.Call(TaskCommand.UpdateTaskR, false, TipManager.GetMessage(TaskReturn.Npc3));
                    return;
                }

                for (int i = 0; i < finish.Count; i++)
                {
                    Variant v = finish[i] as Variant;
                    string type = v.GetStringOrDefault("Type");
                    if (note.Player.SceneID == npcA.GetStringOrDefault("NPCSceneID"))
                    {
                        if (type == "30001")
                        {
                            if (!TaskFinish30001(note, v))
                                return;
                        }
                    }

                    if (type == "10010")
                    {
                        if (!TaskFinish10010(note, v))
                        {
                            note.Call(TaskCommand.UpdateTaskR, false, TipManager.GetMessage(BurdenReturn.BurdenFull));
                            return;
                        }
                    }

                    if (type == "10004")
                    {
                        Task10004(note, v);
                    }
                    else if (type == "10007")
                    {
                        TaskFinish10007(note, v);
                    }
                    else if (type == "10008")
                    {
                        Task10008(note, v);
                    }
                    else if (type == "10003")
                    {
                        TaskFinish10003(note, v);
                    }
                }

                bool m = true;
                foreach (Variant s in finish)
                {
                    if (s.GetIntOrDefault("Total") != s.GetIntOrDefault("Cur"))
                    {
                        m = false;
                        break;
                    }
                }
                if (m)
                {
                    task.Value["Status"] = 2;
                }
                else
                {
                    //接任务时候的时间
                    task.Value["Status"] = 1;
                }
                task.Save();
                TaskBusiness.TaskAPC(note);
                note.Call(TaskCommand.UpdateTaskR, true, TaskAccess.Instance.GetTaskInfo(task));
                return;
            }

            if (status == 1)
            {
                //判断完成条件
                foreach (Variant s in finish)
                {
                    string str = s.GetStringOrDefault("Type");
                    switch (str)
                    {
                        case "10002":
                            TaskFinish10002(note, s);
                            break;
                        case "10004":
                            Task10004(note, s);
                            break;
                        case "10005":
                            TaskFinish10005(note, s);
                            break;
                        case "10006":
                            TaskFinish10006(note, s);
                            break;
                        case "10007":
                            TaskFinish10007(note, s);
                            break;
                        case "10003":
                            TaskFinish10003(note, s);
                            break;
                    }
                }
            }

            bool isfinish = true;
            foreach (Variant s in finish)
            {
                if (s.GetIntOrDefault("Total") != s.GetIntOrDefault("Cur"))
                {
                    isfinish = false;
                    break;
                }
            }

            if (isfinish)
            {
                task.Value["Status"] = 2;
            }
            task.Save();
            note.Call(TaskCommand.UpdateTaskR, true, TaskAccess.Instance.GetTaskInfo(task));
            TaskBusiness.TaskAPC(note);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 任务放异
 /// </summary>
 /// <param name="note">角色信息</param>
 /// <param name="task">任务</param>
 /// <returns></returns>
 public static bool TaskGiveup(PlayerBusiness pb, Task task, bool isremove = true)
 {
     PlayerEx burden = pb.B0;
     Variant v = task.Value;
     //完成条件
     IList finish = v.GetValue<IList>("Finish");
     for (int i = 0; i < finish.Count; i++)
     {
         Variant k = finish[i] as Variant;
         if (k == null) continue;
         string goodsid = k.GetStringOrDefault("GoodsID");
         int Cur = k.GetIntOrDefault("Cur");
         switch (k.GetIntOrDefault("Type"))
         {
             case 10006:
                 Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
                 Variant vn = new Variant();
                 vn.Add("Number1", Cur);
                 dic.Add(goodsid, vn);
                 if (BurdenManager.IsFullBurden(burden, dic))
                 {
                     pb.Call(TaskCommand.GiveupR, false, TipManager.GetMessage(BurdenReturn.BurdenFull));
                     return true;
                 }
                 pb.AddGoods(dic, GoodsSource.TaskGiveup);
                 break;
             case 10003:
             case 10009:
             case 10010:
                 //BurdenAccess.Remove(burden, goodsid, Cur);
                 pb.RemoveGoods(goodsid, Cur, GoodsSource.TaskGiveup);
                 break;
         }
         k["Cur"] = 0;
     }
     v["Status"] = 0;
     if (isremove)
     {
         task.Save();
     }
     pb.Call(TaskCommand.GiveupR, true, task.ID);
     return false;
 }