Beispiel #1
0
 public static BaseCondition CreateCondition(BaseQuest quest, QuestConditionInfo info, int value)
 {
     switch (info.CondictionType)
     {
         case 1:
             return new OwnGradeCondition(quest, info, value);        //1、升级/空/等级数
         case 2:
             return new ItemMountingCondition(quest, info, value);    //2、使用物品
         case 3:
             return new UsingItemCondition(quest, info, value);       //3、使用指定道具/道具ID/数量
         case 4:
             return new GameKillByRoomCondition(quest, info, value);  //4、击杀玩家若干人次/房间模式(-1不限,0撮合,1自由,2练级,3副本)/数量
         case 5:
             return new GameFightByRoomCondition(quest, info, value); //5、完成战斗(无论胜败)/房间模式/数量
         case 6:
             return new GameOverByRoomCondition(quest, info, value);  //6、战斗胜利/房间模式/数量
         case 7:
             return new GameCopyOverCondition(quest, info, value);    //7、完成副本(无论胜败)/副本ID/次数
         case 8:
             return new GameCopyPassCondition(quest, info, value);    //8、通关副本(要求胜利)/副本ID/次数
         case 9:
             return new ItemStrengthenCondition(quest, info, value);  //9、强化/装备类型/强化等级
         case 10:
             return new ShopCondition(quest, info, value);            //10、购买/货币类型/支付金额
         case 11:
             return new ItemFusionCondition(quest, info, value);      //11、熔炼成功/熔炼类型/次数
         case 12:
             return new ItemMeltCondition(quest, info, value);        //12、炼化/装备类型/炼化等级
         case 13:
             return new GameMonsterCondition(quest, info, value);     //13、击杀怪物/怪物ID/数量
         case 14:
             return new OwnPropertyCondition(quest, info, value);     //14、拥有道具(完成任务道具不消失)/道具ID/数量
         case 15:
             return new TurnPropertyCondition(quest, info, value);    //15、上缴道具(完成任务道具消失)/道具ID/数量
         case 16:
             return new DirectFinishCondition(quest, info, value);    //16、直接完成/空/1
         case 17:
             return new OwnMarryCondition(quest, info, value);        //17、结婚/空/1
         case 18:
             return new OwnConsortiaCondition(quest, info, value);    //18、公会人数/空/具体人数
         case 19:
             return new ItemComposeCondition(quest, info, value);     //19、合成/合成类型/次数
         case 20:
             return new ClientModifyCondition(quest, info, value);    //20、客户端请求
         case 21:
             return new GameMissionOverCondition(quest, info, value); //21、通关关卡/关卡ID/回合数
         case 22:
             return new GameKillByGameCondition(quest, info, value);  //22、击杀玩家若干人次/游戏模式/数量
         case 23:
             return new GameFightByGameCondition(quest, info, value); //23、完成战斗(无论胜败)/游戏模式/数量
         case 24:
             return new GameOverByGameCondition(quest, info, value);  //24、战斗胜利/游戏模式/数量
         default:
             if (log.IsErrorEnabled)
                 log.Error(string.Format("Can't find quest condition : {0}", info.CondictionType));
             return null;                    
     }
 }
Beispiel #2
0
        private bool AddQuest(BaseQuest quest)
        {
            List <BaseQuest> list;

            Monitor.Enter(list = this.m_list);
            try
            {
                if (!this.m_list.Contains(quest))
                {
                    this.m_list.Add(quest);
                }
            }
            finally
            {
                Monitor.Exit(list);
            }
            quest.Data.IsExist = true;
            quest.AddToPlayer(this.m_player);
            this.OnQuestsChanged(quest);
            return(true);
        }
Beispiel #3
0
        public void SaveToDatabase()
        {
            object @lock;

            Monitor.Enter(@lock = this.m_lock);
            try
            {
                using (PlayerBussiness pb = new PlayerBussiness())
                {
                    BaseQuest[] list = new BaseQuest[this.m_list.Count];
                    this.m_list.CopyTo(list);
                    BaseQuest[] array = list;
                    for (int i = 0; i < array.Length; i++)
                    {
                        BaseQuest q = array[i];
                        q.SaveData();
                        if (q.Data.IsDirty)
                        {
                            pb.UpdateDbQuestDataInfo(q.Data);
                        }
                    }
                    list = new BaseQuest[this.m_clearList.Count];
                    this.m_clearList.CopyTo(list);
                    array = list;
                    for (int i = 0; i < array.Length; i++)
                    {
                        BaseQuest q = array[i];
                        q.SaveData();
                        pb.UpdateDbQuestDataInfo(q.Data);
                    }
                    this.m_clearList.Clear();
                }
            }
            finally
            {
                Monitor.Exit(@lock);
            }
        }
Beispiel #4
0
 protected void OnQuestsChanged(BaseQuest quest)
 {
     if (quest != null)
     {
         if (!this.m_changedQuests.Contains(quest))
         {
             List <BaseQuest> changedQuests;
             Monitor.Enter(changedQuests = this.m_changedQuests);
             try
             {
                 this.m_changedQuests.Add(quest);
             }
             finally
             {
                 Monitor.Exit(changedQuests);
             }
         }
         if (this.m_changeCount <= 0 && this.m_changedQuests.Count > 0)
         {
             this.UpdateChangedQuests();
         }
     }
 }
Beispiel #5
0
 /// <summary>
 /// 将用户任务添加到内存,事件开始监听 
 /// </summary>
 /// <param name="quest">传入用户任务</param>
 /// <returns></returns>
 private bool AddQuest(BaseQuest quest)
 {
     lock (m_list)
     {
         m_list.Add(quest);
     }
     OnQuestsChanged(quest);
     quest.AddToPlayer(m_player);
     return true;
 }
