Beispiel #1
0
 /// <summary>
 /// 查找一条任务的全部奖励物品
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public static List<QuestAwardInfo> GetQuestGoods(QuestInfo info)
 {
     if (m_questgoods.ContainsKey(info.ID))
     {
         List<QuestAwardInfo> items = m_questgoods[info.ID];
         return items;
     }
     return null;
 }
Beispiel #2
0
 /// <summary>
 /// 查找一条任务的全部条件
 /// </summary>
 /// <param name="info">传入一条任务</param>
 /// <returns></returns>
 public static List<QuestConditionInfo> GetQuestCondiction(QuestInfo info)
 {
     if (m_questcondiction.ContainsKey(info.ID))
     {
         List<QuestConditionInfo> items = m_questcondiction[info.ID];
         return items;
     }
     return null;
 }
Beispiel #3
0
 /// <summary>
 /// 传入用户任务数据
 /// </summary>
 /// <param name="info">一条系统任务</param>
 /// <param name="data">一条用户任务</param>
 public BaseQuest(QuestInfo info, QuestDataInfo data)
 {
     m_info = info;
     m_data = data;
     m_data.QuestID = m_info.ID;
     m_list = new List<BaseCondition>();
     List<QuestConditionInfo> list = QuestMgr.GetQuestCondiction(info);
     int index = 0;
     foreach (QuestConditionInfo ci in list)
     {
         BaseCondition cd = BaseCondition.CreateCondition(this, ci, data.GetConditionValue(index++));
         if (cd != null)
             m_list.Add(cd);
     }
 }
Beispiel #4
0
        /// <summary>
        /// 判断当前用户是否可以接受当前任务,如果可以则添加到内存
        /// </summary>
        /// <param name="info">系统任务</param>
        /// <returns></returns>
        public bool AddQuest(QuestInfo info, out string msg)
        {
            #region 判断是否满足系统任务条件
            msg = "";
            //当前任务是否存在
            try
            {

                if (info == null)
                {
                    msg = "Game.Server.Quests.NoQuest";
                    return false;
                }
                //任务是否开始
                if (info.TimeMode && DateTime.Now.CompareTo(info.StartDate) < 0)
                {
                    msg = "Game.Server.Quests.NoTime";
                }
                //任务是否结束
                if (info.TimeMode && DateTime.Now.CompareTo(info.EndDate) > 0)
                {
                    msg = "Game.Server.Quests.TimeOver";
                }
                //任务是否未达到用户最小等级
                if (m_player.PlayerCharacter.Grade < info.NeedMinLevel)
                {
                    msg = "Game.Server.Quests.LevelLow";
                }
                //任务是否超出用户最高等级
                if (m_player.PlayerCharacter.Grade > info.NeedMaxLevel)
                {
                    msg = "Game.Server.Quests.LevelTop";
                }
                //前置任务是否完成
                if (info.PreQuestID != "0,")
                {
                    string[] tempArry = info.PreQuestID.Split(',');
                    for (int i = 0; i < tempArry.Length - 1; i++)
                    {
                        if (IsQuestFinish(Convert.ToInt32(tempArry[i])) == false)
                        {
                            msg = "Game.Server.Quests.NoFinish";
                        }
                    }
                }
            }
            catch (Exception e)
            {
                log.Info(e.InnerException);
            }
            //判断当前用户是否允许接受工会任务
            if ((info.IsOther == 1) && (!m_player.PlayerCharacter.IsConsortia))
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            //判断当前用户是否可以接受结婚任务
            if ((info.IsOther == 2) && (!m_player.PlayerCharacter.IsMarried))
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            #endregion

            #region 判断用户已开始的当前任务
            BaseQuest oldData = FindQuest(info.ID);
            //判断当前任务已经完成
            if ((oldData != null) && (oldData.Data.IsComplete))
            {
                msg = "Game.Server.Quests.Have";
            }
            //判断当任务是否可以重复接受
            if ((oldData != null) && (!oldData.Info.CanRepeat))
            {
                msg = "Game.Server.Quests.NoRepeat";
            }
            //判断当前任务可以接受间隔(天)内可重复接受次数
            if ((oldData != null) && (DateTime.Now.CompareTo(oldData.Data.CompletedDate.Date.AddDays(oldData.Info.RepeatInterval)) < 0) && (oldData.Data.RepeatFinish < 1))
            {
                msg = "Game.Server.Quests.Rest";
            }
            BaseQuest _baseQuest = m_player.QuestInventory.FindQuest(info.ID);
            if (_baseQuest != null)
            {
                msg = "Game.Server.Quests.Have";
            }
            #endregion

            #region 当前任务添加到内存
            if (msg == "")
            {
                //check is added

                List<QuestConditionInfo> info_condition = Bussiness.Managers.QuestMgr.GetQuestCondiction(info);
                //设置随机获取物品
                int rand = 1;
                if (Bussiness.ThreadSafeRandom.NextStatic(1000000) <= info.Rands)
                {
                    rand = info.RandDouble;
                }

                BeginChanges();

                if (oldData == null)
                {
                    oldData = new BaseQuest(info,new QuestDataInfo());
                    AddQuest(oldData);
                    oldData.Reset(m_player, rand);
                }
                else
                {
                    oldData.Reset(m_player, rand);
                    oldData.AddToPlayer(m_player);
                    OnQuestsChanged(oldData);
                }

                CommitChanges();
                SaveToDatabase();
                return true;
            }
            else
            {
                msg = LanguageMgr.GetTranslation(msg);
                return false;
            }
            #endregion
        }
