Пример #1
0
        public static int ReqStartCaiJi(GameClient client, int monsterId, out int GatherTime)
        {
            GatherTime = 0;
            CaiJiLogic.CancelCaiJiState(client);
            int result;

            if (TimeUtil.NOW() < client.ClientData.CurrentMagicActionEndTicks)
            {
                result = -43;
            }
            else if (client.ClientData.CurrentLifeV <= 0)
            {
                CaiJiLogic.CancelCaiJiState(client);
                result = -3;
            }
            else
            {
                Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);
                if (null == monster)
                {
                    result = -1;
                }
                else if (monster.MonsterType != 1601)
                {
                    result = -4;
                }
                else if (monster.IsCollected)
                {
                    result = -4;
                }
                else
                {
                    SceneUIClasses          sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
                    GetCaiJiTimeEventObject eventObj  = new GetCaiJiTimeEventObject(client, monster);
                    bool handled = GlobalEventSource4Scene.getInstance().fireEvent(eventObj, (int)sceneType);
                    if (handled)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = eventObj.GatherTime;
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.HuanYingSiYuan)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = HuanYingSiYuanManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.YongZheZhanChang)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = YongZheZhanChangManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.KingOfBattle)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = KingOfBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.Comp)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = CompManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.KarenEast)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = KarenBattleManager_MapEast.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.LingDiCaiJi)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400.0)
                        {
                            return(-301);
                        }
                        GatherTime = LingDiCaiJiManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.EscapeBattle)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400.0)
                        {
                            return(-301);
                        }
                        GatherTime = EscapeBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400.0)
                        {
                            return(-301);
                        }
                        SystemXmlItem CaiJiMonsterXmlItem = null;
                        if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
                        {
                            return(-4);
                        }
                        GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime", -1);
                        if (client.ClientData.DailyCrystalCollectNum >= CaiJiLogic.DailyNum)
                        {
                            return(-5);
                        }
                    }
                    Global.EndMeditate(client);
                    CaiJiLogic.SetCaiJiState(client, monsterId, 0L, monster.UniqueID);
                    result = 0;
                }
            }
            return(result);
        }