Beispiel #6
0
 public void Update(BaseQuest quest)
 {
     OnQuestsChanged(quest);
 }
Beispiel #7
0
        /// <summary>
        /// 用户领奖
        /// </summary>
        /// <param name="quest"></param>
        /// <param name="rewardItemID"></param>
        /// <returns></returns>
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            //if (baseQuest.CanCompleted(m_player) == false)
            //    return false;

            #region 定义变量
            //提示用户
            string msg = "";
            //奖励Buff
            string RewardBuffName = string.Empty;
            int RewardBuffTime = 0;
            QuestInfo qinfo = baseQuest.Info;
            QuestDataInfo qdata = baseQuest.Data;
            #endregion

            #region 从游戏中领取奖品
            m_player.BeginAllChanges();
            try
            {
                if (baseQuest.Finish(m_player))
                {
                    RemoveQuest(baseQuest);

                    //固定奖励&选择奖励
                    List<QuestAwardInfo> awards = QuestMgr.GetQuestGoods(qinfo);
                    List<ItemInfo> mainBg = new List<ItemInfo>();
                    List<ItemInfo> propBg = new List<ItemInfo>();
                    foreach (QuestAwardInfo award in awards)
                    {
                        //获取固定奖励 或者 已经选取的可选奖励
                        if (award.IsSelect == false || award.RewardItemID == selectedItem)
                        {
                            ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(award.RewardItemID);
                            if (temp != null)
                            {
                                msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", temp.Name, award.RewardItemCount1) + " ";
                                Int32 tempCount = award.RewardItemCount1;
                                if (award.IsCount == true)
                                {
                                    tempCount = tempCount * qdata.RandDobule;
                                }

                                for (int len = 0; len < tempCount; len += temp.MaxCount)
                                {
                                    int count = len + temp.MaxCount > award.RewardItemCount1 ? award.RewardItemCount1 - len : temp.MaxCount;
                                    ItemInfo item = ItemInfo.CreateFromTemplate(temp, count, (int)ItemAddType.Quest);
                                    if (item == null)
                                        continue;
                                    item.ValidDate = award.RewardItemValid;
                                    item.IsBinds = true;
                                    item.StrengthenLevel = award.StrengthenLevel;//等级
                                    item.AttackCompose = award.AttackCompose;    //攻击加成
                                    item.DefendCompose = award.DefendCompose;    //防御加成
                                    item.AgilityCompose = award.AgilityCompose;  //敏捷加成
                                    item.LuckCompose = award.LuckCompose;        //幸运加成
                                    if (temp.BagType == eBageType.PropBag)
                                    {
                                        propBg.Add(item);
                                    }
                                    else
                                    {
                                        mainBg.Add(item);
                                    }
                                }
                            }
                        }
                    }

                    //判断背包的空位是否足够
                    if (mainBg.Count > 0 && m_player.MainBag.GetEmptyCount() < mainBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return false;
                    }
                    if (propBg.Count > 0 && m_player.PropBag.GetEmptyCount() < propBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return false;
                    }

                    //把物品放入背包
                    foreach (ItemInfo item in mainBg)
                    {
                        m_player.AddTemplate(item,eBageType.MainBag,1);
                    }
                    foreach (ItemInfo item in propBg)
                    {
                        if (item.TemplateID == 11408)//trminhpc
                        {
                            int rewardMedal = item.Count;
                            m_player.AddMedal(rewardMedal);
                            //msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Medal", rewardMedal + " ");
                        }
                        else
                        {
                            m_player.AddTemplate(item, eBageType.PropBag, 1);
                        }
                    }

                    msg = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward") + msg;

                    //发放Buff
                    if ((qinfo.RewardBuffID > 0) && (qinfo.RewardBuffDate > 0))
                    {
                        ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(qinfo.RewardBuffID);
                        if (temp != null)
                        {
                            RewardBuffTime = qinfo.RewardBuffDate * qdata.RandDobule;
                            AbstractBuffer buffer = BufferList.CreateBufferHour(temp, RewardBuffTime);
                            buffer.Start(m_player);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", temp.Name, RewardBuffTime) + " ";
                        }

                    }

                    //奖励金币
                    if (qinfo.RewardGold != 0)
                    {
                        int rewardGold = qinfo.RewardGold * qdata.RandDobule;
                        m_player.AddGold(rewardGold);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", rewardGold) + " ";
                    }
                    //奖励点卷
                    if (qinfo.RewardMoney != 0)
                    {
                        int rewardMoney = qinfo.RewardMoney * qdata.RandDobule;
                        m_player.AddMoney(qinfo.RewardMoney * qdata.RandDobule);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Quest, m_player.PlayerCharacter.ID, rewardMoney, m_player.PlayerCharacter.Money, 0, 0, 0,0, "", "", "");//添加日志
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", rewardMoney) + " ";
                    }
                    //奖励GP
                    if (qinfo.RewardGP != 0)
                    {
                        int rewardGp = qinfo.RewardGP * qdata.RandDobule;
                        m_player.AddGP(rewardGp);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", rewardGp) + " ";
                    }
                    //有公会则奖励财富
                    if ((qinfo.RewardRiches != 0) && (m_player.PlayerCharacter.ConsortiaID != 0))
                    {
                        int riches = qinfo.RewardRiches * qdata.RandDobule;
                        m_player.AddRichesOffer(riches);
                        using (ConsortiaBussiness db = new ConsortiaBussiness())
                        {
                            db.ConsortiaRichAdd(m_player.PlayerCharacter.ConsortiaID, ref riches);
                        }
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", riches) + " ";
                    }
                    //奖励功勋
                    if (qinfo.RewardOffer != 0)
                    {
                        int rewardOffer = qinfo.RewardOffer * qdata.RandDobule;
                        m_player.AddOffer(rewardOffer,false);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", rewardOffer) + " ";
                    }
                    //奖励礼劵
                    if (qinfo.RewardBindMoney != 0)
                    {
                        int rewardGiftToken = qinfo.RewardBindMoney * qdata.RandDobule;
                        m_player.AddGiftToken(rewardGiftToken);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", rewardGiftToken + " ");
                    }
                    //if (qinfo.RewardMedal != 0)//trminhpc
                    //{
                    //    int rewardMedal = qinfo.RewardMedal * qdata.RandDobule;
                    //    m_player.AddMedal(rewardMedal);
                    //    msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Medal", rewardMedal + " ");
                   // }
                    m_player.Out.SendMessage(eMessageType.Normal, msg);
                    SetQuestFinish(baseQuest.Info.ID);
                    m_player.PlayerCharacter.QuestSite =m_states;
                }
                OnQuestsChanged(baseQuest);

            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                    log.Error("Quest Finish:" + ex);
                return false;
            }
            finally
            {
                m_player.CommitAllChanges();
            }
            #endregion
            return true;
        }
