/// <summary>
        /// 获得数据
        /// </summary>
        /// <param name="typeId"></param>
        /// <param name="client"></param>
        /// <returns></returns>
        private static List <TodayCandoData> GetRoleCandoData(int typeId, GameClient client)
        {
            List <TodayCandoData> candolist = new List <TodayCandoData>();

            if (xmlData == null)
            {
                return(null);
            }
            IEnumerable <XElement> xmlItems = xmlData.Elements();
            int iMaxlevel      = -1;
            int iMaxchangelife = -1;
            int ifirst         = 0;
            int lastSectype    = -1;
            Dictionary <int, List <TodayCandoData> > temp = new Dictionary <int, List <TodayCandoData> >();

            foreach (var item in xmlItems)
            {
                if (null != item)
                {
                    int      type             = (int)Global.GetSafeAttributeLong(item, "Type");
                    string[] minilevel        = Global.GetSafeAttributeStr(item, "MinLevel").Split(',');
                    string[] maxlevel         = Global.GetSafeAttributeStr(item, "MaxLevel").Split(',');
                    int      curmaxchangelife = Global.SafeConvertToInt32(minilevel[0]);
                    int      curmaxlevel      = Global.SafeConvertToInt32(minilevel[1]);
                    string   NeedRenWu        = Global.GetSafeAttributeStr(item, "NeedRenWu");
                    bool     condition1       = false;

                    //判断等级
                    if (Global.SafeConvertToInt32(minilevel[0]) < client.ClientData.ChangeLifeCount && client.ClientData.ChangeLifeCount < Global.SafeConvertToInt32(maxlevel[0]))
                    {
                        condition1 = true;
                    }
                    if (Global.SafeConvertToInt32(minilevel[0]) == client.ClientData.ChangeLifeCount)
                    {
                        if (Global.SafeConvertToInt32(minilevel[1]) <= client.ClientData.Level)
                        {
                            condition1 = true;
                        }
                    }
                    if (Global.SafeConvertToInt32(maxlevel[0]) == client.ClientData.ChangeLifeCount)
                    {
                        if (Global.SafeConvertToInt32(maxlevel[1]) >= client.ClientData.Level)
                        {
                            condition1 = true;
                        }
                    }

                    //判断前置任务
                    bool condition2 = false;
                    if (string.IsNullOrEmpty(NeedRenWu))
                    {
                        condition2 = true;
                    }
                    else
                    {
                        int taskid = Global.SafeConvertToInt32(NeedRenWu);
                        condition2 = TaskHasDone(client, taskid);
                        //OldTaskData taskData = null;
                        //if (type == typeId)
                        //{
                        //    taskData = Global.FindOldTaskByTaskID(client, taskid);
                        //}

                        //if (null != taskData) //如果任务存在
                        //{
                        //    if (taskData.DoCount > 0)
                        //        condition2 = true;

                        //}
                    }


                    if (type == typeId && condition1 && condition2)
                    {
                        TodayCandoData data = new TodayCandoData();
                        data.ID = (int)Global.GetSafeAttributeLong(item, "ID");
                        int secondtype = (int)Global.GetSafeAttributeLong(item, "SecondType");
                        if (ifirst == 0)
                        {
                            lastSectype = secondtype;
                        }
                        else if (ifirst != 0 && lastSectype != secondtype)
                        {
                            iMaxchangelife = curmaxchangelife;
                            iMaxlevel      = curmaxlevel;
                        }

                        ifirst += 1;
                        if (iMaxchangelife < curmaxchangelife && lastSectype == secondtype)
                        {
                            if (temp.ContainsKey(secondtype))
                            {
                                foreach (var tempitem in temp[secondtype])
                                {
                                    candolist.Remove(tempitem);
                                }
                                temp[secondtype] = new List <TodayCandoData>();
                            }

                            iMaxchangelife = curmaxchangelife;
                            iMaxlevel      = curmaxlevel;
                            //lastSectype =
                        }
                        if (iMaxchangelife == curmaxchangelife && iMaxlevel < curmaxlevel && lastSectype == secondtype)
                        {
                            if (temp.ContainsKey(secondtype))
                            {
                                foreach (var tempitem in temp[secondtype])
                                {
                                    candolist.Remove(tempitem);
                                }
                                temp[secondtype] = new List <TodayCandoData>();
                            }
                            iMaxchangelife = curmaxchangelife;
                            iMaxlevel      = curmaxlevel;
                        }

                        int copyId    = (int)Global.GetSafeAttributeLong(item, "CodeID");
                        int leftcount = TodayCandoManager.GetLeftCountByType(client, secondtype, copyId);
                        if (leftcount <= 0)
                        {
                            continue;
                        }

                        data.LeftCount = leftcount;

                        candolist.Add(data);
                        if (temp.ContainsKey(secondtype))
                        {
                            temp[secondtype].Add(data);
                        }
                        else
                        {
                            temp[secondtype] = new List <TodayCandoData>();
                            temp[secondtype].Add(data);
                        }

                        lastSectype = secondtype;
                    }
                }
            }

            return(candolist);
        }