Пример #2
0
        public static int ReqFinishCaiJi(GameClient client, int monsterId)
        {
            int result;

            if (monsterId != client.ClientData.CaijTargetId || client.ClientData.CaiJiStartTick == 0U || client.ClientData.CaijTargetId == 0)
            {
                CaiJiLogic.CancelCaiJiState(client);
                result = -3;
            }
            else if (client.ClientData.CurrentLifeV <= 0)
            {
                CaiJiLogic.CancelCaiJiState(client);
                result = -3;
            }
            else
            {
                Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);
                if (null == monster)
                {
                    CaiJiLogic.CancelCaiJiState(client);
                    result = -1;
                }
                else if (monster.UniqueID != client.ClientData.CaiJiTargetUniqueID)
                {
                    CaiJiLogic.CancelCaiJiState(client);
                    result = -1;
                }
                else if (monster.MonsterType != 1601)
                {
                    CaiJiLogic.CancelCaiJiState(client);
                    result = -4;
                }
                else
                {
                    SystemXmlItem           CaiJiMonsterXmlItem = null;
                    SceneUIClasses          sceneType           = Global.GetMapSceneType(client.ClientData.MapCode);
                    GetCaiJiTimeEventObject eventObj            = new GetCaiJiTimeEventObject(client, monster);
                    bool handled = GlobalEventSource4Scene.getInstance().fireEvent(eventObj, (int)sceneType);
                    int  GatherTime;
                    if (handled)
                    {
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600.0)
                        {
                            return(-301);
                        }
                        GatherTime = eventObj.GatherTime;
                        if (GatherTime < 0)
                        {
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.HuanYingSiYuan)
                    {
                        GatherTime = HuanYingSiYuanManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else if (sceneType == SceneUIClasses.YongZheZhanChang)
                    {
                        GatherTime = YongZheZhanChangManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else if (sceneType == SceneUIClasses.KingOfBattle)
                    {
                        GatherTime = KingOfBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else if (sceneType == SceneUIClasses.Comp)
                    {
                        GatherTime = CompManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else if (sceneType == SceneUIClasses.KarenEast)
                    {
                        GatherTime = KarenBattleManager_MapEast.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else if (sceneType == SceneUIClasses.LingDiCaiJi)
                    {
                        GatherTime = LingDiCaiJiManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            CaiJiLogic.CancelCaiJiState(client);
                            return(GatherTime);
                        }
                    }
                    else if (sceneType == SceneUIClasses.EscapeBattle)
                    {
                        GatherTime = EscapeBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                        if (GatherTime < 0)
                        {
                            return(-4);
                        }
                    }
                    else
                    {
                        if (sceneType == SceneUIClasses.ShuiJingHuanJing)
                        {
                            if (client.ClientData.DailyCrystalCollectNum >= CaiJiLogic.DailyNum)
                            {
                                CaiJiLogic.CancelCaiJiState(client);
                                return(-6);
                            }
                        }
                        if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
                        {
                            CaiJiLogic.CancelCaiJiState(client);
                            return(-4);
                        }
                        GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime", -1);
                    }
                    GatherTime = GatherTime * CaiJiLogic.GatherTimePer / 100;
                    uint intervalmsec = TimeUtil.timeGetTime() - client.ClientData.CaiJiStartTick;
                    if ((ulong)intervalmsec < (ulong)((long)(GatherTime * 1000)))
                    {
                        CaiJiLogic.CancelCaiJiState(client);
                        LogManager.WriteLog(LogTypes.Error, string.Format("采集读条时间不足intervalmsec={0}", intervalmsec), null, true);
                        result = -5;
                    }
                    else
                    {
                        CaiJiLogic.CancelCaiJiState(client);
                        if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400.0)
                        {
                            result = -2;
                        }
                        else
                        {
                            lock (monster.CaiJiStateLock)
                            {
                                if (monster.IsCollected)
                                {
                                    return(-4);
                                }
                                monster.IsCollected = true;
                            }
                            if (!GlobalEventSource4Scene.getInstance().fireEvent(new CaiJiEventObject(client, monster), (int)sceneType))
                            {
                                if (sceneType == SceneUIClasses.HuanYingSiYuan)
                                {
                                    HuanYingSiYuanManager.getInstance().OnCaiJiFinish(client, monster);
                                }
                                else if (sceneType == SceneUIClasses.LingDiCaiJi)
                                {
                                    LingDiCaiJiManager.getInstance().OnCaiJiFinish(client, monster);
                                }
                                else
                                {
                                    CaiJiLogic.UpdateCaiJiData(client);
                                    CaiJiLogic.NotifyCollectLastNum(client, 0, CaiJiLogic.DailyNum - client.ClientData.DailyCrystalCollectNum);
                                    float AwardRate  = 1f;
                                    int   rangeIndex = CaiJiLogic.JugeDateTimeInTimeRange(TimeUtil.NowDateTime(), CaiJiLogic.dateTimeRangeArray, true);
                                    if (rangeIndex >= 0)
                                    {
                                        AwardRate = CaiJiLogic.dateTimeRangeArray[rangeIndex].DoubleAwardRate;
                                    }
                                    int ExpAward         = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("ExpAward", -1));
                                    int XingHunAward     = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("XingHunAward", -1));
                                    int BindZuanShiAward = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("BindZuanShiAward", -1));
                                    int BindJinBiAward   = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("BindJinBiAward", -1));
                                    int MoJingAward      = (int)(AwardRate * (float)CaiJiMonsterXmlItem.GetIntValue("MoJingAward", -1));
                                    if (ExpAward > 0)
                                    {
                                        GameManager.ClientMgr.ProcessRoleExperience(client, (long)ExpAward, true, true, false, "none");
                                    }
                                    if (XingHunAward > 0)
                                    {
                                        GameManager.ClientMgr.ModifyStarSoulValue(client, XingHunAward, "采集获得星魂", true, true);
                                    }
                                    if (BindZuanShiAward > 0)
                                    {
                                        GameManager.ClientMgr.AddUserGold(client, BindZuanShiAward, "采集获得绑钻");
                                    }
                                    if (BindJinBiAward > 0)
                                    {
                                        GameManager.ClientMgr.AddMoney1(client, BindJinBiAward, "采集获得绑金", true);
                                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(28, new object[0]), new object[]
                                        {
                                            BindJinBiAward
                                        }), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, 0);
                                    }
                                    if (MoJingAward > 0)
                                    {
                                        GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, MoJingAward, "采集获得魔晶", true, true, false);
                                    }
                                    ProcessTask.ProcessAddTaskVal(client, TaskTypes.CaiJi_ShuiJingHuanJing, -1, 1, new object[0]);
                                }
                            }
                            GameManager.MonsterMgr.DeadMonsterImmediately(monster);
                            ProcessTask.Process(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, monster.RoleID, monster.MonsterInfo.ExtensionID, -1, TaskTypes.CaiJiGoods, null, 0, -1L, null);
                            result = 0;
                        }
                    }
                }
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 请求开始采集
        /// </summary>
        public static int ReqStartCaiJi(GameClient client, int monsterId, out int GatherTime)
        {
            GatherTime = 0;

            CaiJiLogic.CancelCaiJiState(client);

            //判断玩家当前状态能否采集
            //死亡时不能采集
            if (client.ClientData.CurrentLifeV <= 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //判断采集物是否存在
            Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);

            if (null == monster)    //找不到采集物
            {
                return(-1);
            }

            //判断是不是采集物
            if (monster.MonsterType != (int)MonsterTypes.CaiJi)    //不是采集物
            {
                return(-4);
            }

            SystemXmlItem CaiJiMonsterXmlItem = null;

            if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
            {
                return(-4);  //传来的monsterID不对
            }

            GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime");

            //判断玩家与采集物的距离
            if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400)     //判断距离
            {
                return(-2);
            }

            if (monster.IsCollected)
            {
                return(-4);  //已经被采集过了
            }

            //刷新活动中与采集相关的信息
            if (client.ClientData.DailyCrystalCollectNum >= DailyNum)
            {
                return(-5);  //已经达到次数上限
            }

            //结束冥想
            Global.EndMeditate(client);

            //设置玩家的采集状态
            SetCaiJiState(client, monsterId);

            return(0);   //采集开始
        }