Beispiel #8
0
        public static BaseCondition CreateCondition(BaseQuest quest, QuestConditionInfo info, int value)
        {
            switch (info.CondictionType)
            {
                case 1:
                    return new OwnGradeCondition(quest, info, value);        //1、升级/空/等级数
                case 2:
                    return new ItemMountingCondition(quest, info, value);    //2、使用物品
                case 3:
                    return new UsingItemCondition(quest, info, value);       //3、使用指定道具/道具ID/数量
                case 4:
                    return new GameKillByRoomCondition(quest, info, value);  //4、击杀玩家若干人次/房间模式(-1不限,0撮合,1自由,2练级,3副本)/数量
                case 5:
                    return new GameFightByRoomCondition(quest, info, value); //5、完成战斗(无论胜败)/房间模式/数量
                case 6:
                    return new GameOverByRoomCondition(quest, info, value);  //6、战斗胜利/房间模式/数量
                case 7:
                    return new GameCopyOverCondition(quest, info, value);    //7、完成副本(无论胜败)/副本ID/次数
                case 8:
                    return new GameCopyPassCondition(quest, info, value);    //8、通关副本(要求胜利)/副本ID/次数
                case 9:
                    return new ItemStrengthenCondition(quest, info, value);  //9、强化/装备类型/强化等级
                case 10:
                    return new ShopCondition(quest, info, value);            //10、购买/货币类型/支付金额
                case 11:
                    return new ItemFusionCondition(quest, info, value);      //11、熔炼成功/熔炼类型/次数
                case 12:
                    return new ItemMeltCondition(quest, info, value);        //12、炼化/装备类型/炼化等级
                case 13:
                    return new GameMonsterCondition(quest, info, value);     //13、击杀怪物/怪物ID/数量
                case 14:
                    return new OwnPropertyCondition(quest, info, value);     //14、拥有道具(完成任务道具不消失)/道具ID/数量
                case 15:
                    return new TurnPropertyCondition(quest, info, value);    //15、上缴道具(完成任务道具消失)/道具ID/数量
                case 16:
                    return new DirectFinishCondition(quest, info, value);    //16、直接完成/空/1
                case 17:
                    return new OwnMarryCondition(quest, info, value);        //17、结婚/空/1
                case 18:
                    return new OwnConsortiaCondition(quest, info, value);    //18、公会人数/空/具体人数
                case 19:
                    return new ItemComposeCondition(quest, info, value);     //19、合成/合成类型/次数
                case 20:
                    return new ClientModifyCondition(quest, info, value);    //20、客户端请求
                case 21:
                    return new GameMissionOverCondition(quest, info, value); //21、通关关卡/关卡ID/回合数
                case 22:
                    return new GameKillByGameCondition(quest, info, value);  //22、击杀玩家若干人次/游戏模式/数量
                case 23:
                    return new GameFightByGameCondition(quest, info, value); //23、完成战斗(无论胜败)/游戏模式/数量
                case 24:
                    return new GameOverByGameCondition(quest, info, value);  //24、战斗胜利/游戏模式/数量
                case 25:
                    return new ItemInsertCondition(quest, info, value); //25、Khảm nạm châu báu
                case 26://hoan thanh vo chong
                case 27://enter spa
                case 28://vo chong chien thang
                case 30://Hoàn thành 5 thành tựu

                case 31://Chiến thắng 1 trận
                case 32://Chia sẻ 3 lần trạng thái cá nhân
                case 34://Tham gia 2 trận chiến đấu 2v2

                case 35://Quest sư đồ

                case 36://Quest chiến đấu sư đồ
                case 37://Cùng sư phụ hoàn thành trận Sư đồ chiến
                case 38://Quest nạp thẻ
                case 39://Trang bị mới
                case 42://Điền số điện thoại và mã kiểm chứng
                case 43://Quest Hoàn thành đăng nhập

                case 44://Thiết lập mật mã cấp 2 để hoàn thành nhiệm vụ
                case 45://Chiến đấu cùng thú cưng
                case 46://Hợp thành 1 thức ăn thú cưng
                case 47://Đến Nông Trại bạn bè trộm rau
                case 48://Nhận nuôi 1 thú cưng
                case 49://Thu hoạch Lúa Mì
                case 50://Thăng cấp thú cưng lên cấp 5
                case 51://Hạt giống thức ăn thú cưng
                default:
                    if (log.IsErrorEnabled)
                        log.Warn(string.Format("Can't find quest condition : {0}", info.CondictionType));
                    return null;
            }
        }
 public GameOverByRoomCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