示例#2
0
        private static List <TodayCandoData> GetRoleCandoData(int typeId, GameClient client)
        {
            List <TodayCandoData> candolist = new List <TodayCandoData>();
            List <TodayCandoData> result;

            if (TodayCandoManager.xmlData == null)
            {
                result = null;
            }
            else
            {
                IEnumerable <XElement> xmlItems = TodayCandoManager.xmlData.Elements();
                int iMaxlevel      = -1;
                int iMaxchangelife = -1;
                int ifirst         = 0;
                int lastSectype    = -1;
                Dictionary <int, List <TodayCandoData> > temp = new Dictionary <int, List <TodayCandoData> >();
                foreach (XElement item in xmlItems)
                {
                    if (null != item)
                    {
                        int      type      = (int)Global.GetSafeAttributeLong(item, "Type");
                        string[] minilevel = Global.GetSafeAttributeStr(item, "MinLevel").Split(new char[]
                        {
                            ','
                        });
                        string[] maxlevel = Global.GetSafeAttributeStr(item, "MaxLevel").Split(new char[]
                        {
                            ','
                        });
                        int    curmaxchangelife = Global.SafeConvertToInt32(minilevel[0]);
                        int    curmaxlevel      = Global.SafeConvertToInt32(minilevel[1]);
                        string NeedRenWu        = Global.GetSafeAttributeStr(item, "NeedRenWu");
                        bool   condition        = false;
                        if (Global.SafeConvertToInt32(minilevel[0]) < client.ClientData.ChangeLifeCount && client.ClientData.ChangeLifeCount < Global.SafeConvertToInt32(maxlevel[0]))
                        {
                            condition = true;
                        }
                        if (Global.SafeConvertToInt32(minilevel[0]) == client.ClientData.ChangeLifeCount)
                        {
                            if (Global.SafeConvertToInt32(minilevel[1]) <= client.ClientData.Level)
                            {
                                condition = true;
                            }
                        }
                        if (Global.SafeConvertToInt32(maxlevel[0]) == client.ClientData.ChangeLifeCount)
                        {
                            if (Global.SafeConvertToInt32(maxlevel[1]) >= client.ClientData.Level)
                            {
                                condition = true;
                            }
                        }
                        bool condition2;
                        if (string.IsNullOrEmpty(NeedRenWu))
                        {
                            condition2 = true;
                        }
                        else
                        {
                            int taskid = Global.SafeConvertToInt32(NeedRenWu);
                            condition2 = TodayCandoManager.TaskHasDone(client, taskid);
                        }
                        if (type == typeId && condition && condition2)
                        {
                            TodayCandoData data = new TodayCandoData();
                            data.ID = (int)Global.GetSafeAttributeLong(item, "ID");
                            int secondtype = (int)Global.GetSafeAttributeLong(item, "SecondType");
                            if (ifirst == 0)
                            {
                                lastSectype = secondtype;
                            }
                            else if (ifirst != 0 && lastSectype != secondtype)
                            {
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            ifirst++;
                            if (iMaxchangelife < curmaxchangelife && lastSectype == secondtype)
                            {
                                if (temp.ContainsKey(secondtype))
                                {
                                    foreach (TodayCandoData tempitem in temp[secondtype])
                                    {
                                        candolist.Remove(tempitem);
                                    }
                                    temp[secondtype] = new List <TodayCandoData>();
                                }
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            if (iMaxchangelife == curmaxchangelife && iMaxlevel < curmaxlevel && lastSectype == secondtype)
                            {
                                if (temp.ContainsKey(secondtype))
                                {
                                    foreach (TodayCandoData tempitem in temp[secondtype])
                                    {
                                        candolist.Remove(tempitem);
                                    }
                                    temp[secondtype] = new List <TodayCandoData>();
                                }
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            int copyId    = (int)Global.GetSafeAttributeLong(item, "CodeID");
                            int leftcount = TodayCandoManager.GetLeftCountByType(client, secondtype, copyId);
                            if (leftcount > 0)
                            {
                                data.LeftCount = leftcount;
                                candolist.Add(data);
                                if (temp.ContainsKey(secondtype))
                                {
                                    temp[secondtype].Add(data);
                                }
                                else
                                {
                                    temp[secondtype] = new List <TodayCandoData>();
                                    temp[secondtype].Add(data);
                                }
                                lastSectype = secondtype;
                            }
                        }
                    }
                }
                result = candolist;
            }
            return(result);
        }