Пример #4
0
        /// <summary>
        /// 请求完成采集
        /// </summary>
        public static int ReqFinishCaiJi(GameClient client, int monsterId)
        {
            //判断玩家当前状态能否采集
            if (monsterId != client.ClientData.CaijTargetId || client.ClientData.CaiJiStartTick == 0 || client.ClientData.CaijTargetId == 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //死亡时不能采集
            if (client.ClientData.CurrentLifeV <= 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //刷新活动中与采集相关的信息
            if (client.ClientData.DailyCrystalCollectNum >= DailyNum)
            {
                CaiJiLogic.CancelCaiJiState(client);
                return(-6);  //已经达到次数上限
            }

            //判断采集物是否存在
            Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);

            if (null == monster)    //找不到采集物
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-1);
            }

            //判断是不是采集物
            if (monster.MonsterType != (int)MonsterTypes.CaiJi)    //不是采集物
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-4);
            }

            SystemXmlItem CaiJiMonsterXmlItem = null;

            if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-4);  //传来的monsterID不对
            }

            //读条时间
            long GatherTime = (long)CaiJiMonsterXmlItem.GetIntValue("GatherTime");

            //读条时间不对不能采集
            if (DateTime.Now.Ticks - client.ClientData.CaiJiStartTick < GatherTime * 1000 * 10000)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-5);
            }

            CaiJiLogic.CancelCaiJiState(client);

            //判断玩家与采集物的距离
            if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400) //判断距离
            {
                return(-2);                                                              //太远了
            }

            lock (monster.CaiJiStateLock)
            {
                if (monster.IsCollected)
                {
                    return(-4);  //已经被别人采了
                }
                else
                {
                    monster.IsCollected = true;
                }
            }

            //增加采集次数
            UpdateCaiJiData(client);
            //通知客户端采集次数
            NotifyCollectLastNum(client, 0, DailyNum - client.ClientData.DailyCrystalCollectNum);

            //清除采集物
            GameManager.MonsterMgr.DeadMonsterImmediately(monster);

            //给予采集奖励
            float AwardRate = 1.0f;
            //判断是否有双倍
            int endMinute = 0;

            if (Global.JugeDateTimeInTimeRange(DateTime.Now, dateTimeRangeArray, out endMinute))
            {
                AwardRate = DoubleAwardRate;
            }

            int ExpAward         = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("ExpAward"));
            int XingHunAward     = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("XingHunAward"));
            int BindZuanShiAward = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("BindZuanShiAward"));
            int BindJinBiAward   = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("BindJinBiAward"));
            int MoJingAward      = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("MoJingAward"));

            if (ExpAward > 0)
            {
                //处理角色经验
                GameManager.ClientMgr.ProcessRoleExperience(client, ExpAward, true, true);
            }

            if (XingHunAward > 0)
            {
                GameManager.ClientMgr.ModifyStarSoulValue(client, XingHunAward, "采集获得星魂", true, true);
            }

            if (BindZuanShiAward > 0)
            {
                GameManager.ClientMgr.AddUserGold(client, BindZuanShiAward, "采集获得绑钻");
            }

            if (BindJinBiAward > 0)
            {
                GameManager.ClientMgr.AddMoney1(client, BindJinBiAward, "采集获得绑金", true);
            }

            if (MoJingAward > 0)
            {
                GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, MoJingAward, "采集获得魔晶", true);
            }

            /*
             * Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, caiJiRoleID);
             * if (null != monster && monster.MonsterType == (int)MonsterTypes.CaiJi)
             * {
             *  //首先判断背包是否已经满了,如果是则提示用户采集失败
             *  if (monster.MonsterInfo.FallGoodsPackID <= 0)
             *  {
             *      if (!Global.CanAddGoodsNum(client, 1))
             *      {
             *          GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
             *              client, StringUtil.substitute(Global.GetLang("背包已满,无法将进行采集")),
             *              GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox);
             *      }
             *  }
             *
             *  //杀死怪物并处理任务
             *  Global.SystemKillMonster(client, monster);
             * }
             */

            return(0);   //采集完成
        }