Beispiel #10
0
 public void Update(BaseQuest quest)
 {
     OnQuestsChanged(quest);
 }
        /// <summary>
        /// 发送当前用户的任务数据
        /// </summary>
        /// <param name="player"></param>
        /// <param name="infos"></param>
        /// <returns></returns>
        public GSPacketIn SendUpdateQuests(GamePlayer player, byte[] states, BaseQuest[] infos)
        {
            //TODO:完成任务列表的同步
            if (m_gameClient.Player == null)
                return null;


            try
            {
                var length = 0;
                var numSend = infos.Length;
                var j = 0;
                do
                {
                    GSPacketIn pkg = new GSPacketIn((byte)ePackageType.QUEST_UPDATE, m_gameClient.Player.PlayerCharacter.ID);
                    length = (numSend > 7) ? 7 : numSend;
                    pkg.WriteInt(length);
                    for (int i = 0; i < length; i++, j++)
                    {
                        var info = infos[j];
                        if (info.Data.IsExist)
                        {
                            pkg.WriteInt(info.Data.QuestID);           //任务编号
                            pkg.WriteBoolean(info.Data.IsComplete);    //是否完成
                            pkg.WriteInt(info.Data.Condition1);        //用户条件一
                            pkg.WriteInt(info.Data.Condition2);        //用户条件二
                            pkg.WriteInt(info.Data.Condition3);        //用户条件三
                            pkg.WriteInt(info.Data.Condition4);        //用户条件四
                            pkg.WriteDateTime(info.Data.CompletedDate);//用户条件完成日期
                            pkg.WriteInt(info.Data.RepeatFinish);      //该任务剩余接受次数。
                            pkg.WriteInt(info.Data.RandDobule);        //用户接受任务机会
                            pkg.WriteBoolean(info.Data.IsExist);         //是否为新任务
                        }
                    }
                    //输出所有的任务
                    for (int i = 0; i < states.Length; i++)
                    {
                        pkg.WriteByte(states[i]);
                    }
                    numSend -= length;
                    SendTCP(pkg);
                } while (j < infos.Length);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException);
            }

            return new GSPacketIn((byte)ePackageType.QUEST_UPDATE, m_gameClient.Player.PlayerCharacter.ID);
        }
 /// <summary>
 ///  16、直接完成/空/1
 ///  触发条件:由客户端发出该任务。
 /// </summary>
 /// <param name="info"></param>
 /// <param name="value"></param>
 public DirectFinishCondition(BaseQuest quest,QuestConditionInfo info, int value) : base(quest,info, value) { }
 public OwnGradeCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value) { }
 public ClientModifyCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value) { }
 public ItemMountingCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest,info, value) { }
 /// <summary>
 ///  16、直接完成/空/1
 ///  触发条件:由客户端发出该任务。
 /// </summary>
 /// <param name="info"></param>
 /// <param name="value"></param>
 public ClickOpenCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
 public ItemStrengthenCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
 public GameCopyPassCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public OwnGradeCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 /// <summary>
 /// 构造完成一场战斗条件<justin>
 /// </summary>
 /// <param name="info"></param>
 /// <param name="value"></param>
 public FinishGameCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest,info, value) { }
Beispiel #21
0
 public GameFightApprenticeshipCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public GameFightByGameCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #23
0
 public FriendFarmCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public GameFightCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
Beispiel #25
0
 public AccuontInfoCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #26
0
 public BaseCondition(BaseQuest quest,QuestConditionInfo info, int value)
 {
     m_quest = quest;
     m_info = info;
     m_value = value;
 }
Beispiel #27
0
 public OwnConsortiaCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #28