Beispiel #5
0
 /// <summary>
 /// 任务模板
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public static XElement CreateQuestInfo(QuestInfo info)
 {
     return new XElement("Item", new XAttribute("ID", info.ID),
         new XAttribute("QuestID", info.QuestID),
         new XAttribute("Title", info.Title),
         new XAttribute("Detail", info.Detail),
         new XAttribute("Objective", info.Objective),
         new XAttribute("NeedMinLevel", info.NeedMinLevel),
         new XAttribute("NeedMaxLevel", info.NeedMaxLevel),
         new XAttribute("PreQuestID", info.PreQuestID),
         new XAttribute("NextQuestID", info.NextQuestID),
         new XAttribute("IsOther", info.IsOther),
         new XAttribute("CanRepeat", info.CanRepeat),
         new XAttribute("RepeatInterval", info.RepeatInterval),
         new XAttribute("RepeatMax", info.RepeatMax),
         new XAttribute("RewardGP", info.RewardGP),
         new XAttribute("RewardGold", info.RewardGold),
         new XAttribute("RewardBindMoney", info.RewardBindMoney),//RewardGiftToken
         new XAttribute("RewardOffer", info.RewardOffer),
         new XAttribute("RewardRiches", info.RewardRiches),
         new XAttribute("RewardBuffID", info.RewardBuffID),
         new XAttribute("RewardBuffDate", info.RewardBuffDate),
         new XAttribute("RewardMoney", info.RewardMoney),
         new XAttribute("Rands", info.Rands),
         new XAttribute("RandDouble", info.RandDouble),
         new XAttribute("TimeMode", info.TimeMode),
         new XAttribute("StartDate", info.StartDate),
         new XAttribute("EndDate", info.EndDate),
     //MapID="0"
     new XAttribute("MapID", info.MapID),
     //AutoEquip="false"
     new XAttribute("AutoEquip", info.AutoEquip),
     //RewardMedal="0"
     new XAttribute("OneKeyFinishNeedMoney", info.OneKeyFinishNeedMoney),
     //Rank=""
     new XAttribute("Rank", info.Rank == null ? "" : info.Rank),
     //StarLev="0"
     new XAttribute("StarLev", info.StarLev),
     //NotMustCount="0"
     new XAttribute("NotMustCount", info.NotMustCount),
     //Level2NeedMoney="-1"
     new XAttribute("Level2NeedMoney", info.Level2NeedMoney),
     //Level3NeedMoney="-1"
     new XAttribute("Level3NeedMoney", info.Level3NeedMoney),
     //Level4NeedMoney="-1"
     new XAttribute("Level4NeedMoney", info.Level4NeedMoney),
     //Level5NeedMoney="-1">
     new XAttribute("Level5NeedMoney", info.Level5NeedMoney)
     );
 }
 /// <summary>
 /// 从任务模板表中读取数据
 /// </summary>
 /// <param name="reader">传入SqlDataReader</param>
 /// <returns>任务模板表</returns>
 public QuestInfo InitQuest(SqlDataReader reader)
 {
     QuestInfo info = new QuestInfo();
     info.ID = (int)reader["ID"];
     info.QuestID = (int)reader["QuestID"];
     info.Title = reader["Title"] == null ? "" : reader["Title"].ToString();
     info.Detail = reader["Detail"] == null ? "" : reader["Detail"].ToString();
     info.Objective = reader["Objective"] == null ? "" : reader["Objective"].ToString();
     info.NeedMinLevel = (int)reader["NeedMinLevel"];
     info.NeedMaxLevel = (int)reader["NeedMaxLevel"];
     info.PreQuestID = reader["PreQuestID"] == null ? "" : reader["PreQuestID"].ToString();
     info.NextQuestID = reader["NextQuestID"] == null ? "" : reader["NextQuestID"].ToString();
     info.IsOther = (int)reader["IsOther"];
     info.CanRepeat = (bool)reader["CanRepeat"];
     info.RepeatInterval = (int)reader["RepeatInterval"];
     info.RepeatMax = (int)reader["RepeatMax"];
     info.RewardGP = (int)reader["RewardGP"];
     info.RewardGold = (int)reader["RewardGold"];
     info.RewardBindMoney = (int)reader["RewardBindMoney"];
     info.RewardOffer = (int)reader["RewardOffer"];
     info.RewardRiches = (int)reader["RewardRiches"];
     info.RewardBuffID = (int)reader["RewardBuffID"];
     info.RewardBuffDate = (int)reader["RewardBuffDate"];
     info.RewardMoney = (int)reader["RewardMoney"];
     info.Rands = (decimal)reader["Rands"];
     info.RandDouble = (int)reader["RandDouble"];
     info.TimeMode = (bool)reader["TimeMode"];
     info.StartDate = (DateTime)reader["StartDate"];
     info.EndDate = (DateTime)reader["EndDate"];
     return info;
 }