Пример #5
0
        /// <summary>
        /// 请求完成采集
        /// </summary>
        public static int ReqFinishCaiJi(GameClient client, int monsterId)
        {
            //判断玩家当前状态能否采集
            if (monsterId != client.ClientData.CaijTargetId || client.ClientData.CaiJiStartTick == 0 || client.ClientData.CaijTargetId == 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //死亡时不能采集
            if (client.ClientData.CurrentLifeV <= 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //判断采集物是否存在
            Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);

            if (null == monster)    //找不到采集物
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-1);
            }

            //判断是不是采集物
            if (monster.MonsterType != (int)MonsterTypes.CaiJi)    //不是采集物
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-4);
            }

            SystemXmlItem CaiJiMonsterXmlItem = null;
            int           GatherTime          = int.MaxValue;

            //采集条件判断
            SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);

            if (sceneType == SceneUIClasses.HuanYingSiYuan)
            {
                //幻影寺院采集圣杯
                GatherTime = HuanYingSiYuanManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(-4);
                }
            }
            else if (sceneType == SceneUIClasses.YongZheZhanChang)
            {
                // 勇者战场 水晶
                GatherTime = YongZheZhanChangManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(-4);
                }
            }
            else if (sceneType == SceneUIClasses.KingOfBattle)
            {
                // 王者战场 水晶
                GatherTime = KingOfBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(-4);
                }
            }
            else
            {
                //水晶环境采集水晶
                if (client.ClientData.DailyCrystalCollectNum >= DailyNum)
                {
                    CaiJiLogic.CancelCaiJiState(client);
                    return(-6);  //已经达到次数上限
                }
                //====Monsters===
                //if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
                //{
                //    //取消采集状态
                //    CaiJiLogic.CancelCaiJiState(client);
                //    return -4;  //传来的monsterID不对
                //}

                //读条时间
                GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime");
                // 针对服务器时间漂移问题,对结束采集的读条时间进行缩短处理
                GatherTime = GatherTime * GatherTimePer / 100;
            }

            //读条时间不对不能采集
            uint intervalmsec = TimeUtil.timeGetTime() - client.ClientData.CaiJiStartTick;

            if (intervalmsec < GatherTime * 1000)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                LogManager.WriteLog(LogTypes.Error, string.Format("采集读条时间不足intervalmsec={0}", intervalmsec));
                return(-5);
            }

            CaiJiLogic.CancelCaiJiState(client);

            //判断玩家与采集物的距离
            if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400) //判断距离
            {
                return(-2);                                                              //太远了
            }

            lock (monster.CaiJiStateLock)
            {
                if (monster.IsCollected)
                {
                    return(-4);  //已经被别人采了
                }
                else
                {
                    monster.IsCollected = true;
                }
            }

            //采集完成
            bool handled = GlobalEventSource4Scene.getInstance().fireEvent(new CaiJiEventObject(client, monster), (int)sceneType);

            if (!handled)
            {
                if (sceneType == SceneUIClasses.HuanYingSiYuan)
                {
                    //幻影寺院采集圣杯
                    HuanYingSiYuanManager.getInstance().OnCaiJiFinish(client, monster);
                }
                else
                {
                    //水晶环境采集水晶
                    //增加采集次数
                    UpdateCaiJiData(client);

                    //通知客户端采集次数
                    NotifyCollectLastNum(client, 0, DailyNum - client.ClientData.DailyCrystalCollectNum);

                    //给予采集奖励
                    float AwardRate = 1.0f;

                    //判断是否有双倍
                    int rangeIndex = JugeDateTimeInTimeRange(TimeUtil.NowDateTime(), dateTimeRangeArray);
                    if (rangeIndex >= 0)
                    {
                        AwardRate = dateTimeRangeArray[rangeIndex].DoubleAwardRate;
                    }

                    int ExpAward         = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("ExpAward"));
                    int XingHunAward     = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("XingHunAward"));
                    int BindZuanShiAward = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("BindZuanShiAward"));
                    int BindJinBiAward   = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("BindJinBiAward"));
                    int MoJingAward      = (int)(AwardRate * CaiJiMonsterXmlItem.GetIntValue("MoJingAward"));

                    if (ExpAward > 0)
                    {
                        //处理角色经验
                        GameManager.ClientMgr.ProcessRoleExperience(client, ExpAward, true, true);
                    }

                    if (XingHunAward > 0)
                    {
                        GameManager.ClientMgr.ModifyStarSoulValue(client, XingHunAward, "采集获得星魂", true, true);
                    }

                    if (BindZuanShiAward > 0)
                    {
                        GameManager.ClientMgr.AddUserGold(client, BindZuanShiAward, "采集获得绑钻");
                    }

                    if (BindJinBiAward > 0)
                    {
                        GameManager.ClientMgr.AddMoney1(client, BindJinBiAward, "采集获得绑金", true);
                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                                 StringUtil.substitute(Global.GetLang("获得绑定金币 +{0}"), BindJinBiAward),
                                                                 GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, (int)HintErrCodeTypes.None);
                    }

                    if (MoJingAward > 0)
                    {
                        GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, MoJingAward, "采集获得魔晶", true);
                    }

                    /*
                     * Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, caiJiRoleID);
                     * if (null != monster && monster.MonsterType == (int)MonsterTypes.CaiJi)
                     * {
                     *  //首先判断背包是否已经满了,如果是则提示用户采集失败
                     *  if (monster.MonsterInfo.FallGoodsPackID <= 0)
                     *  {
                     *      if (!Global.CanAddGoodsNum(client, 1))
                     *      {
                     *          GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool,
                     *              client, StringUtil.substitute(Global.GetLang("背包已满,无法将进行采集")),
                     *              GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox);
                     *      }
                     *  }
                     *
                     *  //杀死怪物并处理任务
                     *  Global.SystemKillMonster(client, monster);
                     * }
                     */
                }
            }

            //清除采集物
            GameManager.MonsterMgr.DeadMonsterImmediately(monster);

            return(0);   //采集完成
        }