0
        public bool AddQuest(QuestInfo info, out string msg)
        {
            msg = "";
            try
            {
                if (info == null)
                {
                    msg = "Game.Server.Quests.NoQuest";
                    bool result = false;
                    return(result);
                }
                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 (this.m_player.PlayerCharacter.Grade < info.NeedMinLevel)
                {
                    msg = "Game.Server.Quests.LevelLow";
                }
                if (this.m_player.PlayerCharacter.Grade > info.NeedMaxLevel)
                {
                    msg = "Game.Server.Quests.LevelTop";
                }
                if (info.PreQuestID != "0,")
                {
                    string[] array = info.PreQuestID.Split(new char[]
                    {
                        ','
                    });
                    for (int i = 0; i < array.Length - 1; i++)
                    {
                        if (!this.IsQuestFinish(Convert.ToInt32(array[i])))
                        {
                            msg = "Game.Server.Quests.NoFinish";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QuestInventory.log.Info(ex.InnerException);
            }
            if (info.IsOther == 1 && !this.m_player.PlayerCharacter.IsConsortia)
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            if (info.IsOther == 2 && !this.m_player.PlayerCharacter.IsMarried)
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            BaseQuest baseQuest = this.FindQuest(info.ID);

            if (baseQuest != null && baseQuest.Data.IsComplete)
            {
                msg = "Game.Server.Quests.Have";
            }
            if (baseQuest != null && !baseQuest.Info.CanRepeat)
            {
                msg = "Game.Server.Quests.NoRepeat";
            }
            if (baseQuest != null && DateTime.Now.CompareTo(baseQuest.Data.CompletedDate.Date.AddDays((double)baseQuest.Info.RepeatInterval)) < 0 && baseQuest.Data.RepeatFinish < 1)
            {
                msg = "Game.Server.Quests.Rest";
            }
            BaseQuest baseQuest2 = this.m_player.QuestInventory.FindQuest(info.ID);

            if (baseQuest2 != null)
            {
                msg = "Game.Server.Quests.Have";
            }
            if (msg == "")
            {
                QuestMgr.GetQuestCondiction(info);
                int rand = 1;
                if (ThreadSafeRandom.NextStatic(1000000) <= info.Rands)
                {
                    rand = info.RandDouble;
                }
                this.BeginChanges();
                if (baseQuest == null)
                {
                    baseQuest = new BaseQuest(info, new QuestDataInfo());
                    this.AddQuest(baseQuest);
                    baseQuest.Reset(this.m_player, rand);
                }
                else
                {
                    baseQuest.Reset(this.m_player, rand);
                    baseQuest.AddToPlayer(this.m_player);
                    this.OnQuestsChanged(baseQuest);
                }
                this.CommitChanges();
                this.SaveToDatabase();
                return(true);
            }
            msg = LanguageMgr.GetTranslation(msg, new object[0]);
            return(false);
        }
 public ItemComposeCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
Beispiel #30
0
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            string        text     = "";
            string        arg_0B_0 = string.Empty;
            QuestInfo     info     = baseQuest.Info;
            QuestDataInfo data     = baseQuest.Data;

            this.m_player.BeginAllChanges();
            try
            {
                if (baseQuest.Finish(this.m_player))
                {
                    this.RemoveQuest(baseQuest);
                    List <QuestAwardInfo> questGoods = QuestMgr.GetQuestGoods(info);
                    List <ItemInfo>       list       = new List <ItemInfo>();
                    List <ItemInfo>       list2      = new List <ItemInfo>();
                    List <ItemInfo>       list3      = new List <ItemInfo>();
                    List <ItemInfo>       list4      = new List <ItemInfo>();
                    foreach (QuestAwardInfo current in questGoods)
                    {
                        if (!current.IsSelect || current.RewardItemID == selectedItem)
                        {
                            ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(current.RewardItemID);
                            if (itemTemplateInfo != null)
                            {
                                text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", new object[]
                                {
                                    itemTemplateInfo.Name,
                                    current.RewardItemCount1
                                }) + " ";
                                int num = current.RewardItemCount1;
                                if (current.IsCount)
                                {
                                    num *= data.RandDobule;
                                }
                                for (int i = 0; i < num; i += itemTemplateInfo.MaxCount)
                                {
                                    int      count    = (i + itemTemplateInfo.MaxCount > current.RewardItemCount1) ? (current.RewardItemCount1 - i) : itemTemplateInfo.MaxCount;
                                    ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, 106);
                                    if (itemInfo != null)
                                    {
                                        itemInfo.ValidDate       = current.RewardItemValid;
                                        itemInfo.IsBinds         = true;
                                        itemInfo.StrengthenLevel = current.StrengthenLevel;
                                        itemInfo.AttackCompose   = current.AttackCompose;
                                        itemInfo.DefendCompose   = current.DefendCompose;
                                        itemInfo.AgilityCompose  = current.AgilityCompose;
                                        itemInfo.LuckCompose     = current.LuckCompose;
                                        if (itemTemplateInfo.BagType == eBageType.PropBag)
                                        {
                                            list2.Add(itemInfo);
                                        }
                                        else
                                        {
                                            if (itemTemplateInfo.BagType == eBageType.Farm)
                                            {
                                                list3.Add(itemInfo);
                                            }
                                            else
                                            {
                                                list.Add(itemInfo);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (list.Count > 0 && this.m_player.MainBag.GetEmptyCount() < list.Count)
                    {
                        baseQuest.CancelFinish(this.m_player);
                        this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                        bool result = false;
                        return(result);
                    }
                    if (list2.Count > 0 && this.m_player.PropBag.GetEmptyCount() < list2.Count)
                    {
                        baseQuest.CancelFinish(this.m_player);
                        this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                        bool result = false;
                        return(result);
                    }
                    foreach (ItemInfo current2 in list)
                    {
                        if (!this.m_player.MainBag.StackItemToAnother(current2) && !this.m_player.MainBag.AddItem(current2))
                        {
                            list4.Add(current2);
                        }
                    }
                    foreach (ItemInfo current3 in list2)
                    {
                        if (current3.Template.CategoryID != 10)
                        {
                            if (!this.m_player.PropBag.StackItemToAnother(current3) && !this.m_player.PropBag.AddItem(current3))
                            {
                                list4.Add(current3);
                            }
                        }
                        else
                        {
                            int templateID = current3.TemplateID;
                            switch (templateID)
                            {
                            case 10001:
                                this.m_player.PlayerCharacter.openFunction(Step.PICK_TWO_TWENTY);
                                break;

                            case 10002:
                                break;

                            case 10003:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_WIN);
                                break;

                            case 10004:
                                this.m_player.PlayerCharacter.openFunction(Step.FIFTY_OPEN);
                                this.m_player.AddGift(eGiftType.NEWBIE);
                                break;

                            case 10005:
                                this.m_player.PlayerCharacter.openFunction(Step.FORTY_OPEN);
                                break;

                            case 10006:
                                this.m_player.PlayerCharacter.openFunction(Step.THIRTY_OPEN);
                                break;

                            case 10007:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_TWO_TWENTY);
                                break;

                            case 10008:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_TIP_ONE);
                                break;

                            default:
                                switch (templateID)
                                {
                                case 10024:
                                    this.m_player.PlayerCharacter.openFunction(Step.PICK_ONE);
                                    break;

                                case 10025:
                                    this.m_player.PlayerCharacter.openFunction(Step.POP_EXPLAIN_ONE);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    foreach (ItemInfo current4 in list3)
                    {
                        if (!this.m_player.FarmBag.StackItemToAnother(current4) && !this.m_player.FarmBag.AddItem(current4))
                        {
                            list4.Add(current4);
                        }
                    }
                    if (list4.Count > 0)
                    {
                        this.m_player.SendItemsToMail(list4, "Bagfull trả về thư!", "Phần thưởng nhiệm vụ!", eMailType.ItemOverdue);
                        this.m_player.Out.SendMailResponse(this.m_player.PlayerCharacter.ID, eMailRespose.Receiver);
                    }
                    text = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward", new object[0]) + text;
                    if (info.RewardBuffID > 0 && info.RewardBuffDate > 0)
                    {
                        ItemTemplateInfo itemTemplateInfo2 = ItemMgr.FindItemTemplate(info.RewardBuffID);
                        if (itemTemplateInfo2 != null)
                        {
                            int            num2           = info.RewardBuffDate * data.RandDobule;
                            AbstractBuffer abstractBuffer = BufferList.CreateBufferHour(itemTemplateInfo2, num2);
                            abstractBuffer.Start(this.m_player);
                            text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", new object[]
                            {
                                itemTemplateInfo2.Name,
                                num2
                            }) + " ";
                        }
                    }
                    if (info.RewardGold != 0)
                    {
                        int num3 = info.RewardGold * data.RandDobule;
                        this.m_player.AddGold(num3);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", new object[]
                        {
                            num3
                        }) + " ";
                    }
                    if (info.RewardMoney != 0)
                    {
                        int num4 = info.RewardMoney * data.RandDobule;
                        this.m_player.AddMoney(info.RewardMoney * data.RandDobule);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Quest, this.m_player.PlayerCharacter.ID, num4, this.m_player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", new object[]
                        {
                            num4
                        }) + " ";
                    }
                    if (info.RewardGP != 0)
                    {
                        int num5 = info.RewardGP * data.RandDobule;
                        this.m_player.AddGP(num5);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", new object[]
                        {
                            num5
                        }) + " ";
                    }
                    if (info.RewardRiches != 0 && this.m_player.PlayerCharacter.ConsortiaID != 0)
                    {
                        int num6 = info.RewardRiches * data.RandDobule;
                        this.m_player.AddRichesOffer(num6);
                        using (ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness())
                        {
                            consortiaBussiness.ConsortiaRichAdd(this.m_player.PlayerCharacter.ConsortiaID, ref num6);
                        }
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", new object[]
                        {
                            num6
                        }) + " ";
                    }
                    if (info.RewardOffer != 0)
                    {
                        int num7 = info.RewardOffer * data.RandDobule;
                        this.m_player.AddOffer(num7, false);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", new object[]
                        {
                            num7
                        }) + " ";
                    }
                    if (info.RewardBindMoney != 0)
                    {
                        int num8 = info.RewardBindMoney * data.RandDobule;
                        this.m_player.AddGiftToken(num8);
                        text += LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", new object[]
                        {
                            num8 + " "
                        });
                    }
                    this.m_player.Out.SendMessage(eMessageType.Normal, text);
                    this.SetQuestFinish(baseQuest.Info.ID);
                    this.m_player.PlayerCharacter.QuestSite = this.m_states;
                }
                this.OnQuestsChanged(baseQuest);
            }
            catch (Exception arg)
            {
                if (QuestInventory.log.IsErrorEnabled)
                {
                    QuestInventory.log.Error("Quest Finish:" + arg);
                }
                bool result = false;
                return(result);
            }
            finally
            {
                this.m_player.CommitAllChanges();
            }
            return(true);
        }
Beispiel #31
0
        /// <summary>
        /// 移除一条任务
        /// </summary>
        /// <param name="quest">传入用户任务</param>
        /// <returns></returns>
        public bool RemoveQuest(BaseQuest quest)
        {
            if (quest.Info.CanRepeat == false)
            {
                bool result = false;
                lock (m_list)
                {
                    if (m_list.Remove(quest))
                    {
                        m_clearList.Add(quest);
                        result = true;
                    }
                }
                if (result)
                {
                    quest.RemoveFromPlayer(m_player);
                    OnQuestsChanged(quest);
                }
                return result;
            }
            else
            {
                //quest.Data.IsComplete = true;

                quest.Reset(m_player,2);
                quest.Data.RepeatFinish++;
                quest.SaveData();
                OnQuestsChanged(quest);
                return true;
            }
        }
 public TurnPropertyCondition(BaseQuest quest, QuestConditionInfo info, int value)
     : base(quest, info, value)
 {
     m_quest = quest;
 }
Beispiel #33
0
 /// <summary>
 /// 单条执行:添加到临时列表;并通知更新客户端数据
 /// </summary>
 /// <param name="quest"></param>
 protected void OnQuestsChanged(BaseQuest quest)
 {
     if (m_changedQuests.Contains(quest) == false)
         m_changedQuests.Add(quest);
     if (m_changeCount <= 0 && m_changedQuests.Count > 0)
     {
         UpdateChangedQuests();
     }
 }
Beispiel #34
0
 public ItemComposeCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #35
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 #36
0
 public FightWifeHusbandCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public OwnConsortiaCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest,info, value) { }
Beispiel #38
0
 public BaseCondition(BaseQuest quest, QuestConditionInfo info, int value)
 {
     m_quest = quest;
     m_info  = info;
     m_value = value;
 }
 public FightWithPetCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #40
0
        public static BaseCondition CreateCondition(BaseQuest quest, QuestConditionInfo info, int value)
        {
            switch (info.CondictionType)
            {
            case 1:
                return(new OwnGradeCondition(quest, info, value));           //1、升级/空/等级数

            case 2:
                return(new ItemMountingCondition(quest, info, value));       //2、使用物品

            case 3:
                return(new UsingItemCondition(quest, info, value));          //3、使用指定道具/道具ID/数量

            case 4:
                return(new GameKillByRoomCondition(quest, info, value));     //4、击杀玩家若干人次/房间模式(-1不限,0撮合,1自由,2练级,3副本)/数量

            case 5:
                return(new GameFightByRoomCondition(quest, info, value));    //5、完成战斗(无论胜败)/房间模式/数量

            case 6:
                return(new GameOverByRoomCondition(quest, info, value));     //6、战斗胜利/房间模式/数量

            case 7:
                return(new GameCopyOverCondition(quest, info, value));       //7、完成副本(无论胜败)/副本ID/次数

            case 8:
                return(new GameCopyPassCondition(quest, info, value));       //8、通关副本(要求胜利)/副本ID/次数

            case 9:
                return(new ItemStrengthenCondition(quest, info, value));     //9、强化/装备类型/强化等级

            case 10:
                return(new ShopCondition(quest, info, value));               //10、购买/货币类型/支付金额

            case 11:
                return(new ItemFusionCondition(quest, info, value));         //11、熔炼成功/熔炼类型/次数

            case 12:
                return(new ItemMeltCondition(quest, info, value));           //12、炼化/装备类型/炼化等级

            case 13:
                return(new GameMonsterCondition(quest, info, value));        //13、击杀怪物/怪物ID/数量

            case 14:
                return(new OwnPropertyCondition(quest, info, value));        //14、拥有道具(完成任务道具不消失)/道具ID/数量

            case 15:
                return(new TurnPropertyCondition(quest, info, value));       //15、上缴道具(完成任务道具消失)/道具ID/数量

            case 16:
                return(new DirectFinishCondition(quest, info, value));       //16、直接完成/空/1

            case 17:
                return(new OwnMarryCondition(quest, info, value));           //17、结婚/空/1

            case 18:
                return(new OwnConsortiaCondition(quest, info, value));       //18、公会人数/空/具体人数

            case 19:
                return(new ItemComposeCondition(quest, info, value));        //19、合成/合成类型/次数

            case 20:
                return(new ClientModifyCondition(quest, info, value));       //20、客户端请求

            case 21:
                return(new GameMissionOverCondition(quest, info, value));    //21、通关关卡/关卡ID/回合数

            case 22:
                return(new GameKillByGameCondition(quest, info, value));     //22、击杀玩家若干人次/游戏模式/数量

            case 23:
                return(new GameFightByGameCondition(quest, info, value));    //23、完成战斗(无论胜败)/游戏模式/数量

            case 24:
                return(new GameOverByGameCondition(quest, info, value));     //24、战斗胜利/游戏模式/数量

            default:
                if (log.IsErrorEnabled)
                {
                    log.Error(string.Format("Can't find quest condition : {0}", info.CondictionType));
                }
                return(null);
            }
        }
 public ItemStrengthenCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #42