Пример #6
0
        /// <summary>
        /// 请求开始采集
        /// </summary>
        public static int ReqStartCaiJi(GameClient client, int monsterId, out int GatherTime)
        {
            GatherTime = 0;

            CaiJiLogic.CancelCaiJiState(client);

            //判断玩家当前状态能否采集
            //死亡时不能采集
            if (client.ClientData.CurrentLifeV <= 0)
            {
                //取消采集状态
                CaiJiLogic.CancelCaiJiState(client);
                return(-3);
            }

            //判断采集物是否存在
            Monster monster = GameManager.MonsterMgr.FindMonster(client.ClientData.MapCode, monsterId);

            if (null == monster)    //找不到采集物
            {
                return(-1);
            }

            //判断是不是采集物
            if (monster.MonsterType != (int)MonsterTypes.CaiJi)    //不是采集物
            {
                return(-4);
            }

            if (monster.IsCollected)
            {
                return(-4);  //已经被采集过了
            }

            SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);

            if (sceneType == SceneUIClasses.HuanYingSiYuan)
            {
                //判断玩家与采集物的距离
                if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600)     //判断距离
                {
                    return(StdErrorCode.Error_Too_Far);
                }

                //幻影寺院采集圣杯
                GatherTime = HuanYingSiYuanManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(GatherTime);
                }
            }
            else if (sceneType == SceneUIClasses.YongZheZhanChang)
            {
                if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600)
                {
                    return(StdErrorCode.Error_Too_Far);
                }

                GatherTime = YongZheZhanChangManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(GatherTime);
                }
            }
            else if (sceneType == SceneUIClasses.KingOfBattle)
            {
                if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 600)
                {
                    return(StdErrorCode.Error_Too_Far);
                }

                GatherTime = KingOfBattleManager.getInstance().GetCaiJiMonsterTime(client, monster);
                if (GatherTime < 0)
                {
                    return(GatherTime);
                }
            }
            else
            {
                //判断玩家与采集物的距离
                if (Global.GetTwoPointDistance(client.CurrentPos, monster.CurrentPos) > 400)     //判断距离
                {
                    return(StdErrorCode.Error_Too_Far);
                }

                //水晶环境采集水晶
                //====Monsters===
                //SystemXmlItem CaiJiMonsterXmlItem = null;
                //if (!GameManager.systemCaiJiMonsterMgr.SystemXmlItemDict.TryGetValue(monster.MonsterInfo.ExtensionID, out CaiJiMonsterXmlItem) || null == CaiJiMonsterXmlItem)
                //{
                //    return -4;  //传来的monsterID不对
                //}

                //GatherTime = CaiJiMonsterXmlItem.GetIntValue("GatherTime");

                //刷新活动中与采集相关的信息
                if (client.ClientData.DailyCrystalCollectNum >= DailyNum)
                {
                    return(-5);  //已经达到次数上限
                }
            }

            //结束冥想
            Global.EndMeditate(client);

            //设置玩家的采集状态
            SetCaiJiState(client, monsterId);

            return(0);   //采集开始
        }