0
 public ClientModifyCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #43
0
        /// <summary>
        /// 判断当前用户是否可以接受当前任务,如果可以则添加到内存
        /// </summary>
        /// <param name="info">系统任务</param>
        /// <returns></returns>
        public bool AddQuest(QuestInfo info, out string msg)
        {
            //TrieuLSL
            //if (info == null) return false;

            ////if (info.ID == 15)
            //{

            //}
            #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
        }
 public UsingItemCondition(BaseQuest quest,QuestConditionInfo info, int value)
     : base(quest,info, value)
 {
 }
Beispiel #45
0
        /// <summary>
        /// 用户领奖
        /// </summary>
        /// <param name="quest"></param>
        /// <param name="rewardItemID"></param>
        /// <returns></returns>
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            //if (baseQuest.CanCompleted(m_player) == false)
            //    return false;

            #region 定义变量
            //提示用户
            string msg = "";
            //奖励Buff
            string        RewardBuffName = string.Empty;
            int           RewardBuffTime = 0;
            QuestInfo     qinfo          = baseQuest.Info;
            QuestDataInfo qdata          = baseQuest.Data;
            #endregion

            #region 从游戏中领取奖品
            m_player.BeginAllChanges();
            try
            {
                if (baseQuest.Finish(m_player))
                {
                    RemoveQuest(baseQuest);

                    //固定奖励&选择奖励
                    List <QuestAwardInfo> awards = QuestMgr.GetQuestGoods(qinfo);
                    List <ItemInfo>       mainBg = new List <ItemInfo>();
                    List <ItemInfo>       propBg = new List <ItemInfo>();
                    foreach (QuestAwardInfo award in awards)
                    {
                        //获取固定奖励 或者 已经选取的可选奖励
                        if (award.IsSelect == false || award.RewardItemID == selectedItem)
                        {
                            ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(award.RewardItemID);
                            if (temp != null)
                            {
                                msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", temp.Name, award.RewardItemCount) + " ";
                                Int32 tempCount = award.RewardItemCount;
                                if (award.IsCount == true)
                                {
                                    tempCount = tempCount * qdata.RandDobule;
                                }

                                for (int len = 0; len < tempCount; len += temp.MaxCount)
                                {
                                    int      count = len + temp.MaxCount > award.RewardItemCount ? award.RewardItemCount - len : temp.MaxCount;
                                    ItemInfo item  = ItemInfo.CreateFromTemplate(temp, count, (int)ItemAddType.Quest);
                                    if (item == null)
                                    {
                                        continue;
                                    }
                                    item.ValidDate       = award.RewardItemValid;
                                    item.IsBinds         = true;
                                    item.StrengthenLevel = award.StrengthenLevel; //等级
                                    item.AttackCompose   = award.AttackCompose;   //攻击加成
                                    item.DefendCompose   = award.DefendCompose;   //防御加成
                                    item.AgilityCompose  = award.AgilityCompose;  //敏捷加成
                                    item.LuckCompose     = award.LuckCompose;     //幸运加成
                                    if (temp.BagType == eBageType.PropBag)
                                    {
                                        propBg.Add(item);
                                    }
                                    else
                                    {
                                        mainBg.Add(item);
                                    }
                                }
                            }
                        }
                    }

                    //判断背包的空位是否足够
                    if (mainBg.Count > 0 && m_player.MainBag.GetEmptyCount() < mainBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return(false);
                    }
                    if (propBg.Count > 0 && m_player.PropBag.GetEmptyCount() < propBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return(false);
                    }

                    //把物品放入背包
                    foreach (ItemInfo item in mainBg)
                    {
                        m_player.AddTemplate(item, eBageType.MainBag, 1);
                    }
                    foreach (ItemInfo item in propBg)
                    {
                        m_player.AddTemplate(item, eBageType.PropBag, 1);
                    }

                    msg = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward") + msg;

                    //发放Buff
                    if ((qinfo.RewardBuffID > 0) && (qinfo.RewardBuffDate > 0))
                    {
                        ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(qinfo.RewardBuffID);
                        if (temp != null)
                        {
                            RewardBuffTime = qinfo.RewardBuffDate * qdata.RandDobule;
                            AbstractBuffer buffer = BufferList.CreateBufferHour(temp, RewardBuffTime);
                            buffer.Start(m_player);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", temp.Name, RewardBuffTime) + " ";
                        }
                    }

                    //奖励金币
                    if (qinfo.RewardGold != 0)
                    {
                        int rewardGold = qinfo.RewardGold * qdata.RandDobule;
                        m_player.AddGold(rewardGold);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", rewardGold) + " ";
                    }
                    //奖励点卷
                    if (qinfo.RewardMoney != 0)
                    {
                        int rewardMoney = qinfo.RewardMoney * qdata.RandDobule;
                        m_player.AddMoney(qinfo.RewardMoney * qdata.RandDobule);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Quest, m_player.PlayerCharacter.ID, rewardMoney, m_player.PlayerCharacter.Money, 0, 0, 0, "", "", "");//添加日志
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", rewardMoney) + " ";
                    }
                    //奖励GP
                    if (qinfo.RewardGP != 0)
                    {
                        int rewardGp = qinfo.RewardGP * qdata.RandDobule;
                        m_player.AddGP(rewardGp);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", rewardGp) + " ";
                    }
                    //有公会则奖励财富
                    if ((qinfo.RewardRiches != 0) && (m_player.PlayerCharacter.ConsortiaID != 0))
                    {
                        int riches = qinfo.RewardRiches * qdata.RandDobule;
                        m_player.AddRichesOffer(riches);
                        using (ConsortiaBussiness db = new ConsortiaBussiness())
                        {
                            db.ConsortiaRichAdd(m_player.PlayerCharacter.ConsortiaID, ref riches);
                        }
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", riches) + " ";
                    }
                    //奖励功勋
                    if (qinfo.RewardOffer != 0)
                    {
                        int rewardOffer = qinfo.RewardOffer * qdata.RandDobule;
                        m_player.AddOffer(rewardOffer, false);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", rewardOffer) + " ";
                    }
                    //奖励礼劵
                    if (qinfo.RewardGiftToken != 0)
                    {
                        int rewardGiftToken = qinfo.RewardGiftToken * qdata.RandDobule;
                        m_player.AddGiftToken(rewardGiftToken);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", rewardGiftToken + " ");
                    }
                    m_player.Out.SendMessage(eMessageType.Normal, msg);
                    SetQuestFinish(baseQuest.Info.ID);
                    m_player.PlayerCharacter.QuestSite = m_states;
                }
                OnQuestsChanged(baseQuest);
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Quest Finish:" + ex);
                }
                return(false);
            }
            finally
            {
                m_player.CommitAllChanges();
            }
            #endregion
            return(true);
        }
Beispiel #46
0
 /// <summary>
 ///  16、直接完成/空/1
 ///  触发条件:由客户端发出该任务。
 /// </summary>
 /// <param name="info"></param>
 /// <param name="value"></param>
 public DirectFinishCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public FinishGameCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public SendGiftForFriendCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public GameMonsterCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #50
0
 public ShopCondition(BaseQuest quest,QuestConditionInfo info, int value) : base(quest,info, value) { }
 public ItemPropertyCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public GameCopyPassCondition(BaseQuest quest,QuestConditionInfo info ,int value):base(quest,info,value){}
 public ItemPropertyCondition(BaseQuest quest,QuestConditionInfo info, int value) : base(quest,info, value) { }
 public  ItemFusionCondition(BaseQuest quest,QuestConditionInfo info, int value) : base(quest,info, value) { }
 public ShopCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
Beispiel #56
0
 public GameOverByRoomCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }
 public GameMissionOverCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value) { }
Beispiel #58
0
 public EnterSpaCondition(BaseQuest quest, QuestConditionInfo info, int value) : base(quest, info, value)
 {
 }