Exemple #1
0
        /// <summary>
        /// A*寻路移动
        /// useLinearFinder 使用直线寻路,对于夺宝奇兵类型的怪物,使用直线寻路,寻找近的点
        /// </summary>
        private bool AStarMove(Monster sprite, Point p, int action)
        {
            //首先置空路径
            //sprite.PathString = "";

            Point srcPoint = sprite.Coordinate;

            //*****************************************
            //srcPoint = new Point(710, 3450);
            //p = new Point(619, 2191);
            //****************************************

            //进行单元格缩小
            Point start = new Point()
            {
                X = srcPoint.X / 20,
                Y = srcPoint.Y / 20
            },
                  end = new Point()
            {
                X = p.X / 20,
                Y = p.Y / 20
            };

            //如果起止一样,就不移动
            if (start.X == end.X && start.Y == end.Y)
            {
                return(true);
            }

            GameMap gameMap = GameManager.MapMgr.DictMaps[sprite.MonsterZoneNode.MapCode];

            //System.Diagnostics.Debug.WriteLine(
            //string.Format("开始AStar怪物寻路, ExtenstionID={0}, Start=({1},{2}), End=({3},{4}), fixedObstruction=({5},{6}), MapCode={7}",
            //            sprite.MonsterInfo.ExtensionID, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y, gameMap.MyNodeGrid.numCols, gameMap.MyNodeGrid.numRows,
            //            sprite.MonsterZoneNode.MapCode)
            //            );

            if (start != end)
            {
                List <ANode> path = null;

                gameMap.MyNodeGrid.setStartNode((int)start.X, (int)start.Y);
                gameMap.MyNodeGrid.setEndNode((int)end.X, (int)end.Y);

                try
                {
                    path = gameMap.MyAStarFinder.find(gameMap.MyNodeGrid);
                }
                catch (Exception)
                {
                    sprite.DestPoint = new Point(-1, -1);
#if ___CC___FUCK___YOU___BB___
                    LogManager.WriteLog(LogTypes.Error, string.Format("AStar怪物寻路失败, ExtenstionID={0}, Start=({1},{2}), End=({3},{4}), fixedObstruction=({5},{6})",
                                                                      sprite.XMonsterInfo.MonsterId, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y, gameMap.MyNodeGrid.numCols, gameMap.MyNodeGrid.numRows));
#else
                    LogManager.WriteLog(LogTypes.Error, string.Format("AStar怪物寻路失败, ExtenstionID={0}, Start=({1},{2}), End=({3},{4}), fixedObstruction=({5},{6})",
                                                                      sprite.MonsterInfo.ExtensionID, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y, gameMap.MyNodeGrid.numCols, gameMap.MyNodeGrid.numRows));
#endif

                    return(false);
                }

                if (path == null || path.Count <= 1)
                {
                    // 寻找一个直线的两点间的从开始点出发的最大无障碍点
                    Point maxPoint;
                    if (FindLinearNoObsMaxPoint(gameMap, sprite, p, out maxPoint))
                    {
                        path = null;
                        end  = new Point()
                        {
                            X = maxPoint.X / gameMap.MapGridWidth,
                            Y = maxPoint.Y / gameMap.MapGridHeight,
                        };

                        p = maxPoint;

                        gameMap.MyNodeGrid.setStartNode((int)start.X, (int)start.Y);
                        gameMap.MyNodeGrid.setEndNode((int)end.X, (int)end.Y);

                        path = gameMap.MyAStarFinder.find(gameMap.MyNodeGrid);
                    }
                }

                if (path == null || path.Count <= 1)
                {
                    //路径不存在
                    //sprite.MoveToPos = new Point(-1, -1); //防止重入
                    sprite.DestPoint = new Point(-1, -1);
                    sprite.Action    = GActions.Stand; //不需要通知,统一会执行的动作
                    Global.RemoveStoryboard(sprite.Name);
                    return(false);
                }
                else
                {
                    //找到路径 设置路径
                    //sprite.PathString = Global.TransPathToString(path);

                    //System.Diagnostics.Debug.WriteLine(String.Format("monster_{0} 路径:{1} ", sprite.RoleID, sprite.PathString));
                    //System.Diagnostics.Debug.WriteLine(String.Format("start:{0}, {1}  end {2}, {3}", start.X, start.Y, end.X, end.Y));
                    //System.Diagnostics.Debug.WriteLine(String.Format("srcPoint:{0}, {1}  P {2}, {3}", srcPoint.X, srcPoint.Y, p.X, p.Y));

                    sprite.Destination = p;
                    double UnitCost = 0;
                    //if (action == (int)GActions.Walk)
                    //{
                    //    UnitCost = Data.WalkUnitCost;
                    //}
                    //else if (action == (int)GActions.Run)
                    //{
                    //    UnitCost = Data.RunUnitCost;
                    //}
                    UnitCost = Data.RunUnitCost; //怪物使用跑步的移动速度
                    UnitCost = UnitCost / sprite.MoveSpeed;

                    UnitCost = 20.0 / UnitCost * Global.MovingFrameRate;
                    UnitCost = UnitCost * 0.5;

                    StoryBoardEx.RemoveStoryBoard(sprite.Name);

                    StoryBoardEx sb = new StoryBoardEx(sprite.Name);
                    sb.Completed = Move_Completed;

                    //path.Reverse();
                    Point firstPoint = new Point(path[0].x * gameMap.MapGridWidth, path[0].y * gameMap.MapGridHeight);
                    sprite.Direction = this.CalcDirection(sprite.Coordinate, firstPoint);
                    sprite.Action    = (GActions)action;

                    sb.Binding();

                    sprite.FirstStoryMove = true;
                    sb.Start(sprite, path, UnitCost, 20);
                }
            }

            return(true);
        }
        public static void KillMonsterInFreshPlayerScene(GameClient client, Monster monster)
        {
            CopyMap copyMapInfo;

            lock (FreshPlayerCopySceneManager.m_FreshPlayerListCopyMaps)
            {
                if (!FreshPlayerCopySceneManager.m_FreshPlayerListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out copyMapInfo) || copyMapInfo == null)
                {
                    return;
                }
            }
            if (monster.MonsterInfo.VLevel >= Data.FreshPlayerSceneInfo.NeedKillMonster1Level)
            {
                copyMapInfo.FreshPlayerKillMonsterACount++;
                if (copyMapInfo.FreshPlayerKillMonsterACount >= Data.FreshPlayerSceneInfo.NeedKillMonster1Num)
                {
                    string strcmd = string.Format("{0}", client.ClientData.RoleID);
                    GameManager.ClientMgr.SendToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, strcmd, 525);
                }
            }
            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.NeedKillMonster2ID)
            {
                copyMapInfo.FreshPlayerKillMonsterBCount++;
                if (copyMapInfo.FreshPlayerKillMonsterBCount >= Data.FreshPlayerSceneInfo.NeedKillMonster2Num)
                {
                    bool     canAddMonster = false;
                    TaskData taskData      = Global.GetTaskData(client, 105);
                    if (null != taskData)
                    {
                        canAddMonster = true;
                    }
                    if (canAddMonster)
                    {
                        copyMapInfo.HaveBirthShuiJingGuan = true;
                        int      monsterID = Data.FreshPlayerSceneInfo.CrystalID;
                        string[] sfields   = Data.FreshPlayerSceneInfo.CrystalPos.Split(new char[]
                        {
                            ','
                        });
                        int     nPosX   = Global.SafeConvertToInt32(sfields[0]);
                        int     nPosY   = Global.SafeConvertToInt32(sfields[1]);
                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(copyMapInfo.MapCode, out gameMap))
                        {
                            return;
                        }
                        int gridX = gameMap.CorrectWidthPointToGridPoint(nPosX) / gameMap.MapGridWidth;
                        int gridY = gameMap.CorrectHeightPointToGridPoint(nPosY) / gameMap.MapGridHeight;
                        GameManager.MonsterZoneMgr.AddDynamicMonsters(copyMapInfo.MapCode, monsterID, copyMapInfo.CopyMapID, 1, gridX, gridY, 0, 0, SceneUIClasses.Normal, null, null);
                    }
                }
            }
            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.GateID)
            {
                FreshPlayerCopySceneManager.CreateMonsterBFreshPlayerScene(copyMapInfo);
            }
            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.CrystalID)
            {
                int      monsterID = Data.FreshPlayerSceneInfo.DiaoXiangID;
                string[] sfields   = Data.FreshPlayerSceneInfo.DiaoXiangPos.Split(new char[]
                {
                    ','
                });
                int     nPosX   = Global.SafeConvertToInt32(sfields[0]);
                int     nPosY   = Global.SafeConvertToInt32(sfields[1]);
                GameMap gameMap = null;
                if (GameManager.MapMgr.DictMaps.TryGetValue(copyMapInfo.MapCode, out gameMap))
                {
                    int gridX = gameMap.CorrectWidthPointToGridPoint(nPosX) / gameMap.MapGridWidth;
                    int gridY = gameMap.CorrectHeightPointToGridPoint(nPosY) / gameMap.MapGridHeight;
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(copyMapInfo.MapCode, monsterID, copyMapInfo.CopyMapID, 1, gridX, gridY, 0, 0, SceneUIClasses.Normal, null, null);
                }
            }
        }
        /// <summary>
        /// 加载怪物
        /// </summary>
        public void AddMapMonsters(int mapCode, GameMap gameMap)
        {
            //对于每一个地图,都要加入一个动态刷怪区域,用于动态刷怪管理
            AddDynamicMonsterZone(mapCode);

            string   fileName = string.Format("Map/{0}/Monsters.xml", mapCode);
            XElement xml      = null;

            try
            {
                xml = XElement.Load(Global.GameResPath(fileName));
            }
            catch (Exception)
            {
                throw new Exception(string.Format("加载地图怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }

            IEnumerable <XElement> monsterItems = xml.Elements("Monsters").Elements();

            if (null == monsterItems)
            {
                return;
            }

            //判断是否是副本地图
            bool isFuBenMap = FuBenManager.FindFuBenIDByMapCode(mapCode) > 0 ? true : false;

            foreach (var monsterItem in monsterItems)
            {
                String timePoints      = Global.GetSafeAttributeStr(monsterItem, "TimePoints");
                int    configBirthType = (int)Global.GetSafeAttributeLong(monsterItem, "BirthType");
                int    realBirthType   = configBirthType;

                String realTimePoints = timePoints;
                int    spawnMonstersAfterKaiFuDays = 0;
                int    spawnMonstersDays           = 0;
                List <BirthTimeForDayOfWeek> CreateMonstersDayOfWeek = new List <BirthTimeForDayOfWeek>();
                List <BirthTimePoint>        birthTimePointList      = null;

                //对于开服多少天之后才开始刷怪,进行特殊配置 格式:开服多少天;连续刷多少天[负数0表示一直];刷怪方式0或1;0或1的配置
                if ((int)MonsterBirthTypes.AfterKaiFuDays == configBirthType || (int)MonsterBirthTypes.AfterHeFuDays == configBirthType || (int)MonsterBirthTypes.AfterJieRiDays == configBirthType)
                {
                    String[] arr = timePoints.Split(';');
                    if (4 != arr.Length)
                    {
                        throw new Exception(String.Format("地图{0}的类型4的刷怪配置参数个数不对!!!!", mapCode));
                    }

                    spawnMonstersAfterKaiFuDays = int.Parse(arr[0]);
                    spawnMonstersDays           = int.Parse(arr[1]);
                    realBirthType  = int.Parse(arr[2]);
                    realTimePoints = arr[3];

                    if ((int)MonsterBirthTypes.TimePoint != realBirthType && (int)MonsterBirthTypes.TimeSpan != realBirthType)
                    {
                        throw new Exception(String.Format("地图{0}的类型4的刷怪配置子类型不对!!!!", mapCode));
                    }
                }

                // MU新增 一周中的哪天刷 TimePoints 配置形式 周几,时间点|周几,时间点|周几,时间点... [1/10/2014 LiaoWei]
                if ((int)MonsterBirthTypes.CreateDayOfWeek == configBirthType)
                {
                    String[] arrTime = timePoints.Split('|');

                    if (arrTime.Length > 0)
                    {
                        for (int nIndex = 0; nIndex < arrTime.Length; ++nIndex)
                        {
                            string sTimePoint = null;
                            sTimePoint = arrTime[nIndex];

                            if (sTimePoint != null)
                            {
                                String[] sTime = null;
                                sTime = sTimePoint.Split(',');

                                if (sTime != null && sTime.Length == 2)
                                {
                                    string sTimeString = null;
                                    int    nDayOfWeek  = -1;

                                    nDayOfWeek  = int.Parse(sTime[0]);
                                    sTimeString = sTime[1];

                                    if (nDayOfWeek != -1 && !string.IsNullOrEmpty(sTimeString))
                                    {
                                        string[] fields2 = sTimeString.Split(':');
                                        if (fields2.Length != 2)
                                        {
                                            continue;
                                        }

                                        string str1 = fields2[0].TrimStart('0');
                                        string str2 = fields2[1].TrimStart('0');

                                        BirthTimePoint birthTimePoint = new BirthTimePoint()
                                        {
                                            BirthHour   = Global.SafeConvertToInt32(str1),
                                            BirthMinute = Global.SafeConvertToInt32(str2),
                                        };

                                        BirthTimeForDayOfWeek BirthTimeTmp = new BirthTimeForDayOfWeek();

                                        BirthTimeTmp.BirthDayOfWeek = nDayOfWeek;
                                        BirthTimeTmp.BirthTime      = birthTimePoint;

                                        CreateMonstersDayOfWeek.Add(BirthTimeTmp);
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    birthTimePointList = ParseBirthTimePoints(realTimePoints);
                }

                MonsterZone monsterZone = new MonsterZone()
                {
                    MapCode                     = mapCode,
                    ID                          = (int)Global.GetSafeAttributeLong(monsterItem, "ID"),
                    Code                        = (int)Global.GetSafeAttributeLong(monsterItem, "Code"),
                    ToX                         = (int)Global.GetSafeAttributeLong(monsterItem, "X") / gameMap.MapGridWidth,
                    ToY                         = (int)Global.GetSafeAttributeLong(monsterItem, "Y") / gameMap.MapGridHeight,
                    Radius                      = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth,
                    TotalNum                    = (int)Global.GetSafeAttributeLong(monsterItem, "Num"),
                    Timeslot                    = (int)Global.GetSafeAttributeLong(monsterItem, "Timeslot"),
                    IsFuBenMap                  = isFuBenMap,
                    BirthType                   = realBirthType,
                    ConfigBirthType             = configBirthType,
                    SpawnMonstersAfterKaiFuDays = spawnMonstersAfterKaiFuDays,
                    SpawnMonstersDays           = spawnMonstersDays,
                    SpawnMonstersDayOfWeek      = CreateMonstersDayOfWeek,
                    BirthTimePointList          = birthTimePointList,
                    BirthRate                   = (int)(Global.GetSafeAttributeDouble(monsterItem, "BirthRate") * 10000),
                };

                XAttribute attrib = monsterItem.Attribute("PursuitRadius");
                if (null != attrib)
                {
                    monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "PursuitRadius");
                }
                else
                {
                    monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius");
                }

                //加入列表
                MonsterZoneList.Add(monsterZone);

                //如果是副本地图, 则加入副本爆怪区域列表
                if (isFuBenMap)
                {
                    FuBenMonsterZoneList.Add(monsterZone);
                }

                //加入爆怪区域
                AddMap2MonsterZoneDict(monsterZone);

                //加载静态的怪物信息
                monsterZone.LoadStaticMonsterInfo();

                //加载怪物
                monsterZone.LoadMonsters();//暂时屏蔽怪物加载
            }
        }
Exemple #4
0
        private bool StepMove(long elapsedTicks)
        {
            //防止外部结束后,这里还在递归处理
            StoryBoard4Client sb = FindStoryBoard(_RoleID);

            if (null == sb)
            {
                return(false);
            }

            lock (mutex)
            {
                //已到最后一个目的地,则停下
                _PathIndex = Math.Min(_PathIndex, _Path.Count - 1);

                //探测下一个格子
                if (!DetectNextGrid())
                {
                    return(true);
                }

                double targetX   = _Path[_PathIndex].X * _CellSizeX + _CellSizeX / 2.0; //根据节点列号求得屏幕坐标
                double targetY   = _Path[_PathIndex].Y * _CellSizeY + _CellSizeY / 2.0; //根据节点行号求得屏幕坐标
                int    direction = (int)(GetDirectionByTan(targetX, targetY, _LastTargetX, _LastTargetY));

                double dx = targetX - _LastTargetX;
                double dy = targetY - _LastTargetY;
                double thisGridStepDist = Math.Sqrt(dx * dx + dy * dy);
                //trace("_PathIndex=" + _PathIndex + ", " + "thisGridStepDist=" + thisGridStepDist);

                bool needWalking = false;// _LastNeedWalking;
                //if (_PathIndex > _ActionIndex)
                //{
                //    int currentGridX = (int)(_LastTargetX / _CellSizeX);
                //    int currentGridY = (int)(_LastTargetY / _CellSizeY);
                //    needWalking = NeedWalking(currentGridX, currentGridY);
                //    _LastNeedWalking = needWalking;
                //}

                if (_Path.Count <= 1)
                {
                    needWalking = true;
                }

                int action = needWalking ? (int)GActions.Walk : (int)GActions.Run;

                long thisGridNeedTicks = GetNeedTicks(needWalking, direction);
                long thisToNeedTicks   = Math.Min(thisGridNeedTicks - _LastUsedTicks, elapsedTicks);
                _LastUsedTicks += thisToNeedTicks;

                //trace(thisToNeedTicks);

                double movePercent  = (double)(thisToNeedTicks) / (double)(thisGridNeedTicks);
                var    realMoveDist = thisGridStepDist * movePercent;
                //trace("_PathIndex=" + _PathIndex + ", " + "movePercent=" + movePercent + ", realMoveDist=" + realMoveDist);

                var angle  = Math.Atan2(dy, dx);
                var speedX = realMoveDist * Math.Cos(angle);
                var speedY = realMoveDist * Math.Sin(angle);

                //trace("_PathIndex=" + _PathIndex + ", " + "speedX=" + speedX + ", speedY=" + speedY);

                _CurrentX = _CurrentX + speedX;
                _CurrentY = _CurrentY + speedY;

                if (thisToNeedTicks >= elapsedTicks)
                {
                    //trace("_PathIndex=" + _PathIndex + ", " + "old_cx=" + _MovingObj.cx + ", old_cy=" + _MovingObj.cy);

                    GameClient client = GameManager.ClientMgr.FindClient(_RoleID);
                    if (null != client)
                    {
                        client.ClientData.CurrentAction = action;

                        //求当前格子到目标格子的方向
                        if ((int)targetX != (int)_CurrentX || (int)targetY != (int)_CurrentY)
                        {
                            if (direction != client.ClientData.RoleDirection)
                            {
                                client.ClientData.RoleDirection = direction;
                            }
                            //Debug.WriteLine("_MovingObj.Direction=" + _MovingObj.Direction + ", targetX=" + targetX + ", targetY=" + targetY + ", _MovingObj.cx=" +  _MovingObj.cx + ",  _MovingObj.cy=" + _MovingObj.cy);
                        }

                        GameMap gameMap  = GameManager.MapMgr.DictMaps[client.ClientData.MapCode];
                        int     oldGridX = client.ClientData.PosX / gameMap.MapGridWidth;
                        int     oldGridY = client.ClientData.PosY / gameMap.MapGridHeight;

                        client.ClientData.PosX = (int)_CurrentX;
                        client.ClientData.PosY = (int)_CurrentY;
                        //_MovingObj.Z = int(_MovingObj.Y); //此处应该非常消耗CPU
                        //trace("_PathIndex=" + _PathIndex + ", " + "now_cx=" + _MovingObj.cx + ", now_cy=" + _MovingObj.cy);
                        //System.Diagnostics.Debug.WriteLine(string.Format("StepMove, toX={0}, toY={1}", client.ClientData.PosX, client.ClientData.PosY));

                        int newGridX = client.ClientData.PosX / gameMap.MapGridWidth;
                        int newGridY = client.ClientData.PosY / gameMap.MapGridHeight;

                        if (oldGridX != newGridX || oldGridY != newGridY)
                        {
                            MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[client.ClientData.MapCode];
                            mapGrid.MoveObjectEx(oldGridX, oldGridY, newGridX, newGridY, client);

                            /// 玩家进行了移动
                            //Global.GameClientMoveGrid(client);
                        }
                    }
                }
                else //到达当前目的地
                {
                    //trace("_PathIndex=" + _PathIndex + ", " + "targetX=" + targetX + ", targetY=" + targetY + ", cx=" + _MovingObj.cx + ", cy=" + _MovingObj.cy );
                    //trace("_PathIndex=" + _PathIndex + ", " + "_LastUsedTicks=" + _LastUsedTicks + ", " + "_LastLostNumberX=" + _LastLostNumberX + ", _LastLostNumberY=" + _LastLostNumberY + ", _TotalMovePercent=" + _TotalMovePercent);
                    //trace("_LastTargetX=" + _LastTargetX + ", " + "_LastTargetY=" + _LastTargetY + ", TargetX=" + targetX + ", " + "targetY=" + targetY + ", cx=" + _MovingObj.cx + ", cy=" + _MovingObj.cy );
                    //trace(_TotalTicksSlot);
                    _PathIndex++;

                    //已到最后一个目的地,则停下
                    if (_PathIndex >= _Path.Count)
                    {
                        GameClient client = GameManager.ClientMgr.FindClient(_RoleID);
                        if (null != client)
                        {
                            client.ClientData.PosX = (int)targetX;
                            client.ClientData.PosY = (int)targetY;
                        }
                        return(true);
                    }

                    _LastTargetX   = (int)targetX;
                    _LastTargetY   = (int)targetY;
                    _LastUsedTicks = 0;
                    //_TotalTicksSlot = "";

                    elapsedTicks = elapsedTicks - thisToNeedTicks; //减去此次移动的距离
                    StepMove(elapsedTicks);
                }

                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        // 刷怪接口
        /// </summary>
        static public void DaimonSquareSceneCreateMonster(DaimonSquareScene bcTmp, DaimonSquareDataInfo bcDataTmp)
        {
            if (bcTmp.m_nMonsterWave >= bcTmp.m_nMonsterTotalWave)
            {
                return;
            }

            // 置刷怪标记
            bcTmp.m_nCreateMonsterFlag = 1;

            string sMonsterNum       = null;
            string sMonsterID        = null;
            string sNeedSkillMonster = null;

            sMonsterNum       = bcDataTmp.MonsterNum[bcTmp.m_nMonsterWave];
            sMonsterID        = bcDataTmp.MonsterID[bcTmp.m_nMonsterWave];
            sNeedSkillMonster = bcDataTmp.CreateNextWaveMonsterCondition[bcTmp.m_nMonsterWave];

            if (sMonsterID == null || sMonsterNum == null || sNeedSkillMonster == null)
            {
                return;
            }

            string[] sNum  = null;
            string[] sID   = null;
            string[] sRate = null;

            sNum  = sMonsterNum.Split(',');
            sID   = sMonsterID.Split(',');
            sRate = sNeedSkillMonster.Split(',');

            if (sNum.Length != sID.Length)
            {
                return;
            }

            GameMap gameMap = null;

            if (!GameManager.MapMgr.DictMaps.TryGetValue(bcDataTmp.MapCode, out gameMap))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("恶魔广场报错 地图配置 ID = {0}", bcDataTmp.MapCode));
                return;
            }

            int gridX = gameMap.CorrectWidthPointToGridPoint(bcDataTmp.posX) / gameMap.MapGridWidth;
            int gridY = gameMap.CorrectHeightPointToGridPoint(bcDataTmp.posZ) / gameMap.MapGridHeight;

            int gridNum = gameMap.CorrectWidthPointToGridPoint(bcDataTmp.Radius);

            for (int i = 0; i < sNum.Length; ++i)
            {
                int nNum = Global.SafeConvertToInt32(sNum[i]);
                int nID  = Global.SafeConvertToInt32(sID[i]);
                //System.Console.WriteLine("liaowei是帅哥  恶魔广场 i = {0}",i);
                for (int j = 0; j < nNum; ++j)
                {
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(bcTmp.m_nMapCode, nID, -1, 1, gridX, gridY, gridNum);

                    //System.Console.WriteLine("liaowei是帅哥  恶魔广场 j = {0}", j);

                    ++bcTmp.m_nCreateMonsterCount;
                }
            }

            // 计数要杀死怪的数量
            bcTmp.m_nNeedKillMonsterNum = bcTmp.m_nCreateMonsterCount * Global.SafeConvertToInt32(sRate[0]) / 100;

            // 递增刷怪波数
            ++bcTmp.m_nMonsterWave;

            //System.Console.WriteLine("liaowei是帅哥  恶魔广场第{0}波 {1}只!!!", bcTmp.m_nMonsterWave, bcTmp.m_nCreateMonsterCount);

            // 恶魔广场怪物波和人物得分信息
            GameManager.ClientMgr.NotifyDaimonSquareMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, bcDataTmp.MapCode, (int)TCPGameServerCmds.CMD_SPR_QUERYDAIMONSQUAREMONSTERWAVEANDPOINTRINFO,
                                                        0, 0, bcDataTmp.MonsterID.Length - bcTmp.m_nMonsterWave, -100, 0);  // 只更新波数

            //System.Console.WriteLine("liaowei是帅哥  恶魔广场{0}里 刷第{1}波怪了 一共{3}只!!!", bcTmp.m_nMapCode, bcTmp.m_nMonsterWave, bcTmp.m_nCreateMonsterCount);

            return;
        }
Exemple #6
0
        public void AddMapMonsters(int mapCode, GameMap gameMap)
        {
            this.AddDynamicMonsterZone(mapCode);
            string   fileName = string.Format("Map/{0}/Monsters.xml", mapCode);
            XElement xml      = null;

            try
            {
                xml = XElement.Load(Global.ResPath(fileName));
            }
            catch (Exception)
            {
                throw new Exception(string.Format("加载地图怪物配置文件:{0}, 失败。没有找到相关XML配置文件!", fileName));
            }
            IEnumerable <XElement> monsterItems = xml.Elements("Monsters").Elements <XElement>();

            if (null != monsterItems)
            {
                bool isFuBenMap = FuBenManager.IsFuBenMap(mapCode);
                foreach (XElement monsterItem in monsterItems)
                {
                    string timePoints                  = Global.GetSafeAttributeStr(monsterItem, "TimePoints");
                    int    configBirthType             = (int)Global.GetSafeAttributeLong(monsterItem, "BirthType");
                    int    realBirthType               = configBirthType;
                    string realTimePoints              = timePoints;
                    int    spawnMonstersAfterKaiFuDays = 0;
                    int    spawnMonstersDays           = 0;
                    List <BirthTimeForDayOfWeek> CreateMonstersDayOfWeek = new List <BirthTimeForDayOfWeek>();
                    List <BirthTimePoint>        birthTimePointList      = null;
                    if (4 == configBirthType || 5 == configBirthType || 6 == configBirthType)
                    {
                        string[] arr = timePoints.Split(new char[]
                        {
                            ';'
                        });
                        if (4 != arr.Length)
                        {
                            throw new Exception(string.Format("地图{0}的类型4的刷怪配置参数个数不对!!!!", mapCode));
                        }
                        spawnMonstersAfterKaiFuDays = int.Parse(arr[0]);
                        spawnMonstersDays           = int.Parse(arr[1]);
                        realBirthType  = int.Parse(arr[2]);
                        realTimePoints = arr[3];
                        if (1 != realBirthType && 0 != realBirthType)
                        {
                            throw new Exception(string.Format("地图{0}的类型4的刷怪配置子类型不对!!!!", mapCode));
                        }
                    }
                    if (7 == configBirthType)
                    {
                        string[] arrTime = timePoints.Split(new char[]
                        {
                            '|'
                        });
                        if (arrTime.Length > 0)
                        {
                            int nIndex = 0;
                            while (nIndex < arrTime.Length)
                            {
                                string sTimePoint = arrTime[nIndex];
                                if (sTimePoint != null)
                                {
                                    string[] sTime = sTimePoint.Split(new char[]
                                    {
                                        ','
                                    });
                                    if (sTime != null && sTime.Length == 2)
                                    {
                                        int    nDayOfWeek  = int.Parse(sTime[0]);
                                        string sTimeString = sTime[1];
                                        if (nDayOfWeek != -1 && !string.IsNullOrEmpty(sTimeString))
                                        {
                                            string[] fields2 = sTimeString.Split(new char[]
                                            {
                                                ':'
                                            });
                                            if (fields2.Length == 2)
                                            {
                                                string str = fields2[0].TrimStart(new char[]
                                                {
                                                    '0'
                                                });
                                                string str2 = fields2[1].TrimStart(new char[]
                                                {
                                                    '0'
                                                });
                                                BirthTimePoint birthTimePoint = new BirthTimePoint
                                                {
                                                    BirthHour   = Global.SafeConvertToInt32(str),
                                                    BirthMinute = Global.SafeConvertToInt32(str2)
                                                };
                                                CreateMonstersDayOfWeek.Add(new BirthTimeForDayOfWeek
                                                {
                                                    BirthDayOfWeek = nDayOfWeek,
                                                    BirthTime      = birthTimePoint
                                                });
                                            }
                                        }
                                    }
                                }
IL_2E5:
                                nIndex++;
                                continue;
                                goto IL_2E5;
                            }
                        }
                    }
                    else
                    {
                        birthTimePointList = this.ParseBirthTimePoints(realTimePoints);
                    }
                    MonsterZone monsterZone = new MonsterZone
                    {
                        MapCode                     = mapCode,
                        ID                          = (int)Global.GetSafeAttributeLong(monsterItem, "ID"),
                        Code                        = (int)Global.GetSafeAttributeLong(monsterItem, "Code"),
                        ToX                         = (int)Global.GetSafeAttributeLong(monsterItem, "X") / gameMap.MapGridWidth,
                        ToY                         = (int)Global.GetSafeAttributeLong(monsterItem, "Y") / gameMap.MapGridHeight,
                        Radius                      = (int)Global.GetSafeAttributeLong(monsterItem, "Radius") / gameMap.MapGridWidth,
                        TotalNum                    = (int)Global.GetSafeAttributeLong(monsterItem, "Num"),
                        Timeslot                    = (int)Global.GetSafeAttributeLong(monsterItem, "Timeslot"),
                        IsFuBenMap                  = isFuBenMap,
                        BirthType                   = realBirthType,
                        ConfigBirthType             = configBirthType,
                        SpawnMonstersAfterKaiFuDays = spawnMonstersAfterKaiFuDays,
                        SpawnMonstersDays           = spawnMonstersDays,
                        SpawnMonstersDayOfWeek      = CreateMonstersDayOfWeek,
                        BirthTimePointList          = birthTimePointList,
                        BirthRate                   = (int)(Global.GetSafeAttributeDouble(monsterItem, "BirthRate") * 10000.0)
                    };
                    XAttribute attrib = monsterItem.Attribute("PursuitRadius");
                    if (null != attrib)
                    {
                        monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "PursuitRadius");
                    }
                    else
                    {
                        monsterZone.PursuitRadius = (int)Global.GetSafeAttributeLong(monsterItem, "Radius");
                    }
                    lock (this.InitMonsterZoneMutex)
                    {
                        this.MonsterZoneList.Add(monsterZone);
                        if (isFuBenMap)
                        {
                            this.FuBenMonsterZoneList.Add(monsterZone);
                        }
                        this.AddMap2MonsterZoneDict(monsterZone);
                    }
                    monsterZone.LoadStaticMonsterInfo_2();
                    monsterZone.LoadMonsters();
                }
            }
        }
Exemple #7
0
        public bool ProcessKuaFuMapEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result     = 0;
                int toMapCode  = Global.SafeConvertToInt32(cmdParams[0]);
                int line       = Global.SafeConvertToInt32(cmdParams[1]);
                int toBoss     = 0;
                int teleportId = 0;
                if (cmdParams.Length >= 3)
                {
                    toBoss = Global.SafeConvertToInt32(cmdParams[2]);
                }
                if (cmdParams.Length >= 4)
                {
                    teleportId = Global.SafeConvertToInt32(cmdParams[3]);
                }
                KuaFuLineData kuaFuLineData;
                if (!KuaFuMapManager.getInstance().IsKuaFuMap(toMapCode))
                {
                    result = -12;
                }
                else if (!this.RuntimeData.LineMap2KuaFuLineDataDict.TryGetValue(new IntPairKey(line, toMapCode), out kuaFuLineData))
                {
                    result = -12;
                }
                else if (!Global.CanEnterMap(client, toMapCode) || (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType != 1))
                {
                    result = -12;
                }
                else
                {
                    if (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType == 1)
                    {
                        List <KuaFuLineData> list = KuaFuWorldClient.getInstance().GetKuaFuLineDataList(toMapCode) as List <KuaFuLineData>;
                        if (null == list)
                        {
                            result = -12;
                            goto IL_67F;
                        }
                        KuaFuLineData currentLineData = list.Find((KuaFuLineData x) => x.ServerId == GameManager.KuaFuServerId);
                        if (currentLineData != null && currentLineData.Line == kuaFuLineData.Line)
                        {
                            result = -4011;
                            goto IL_67F;
                        }
                    }
                    if (!KuaFuMapManager.getInstance().IsKuaFuMap(client.ClientData.MapCode) && !this.CheckMap(client))
                    {
                        result = -21;
                    }
                    else if (!this.IsGongNengOpened(client, false))
                    {
                        result = -12;
                    }
                    else if (kuaFuLineData.OnlineCount >= kuaFuLineData.MaxOnlineCount)
                    {
                        result = -100;
                    }
                    else
                    {
                        int fromMapCode = client.ClientData.MapCode;
                        if (teleportId > 0)
                        {
                            GameMap fromGameMap = null;
                            if (!GameManager.MapMgr.DictMaps.TryGetValue(fromMapCode, out fromGameMap))
                            {
                                result = -3;
                                goto IL_67F;
                            }
                            MapTeleport mapTeleport = null;
                            if (!fromGameMap.MapTeleportDict.TryGetValue(teleportId, out mapTeleport) || mapTeleport.ToMapID != toMapCode)
                            {
                                result = -12;
                                goto IL_67F;
                            }
                            if (Global.GetTwoPointDistance(client.CurrentPos, new Point((double)mapTeleport.X, (double)mapTeleport.Y)) > 800.0)
                            {
                                result = -301;
                                goto IL_67F;
                            }
                        }
                        KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                        int kuaFuServerId;
                        if (kuaFuLineData.MapType == 1)
                        {
                            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Reborn, true))
                            {
                                result = -400;
                                goto IL_67F;
                            }
                            string signToken;
                            string signKey;
                            int    rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            if (rt == -4010)
                            {
                                KuaFuWorldRoleData kuaFuWorldRoleData = new KuaFuWorldRoleData
                                {
                                    LocalRoleID = client.ClientData.LocalRoleID,
                                    UserID      = client.strUserID,
                                    WorldRoleID = client.ClientData.WorldRoleID,
                                    Channel     = client.ClientData.Channel,
                                    PTID        = client.ClientData.ServerPTID,
                                    ServerID    = client.ServerId,
                                    ZoneID      = client.ClientData.ZoneID
                                };
                                rt = KuaFuWorldClient.getInstance().RegPTKuaFuRoleData(ref kuaFuWorldRoleData);
                                rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            }
                            if (rt < 0)
                            {
                                result = rt;
                                goto IL_67F;
                            }
                            KFRebornRoleData rebornRoleData = KuaFuWorldClient.getInstance().Reborn_GetRebornRoleData(client.ClientData.ServerPTID, client.ClientData.LocalRoleID);
                            if (null == rebornRoleData)
                            {
                                result = KuaFuWorldClient.getInstance().Reborn_RoleReborn(client.ClientData.ServerPTID, client.ClientData.LocalRoleID, client.ClientData.RoleName, client.ClientData.RebornLevel);
                                if (result < 0)
                                {
                                    goto IL_67F;
                                }
                                LogManager.WriteLog(LogTypes.Analysis, string.Format("Reborn_RoleReborn ptId={0} roleId={1} roleName={2} rebornLevel={3}", new object[]
                                {
                                    client.ClientData.ServerPTID,
                                    client.ClientData.LocalRoleID,
                                    client.ClientData.RoleName,
                                    client.ClientData.RebornLevel
                                }), null, true);
                            }
                            kuaFuServerLoginData.PTID       = client.ClientData.ServerPTID;
                            kuaFuServerLoginData.RoleId     = client.ClientData.LocalRoleID;
                            kuaFuServerLoginData.SignToken  = signToken;
                            kuaFuServerLoginData.TempRoleID = rt;
                            kuaFuServerLoginData.SignCode   = MD5Helper.get_md5_string(kuaFuServerLoginData.SignDataString() + signKey).ToLower();
                            kuaFuServerId = kuaFuServerLoginData.TargetServerID;
                        }
                        else
                        {
                            kuaFuServerLoginData.SignCode = null;
                            kuaFuServerId = YongZheZhanChangClient.getInstance().EnterKuaFuMap(client.ClientData.LocalRoleID, kuaFuLineData.MapCode, kuaFuLineData.Line, client.ServerId, Global.GetClientKuaFuServerLoginData(client));
                        }
                        kuaFuServerLoginData.Line = line;
                        if (kuaFuServerId > 0)
                        {
                            bool flag      = 0 == 0;
                            int  needMoney = (teleportId > 0) ? 0 : Global.GetMapTransNeedMoney(toMapCode);
                            if (Global.GetTotalBindTongQianAndTongQianVal(client) < needMoney)
                            {
                                GameManager.ClientMgr.NotifyImportantMsg(client, StringUtil.substitute(GLang.GetLang(171, new object[0]), new object[]
                                {
                                    needMoney,
                                    Global.GetMapName(toMapCode)
                                }), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 27);
                                result = -9;
                                Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            }
                            else
                            {
                                int[] enterFlags = new int[5];
                                enterFlags[0] = fromMapCode;
                                enterFlags[1] = teleportId;
                                enterFlags[2] = toBoss;
                                Global.SaveRoleParamsIntListToDB(client, new List <int>(enterFlags), "EnterKuaFuMapFlag", true);
                                GlobalNew.RecordSwitchKuaFuServerLog(client);
                                client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                            }
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            result = kuaFuServerId;
                        }
                    }
                }
IL_67F:
                client.sendCmd <int>(nID, result, false);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
            }
            return(false);
        }
Exemple #8
0
        private bool AStarMove(Monster sprite, Point p, int action)
        {
            Point srcPoint = sprite.Coordinate;
            Point start    = new Point
            {
                X = srcPoint.X / 20.0,
                Y = srcPoint.Y / 20.0
            };
            Point end = new Point
            {
                X = p.X / 20.0,
                Y = p.Y / 20.0
            };
            bool result;

            if (start.X == end.X && start.Y == end.Y)
            {
                result = true;
            }
            else
            {
                GameMap gameMap = GameManager.MapMgr.DictMaps[sprite.MonsterZoneNode.MapCode];
                if (start != end)
                {
                    List <ANode> path = null;
                    gameMap.MyNodeGrid.setStartNode((int)start.X, (int)start.Y);
                    gameMap.MyNodeGrid.setEndNode((int)end.X, (int)end.Y);
                    try
                    {
                        path = gameMap.MyAStarFinder.find(gameMap.MyNodeGrid);
                    }
                    catch (Exception)
                    {
                        sprite.DestPoint = new Point(-1.0, -1.0);
                        LogManager.WriteLog(LogTypes.Error, string.Format("AStar怪物寻路失败, ExtenstionID={0}, Start=({1},{2}), End=({3},{4}), fixedObstruction=({5},{6})", new object[]
                        {
                            sprite.MonsterInfo.ExtensionID,
                            (int)start.X,
                            (int)start.Y,
                            (int)end.X,
                            (int)end.Y,
                            gameMap.MyNodeGrid.numCols,
                            gameMap.MyNodeGrid.numRows
                        }), null, true);
                        return(false);
                    }
                    if (path == null || path.Count <= 1)
                    {
                        Point maxPoint;
                        if (this.FindLinearNoObsMaxPoint(gameMap, sprite, p, out maxPoint))
                        {
                            path = null;
                            end  = new Point
                            {
                                X = maxPoint.X / (double)gameMap.MapGridWidth,
                                Y = maxPoint.Y / (double)gameMap.MapGridHeight
                            };
                            p = maxPoint;
                            gameMap.MyNodeGrid.setStartNode((int)start.X, (int)start.Y);
                            gameMap.MyNodeGrid.setEndNode((int)end.X, (int)end.Y);
                            path = gameMap.MyAStarFinder.find(gameMap.MyNodeGrid);
                        }
                    }
                    if (path == null || path.Count <= 1)
                    {
                        sprite.DestPoint = new Point(-1.0, -1.0);
                        sprite.Action    = GActions.Stand;
                        Global.RemoveStoryboard(sprite.Name);
                        return(false);
                    }
                    sprite.Destination = p;
                    double UnitCost = (double)Data.RunUnitCost;
                    UnitCost /= sprite.MoveSpeed;
                    UnitCost  = 20.0 / UnitCost * (double)Global.MovingFrameRate;
                    UnitCost *= 0.5;
                    StoryBoardEx.RemoveStoryBoard(sprite.Name);
                    StoryBoardEx sb = new StoryBoardEx(sprite.Name);
                    sb.Completed = new StoryBoardEx.CompletedDelegateHandle(this.Move_Completed);
                    Point firstPoint = new Point((double)(path[0].x * gameMap.MapGridWidth), (double)(path[0].y * gameMap.MapGridHeight));
                    sprite.Direction = this.CalcDirection(sprite.Coordinate, firstPoint);
                    sprite.Action    = (GActions)action;
                    sb.Binding();
                    sprite.FirstStoryMove = true;
                    sb.Start(sprite, path, UnitCost, 20);
                }
                result = true;
            }
            return(result);
        }
        public void HeartBeatAngelTempleScene()
        {
            long ticks = TimeUtil.NOW();
            AngelTempleStatus newStatus;

            if (this.ChangeToNextStatus(out newStatus))
            {
                switch (newStatus)
                {
                case AngelTempleStatus.FIGHT_STATUS_NULL:
                {
                    List <object> objsList = GameManager.ClientMgr.GetMapClients(this.m_AngelTempleData.MapCode);
                    if (objsList != null)
                    {
                        for (int i = 0; i < objsList.Count; i++)
                        {
                            GameClient c = objsList[i] as GameClient;
                            if (c != null)
                            {
                                if (c.ClientData.MapCode == this.m_AngelTempleData.MapCode)
                                {
                                    int toMapCode = GameManager.MainMapCode;
                                    int toPosX    = -1;
                                    int toPosY    = -1;
                                    if (MapTypes.Normal == Global.GetMapType(c.ClientData.LastMapCode))
                                    {
                                        if (GameManager.BattleMgr.BattleMapCode != c.ClientData.LastMapCode || GameManager.ArenaBattleMgr.BattleMapCode != c.ClientData.LastMapCode)
                                        {
                                            toMapCode = c.ClientData.LastMapCode;
                                            toPosX    = c.ClientData.LastPosX;
                                            toPosY    = c.ClientData.LastPosY;
                                        }
                                    }
                                    GameMap gameMap = null;
                                    if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                    {
                                        c.ClientData.bIsInAngelTempleMap = false;
                                        GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, c, toMapCode, toPosX, toPosY, -1, 0);
                                    }
                                }
                            }
                        }
                    }
                    this.CleanUpAngelTempleScene();
                    if (ticks >= this.m_AngelTempleScene.m_lEndTime + (long)(this.m_AngelTempleData.LeaveTime * 20000))
                    {
                        this.m_AngelTempleScene.m_eStatus = AngelTempleStatus.FIGHT_STATUS_NULL;
                    }
                    break;
                }

                case AngelTempleStatus.FIGHT_STATUS_PREPARE:
                    Global.AddFlushIconStateForAll(1007, true);
                    break;

                case AngelTempleStatus.FIGHT_STATUS_BEGIN:
                {
                    lock (this.m_AngelTempleScene)
                    {
                        this.bBossKilled = false;
                        this.m_AngelTempleScene.m_bEndFlag = 0;
                    }
                    this.SendTimeInfoToAll(ticks);
                    int     monsterID = this.m_AngelTempleData.BossID;
                    GameMap gameMap   = null;
                    if (!GameManager.MapMgr.DictMaps.TryGetValue(this.m_AngelTempleData.MapCode, out gameMap))
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("天使神殿报错 地图配置 ID = {0}", this.m_AngelTempleData.MapCode), null, true);
                        return;
                    }
                    int gridX = gameMap.CorrectWidthPointToGridPoint(this.m_AngelTempleData.BossPosX) / gameMap.MapGridWidth;
                    int gridY = gameMap.CorrectHeightPointToGridPoint(this.m_AngelTempleData.BossPosY) / gameMap.MapGridHeight;
                    this.AngelTempleMonsterUpgradePercent = Global.SafeConvertToDouble(GameManager.GameConfigMgr.GetGameConifgItem("AngelTempleMonsterUpgradeNumber"));
                    GameManager.MonsterZoneMgr.AddDynamicMonsters(this.m_AngelTempleData.MapCode, monsterID, -1, 1, gridX, gridY, 1, 0, SceneUIClasses.Normal, null, null);
                    break;
                }

                case AngelTempleStatus.FIGHT_STATUS_END:
                    Global.AddFlushIconStateForAll(1007, false);
                    this.SendTimeInfoToAll(ticks);
                    if (!this.bBossKilled && this.m_AngelTempleBoss != null)
                    {
                        MonsterData md     = this.m_AngelTempleBoss.GetMonsterData();
                        double      damage = 0.0;
                        if (md.MaxLifeV != md.LifeV)
                        {
                            damage = Global.Clamp(md.MaxLifeV - md.LifeV, md.MaxLifeV / 10.0, md.MaxLifeV);
                            this.AngelTempleMonsterUpgradePercent *= damage * 0.8 / md.MaxLifeV;
                            Global.UpdateDBGameConfigg("AngelTempleMonsterUpgradeNumber", this.AngelTempleMonsterUpgradePercent.ToString("0.00"));
                        }
                        GameManager.MonsterMgr.AddDelayDeadMonster(this.m_AngelTempleBoss);
                        GameManager.ClientMgr.NotifyAngelTempleMsgBossDisappear(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, this.m_AngelTempleData.MapCode);
                        LogManager.WriteLog(LogTypes.SQL, string.Format("天使神殿Boss未死亡,血量减少百分比{0:P} ,Boss生命值比例成长为{1}", damage / md.MaxLifeV, this.AngelTempleMonsterUpgradePercent), null, true);
                        this.m_AngelTempleBoss = null;
                    }
                    this.GiveAwardAngelTempleScene(this.bBossKilled);
                    break;
                }
            }
            if (newStatus == AngelTempleStatus.FIGHT_STATUS_BEGIN)
            {
            }
        }
Exemple #10
0
        /// <summary>
        // 杀死了怪
        /// </summary>
        public static void KillMonsterInFreshPlayerScene(GameClient client, Monster monster)
        {
            CopyMap copyMapInfo;

            lock (m_FreshPlayerListCopyMaps)
            {
                if (!m_FreshPlayerListCopyMaps.TryGetValue(client.ClientData.FuBenSeqID, out copyMapInfo) || copyMapInfo == null)
                {
                    return;
                }
            }

            if (monster.MonsterInfo.VLevel >= Data.FreshPlayerSceneInfo.NeedKillMonster1Level)
            {
                ++copyMapInfo.FreshPlayerKillMonsterACount;

                if (copyMapInfo.FreshPlayerKillMonsterACount >= Data.FreshPlayerSceneInfo.NeedKillMonster1Num)
                {
                    // 杀死A怪的数量已经达到限额 通知客户端 面前的阻挡消失 玩家可以离开桥 攻击城门了
                    string strcmd = string.Format("{0}", client.ClientData.RoleID);
                    GameManager.ClientMgr.SendToClient(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, strcmd,
                                                       (int)TCPGameServerCmds.CMD_SPR_FRESHPLAYERSCENEKILLMONSTERAHASDONE);
                }
            }

            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.NeedKillMonster2ID)
            {
                ++copyMapInfo.FreshPlayerKillMonsterBCount;

                if (copyMapInfo.FreshPlayerKillMonsterBCount >= Data.FreshPlayerSceneInfo.NeedKillMonster2Num)
                {
                    bool     canAddMonster = false;
                    TaskData taskData      = Global.GetTaskData(client, 105);        //先写死吧,临时i解决掉
                    if (null != taskData)
                    {
                        canAddMonster = true;
                    }

                    if (canAddMonster) //是否能刷水晶棺的怪物
                    {
                        copyMapInfo.HaveBirthShuiJingGuan = true;

                        // 把水晶棺刷出来
                        int      monsterID = Data.FreshPlayerSceneInfo.CrystalID;
                        string[] sfields   = Data.FreshPlayerSceneInfo.CrystalPos.Split(',');

                        int nPosX = Global.SafeConvertToInt32(sfields[0]);
                        int nPosY = Global.SafeConvertToInt32(sfields[1]);

                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(copyMapInfo.MapCode, out gameMap))
                        {
                            return;
                        }

                        int gridX = gameMap.CorrectWidthPointToGridPoint(nPosX) / gameMap.MapGridWidth;
                        int gridY = gameMap.CorrectHeightPointToGridPoint(nPosY) / gameMap.MapGridHeight;

                        GameManager.MonsterZoneMgr.AddDynamicMonsters(copyMapInfo.MapCode, monsterID, copyMapInfo.CopyMapID, 1, gridX, gridY, 0);
                    }
                }
            }

            // 如果杀死的是城门 刷巫师
            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.GateID)
            {
                CreateMonsterBFreshPlayerScene(copyMapInfo);
            }

            // 刷雕像
            if (monster.MonsterInfo.ExtensionID == Data.FreshPlayerSceneInfo.CrystalID)
            {
                int      monsterID = Data.FreshPlayerSceneInfo.DiaoXiangID;
                string[] sfields   = Data.FreshPlayerSceneInfo.DiaoXiangPos.Split(',');

                int nPosX = Global.SafeConvertToInt32(sfields[0]);
                int nPosY = Global.SafeConvertToInt32(sfields[1]);

                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(copyMapInfo.MapCode, out gameMap))
                {
                    return;
                }

                int gridX = gameMap.CorrectWidthPointToGridPoint(nPosX) / gameMap.MapGridWidth;
                int gridY = gameMap.CorrectHeightPointToGridPoint(nPosY) / gameMap.MapGridHeight;

                GameManager.MonsterZoneMgr.AddDynamicMonsters(copyMapInfo.MapCode, monsterID, copyMapInfo.CopyMapID, 1, gridX, gridY, 0);
            }

            return;
        }
        /// <summary>
        /// 初始化配置
        /// </summary>
        public bool InitConfig()
        {
            bool     success          = true;
            XElement xml              = null;
            string   fileName         = "";
            string   fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (RuntimeData.Mutex)
            {
                try
                {
                    //圣杯配置
                    RuntimeData.ShengBeiDataDict.Clear();

                    fileName         = "Config/HolyGrail.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        ShengBeiData item = new ShengBeiData();
                        item.ID        = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MonsterID = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.Time      = (int)Global.GetSafeAttributeLong(node, "Time");
                        item.GoodsID   = (int)Global.GetSafeAttributeLong(node, "GoodsID");
                        item.Score     = (int)Global.GetSafeAttributeLong(node, "Score");
                        item.PosX      = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY      = (int)Global.GetSafeAttributeLong(node, "PosY");

                        EquipPropItem propItem = GameManager.EquipPropsMgr.FindEquipPropItem(item.GoodsID);
                        if (null != propItem)
                        {
                            item.BufferProps = propItem.ExtProps;
                        }
                        else
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, "幻影寺院的圣杯Buffer的GoodsID在物品表中找不到");
                        }

                        RuntimeData.ShengBeiDataDict[item.ID] = item;
                    }

                    //出生点配置
                    RuntimeData.MapBirthPointDict.Clear();

                    fileName         = "Config/TempleMirageRebirth.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        HuanYingSiYuanBirthPoint item = new HuanYingSiYuanBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");

                        RuntimeData.MapBirthPointDict[item.ID] = item;
                    }

                    //连杀配置
                    RuntimeData.ContinuityKillAwardDict.Clear();

                    fileName         = "Config/ContinuityKillAward.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        ContinuityKillAward item = new ContinuityKillAward();
                        item.ID    = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.Num   = (int)Global.GetSafeAttributeLong(node, "Num");
                        item.Score = (int)Global.GetSafeAttributeLong(node, "Score");

                        RuntimeData.ContinuityKillAwardDict[item.Num] = item;
                    }

                    //活动配置
                    RuntimeData.MapCode = 0;

                    fileName         = "Config/TempleMirage.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        RuntimeData.MapCode       = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        RuntimeData.MinZhuanSheng = (int)Global.GetSafeAttributeLong(node, "MinZhuanSheng");
                        RuntimeData.MinLevel      = (int)Global.GetSafeAttributeLong(node, "MinLevel");
                        RuntimeData.MinRequestNum = (int)Global.GetSafeAttributeLong(node, "MinRequestNum");
                        RuntimeData.MaxEnterNum   = (int)Global.GetSafeAttributeLong(node, "MaxEnterNum");

                        RuntimeData.WaitingEnterSecs = (int)Global.GetSafeAttributeLong(node, "WaitingEnterSecs");
                        RuntimeData.PrepareSecs      = (int)Global.GetSafeAttributeLong(node, "PrepareSecs");
                        RuntimeData.FightingSecs     = (int)Global.GetSafeAttributeLong(node, "FightingSecs");
                        RuntimeData.ClearRolesSecs   = (int)Global.GetSafeAttributeLong(node, "ClearRolesSecs");

                        if (!ConfigParser.ParserTimeRangeList(RuntimeData.TimePoints, Global.GetSafeAttributeStr(node, "TimePoints")))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, "读取幻影寺院时间配置(TimePoints)出错");
                        }

                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(RuntimeData.MapCode, out gameMap))
                        {
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("缺少幻影寺院地图 {0}", RuntimeData.MapCode));
                        }

                        RuntimeData.MapGridWidth  = gameMap.MapGridWidth;
                        RuntimeData.MapGridHeight = gameMap.MapGridHeight;

                        break;
                    }

                    //奖励配置
                    RuntimeData.TempleMirageEXPAward = GameManager.systemParamsList.GetParamValueIntByName("TempleMirageEXPAward");
                    RuntimeData.TempleMirageWin      = (int)GameManager.systemParamsList.GetParamValueIntByName("TempleMirageWin");
                    RuntimeData.TempleMiragePK       = (int)GameManager.systemParamsList.GetParamValueIntByName("TempleMiragePK");
                    RuntimeData.TempleMirageMinJiFen = (int)GameManager.systemParamsList.GetParamValueIntByName("TempleMirageMinJiFen");

                    if (!ConfigParser.ParseStrInt2(GameManager.systemParamsList.GetParamValueByName("TempleMirageWinNum"), ref RuntimeData.TempleMirageWinExtraNum, ref RuntimeData.TempleMirageWinExtraRate))
                    {
                        success = false;
                        LogManager.WriteLog(LogTypes.Fatal, "读取幻影寺院多倍奖励配置(TempleMirageWin)出错");
                    }

                    if (!ConfigParser.ParseStrInt2(GameManager.systemParamsList.GetParamValueByName("TempleMirageAward"), ref RuntimeData.TempleMirageAwardChengJiu, ref RuntimeData.TempleMirageAwardShengWang))
                    {
                        success = false;
                        LogManager.WriteLog(LogTypes.Fatal, "读取幻影寺院多倍奖励配置(TempleMirageWin)出错");
                    }

                    List <List <int> > levelRanges = ConfigParser.ParserIntArrayList(GameManager.systemParamsList.GetParamValueByName("TempleMirageLevel"));
                    if (levelRanges.Count == 0)
                    {
                        success = false;
                        LogManager.WriteLog(LogTypes.Fatal, "读取幻影寺院等级分组配置(TempleMirageLevel)出错");
                    }
                    else
                    {
                        for (int i = 0; i < levelRanges.Count; i++)
                        {
                            List <int> range = levelRanges[i];
                            RuntimeData.Range2GroupIndexDict.Add(new RangeKey(Global.GetUnionLevel(range[0], range[1]), Global.GetUnionLevel(range[2], range[3])), i + 1);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                }
            }

            return(success);
        }
        /// <summary>
        /// 添加技能辅助项
        /// </summary>
        /// <param name="magicActionID"></param>
        /// <param name="magicActionParams"></param>
        public void AddMagicHelper(MagicActionIDs magicActionID, double[] magicActionParams, int mapCode, Point centerGridXY, int gridWidthNum, int gridHeightNum, int copyMapID = -1)
        {
            if (copyMapID < 0)
            {
                copyMapID = -1;
            }

            GameMap gameMap = GameManager.MapMgr.DictMaps[mapCode];

            List <Point> pts = new List <Point>();

            pts.Add(centerGridXY);

            for (int i = (int)centerGridXY.X - gridWidthNum; i <= centerGridXY.X + gridWidthNum; i++)
            {
                for (int j = (int)centerGridXY.Y - gridHeightNum; j <= centerGridXY.Y + gridHeightNum; j++)
                {
                    pts.Add(new Point(i, j));
                }
            }

            for (int i = 0; i < pts.Count; i++)
            {
                ///障碍上边,不能放火墙
                if (Global.InOnlyObs(ObjectTypes.OT_CLIENT, mapCode, (int)pts[i].X, (int)pts[i].Y))
                {
                    continue;
                }

                Dictionary <MagicActionIDs, GridMagicHelperItem> dict = null;
                string key = string.Format("{0}_{1}_{2}", pts[i].X, pts[i].Y, copyMapID);
                lock (_GridMagicHelperDict)
                {
                    if (!_GridMagicHelperDict.TryGetValue(key, out dict))
                    {
                        dict = new Dictionary <MagicActionIDs, GridMagicHelperItem>();
                        _GridMagicHelperDict[key] = dict;
                    }
                }

                lock (dict)
                {
                    if (dict.ContainsKey(magicActionID)) //一个格子上边,同时只能有一个buffer
                    {
                        continue;
                    }
                }

                GridMagicHelperItem magicHelperItem = new GridMagicHelperItem()
                {
                    MagicActionID     = magicActionID,
                    MagicActionParams = magicActionParams,
                    StartedTicks      = TimeUtil.NOW(),
                    LastTicks         = TimeUtil.NOW(),
                    ExecutedNum       = 0,
                    MapCode           = mapCode,
                };

                lock (dict)
                {
                    dict[magicHelperItem.MagicActionID] = magicHelperItem;
                }
            }
        }
Exemple #13
0
        public bool ProcessKuaFuMapEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result     = StdErrorCode.Error_Success_No_Info;
                int toMapCode  = Global.SafeConvertToInt32(cmdParams[0]);
                int line       = Global.SafeConvertToInt32(cmdParams[1]);
                int toBoss     = 0;
                int teleportId = 0;
                if (cmdParams.Length >= 3)
                {
                    toBoss = Global.SafeConvertToInt32(cmdParams[2]);
                }
                if (cmdParams.Length >= 4)
                {
                    teleportId = Global.SafeConvertToInt32(cmdParams[3]);
                }

                do
                {
                    if (!KuaFuMapManager.getInstance().IsKuaFuMap(toMapCode))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }

                    if (!Global.CanEnterMap(client, toMapCode) ||
                        toMapCode == client.ClientData.MapCode)
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }

                    // 新增需求,跨服主线地图能够直接进入另一个跨服主线地图
                    if (!KuaFuMapManager.getInstance().IsKuaFuMap(client.ClientData.MapCode) &&
                        !CheckMap(client))
                    {
                        result = StdErrorCode.Error_Denied_In_Current_Map;
                        break;
                    }

                    if (!IsGongNengOpened(client))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }

                    KuaFuLineData kuaFuLineData;
                    if (!RuntimeData.LineMap2KuaFuLineDataDict.TryGetValue(new IntPairKey(line, toMapCode), out kuaFuLineData))
                    {
                        result = StdErrorCode.Error_Operation_Denied;
                        break;
                    }

                    if (kuaFuLineData.OnlineCount >= kuaFuLineData.MaxOnlineCount)
                    {
                        result = StdErrorCode.Error_Server_Connections_Limit;
                        break;
                    }

                    int fromMapCode = client.ClientData.MapCode;
                    if (teleportId > 0)
                    {
                        // 要通过传送点进入跨服主线,必须检测是否能真正使用这个传送点
                        GameMap fromGameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(fromMapCode, out fromGameMap))
                        {
                            result = StdErrorCode.Error_Config_Fault;
                            break;
                        }

                        MapTeleport mapTeleport = null;
                        if (!fromGameMap.MapTeleportDict.TryGetValue(teleportId, out mapTeleport) || mapTeleport.ToMapID != toMapCode)
                        {
                            result = StdErrorCode.Error_Operation_Denied;
                            break;
                        }

                        // 这里要增加一个位置判断,玩家是否在传送点附近, CMD_SPR_MAPCHANGE 里面没有判断,这里先放宽松一点
                        if (Global.GetTwoPointDistance(client.CurrentPos, new Point(mapTeleport.X, mapTeleport.Y)) > 800)
                        {
                            result = StdErrorCode.Error_Too_Far;
                            break;
                        }
                    }

                    int kuaFuServerId = YongZheZhanChangClient.getInstance().EnterKuaFuMap(client.ClientData.RoleID, kuaFuLineData.MapCode, kuaFuLineData.Line, client.ServerId, Global.GetClientKuaFuServerLoginData(client));
                    if (kuaFuServerId > 0)
                    {
                        // 废弃这个判断,两个跨服主线地图配在同一台服务器上,仍然统一短线重连<客户端并不需要知道没有跨到另一个服务器>
                        if (false && kuaFuServerId == GameManager.ServerId)
                        {
                            Global.GotoMap(client, toMapCode);
                        }
                        else
                        {
                            // 使用传送点,不扣金币
                            int needMoney = teleportId > 0 ? 0 : Global.GetMapTransNeedMoney(toMapCode);
                            if (Global.GetTotalBindTongQianAndTongQianVal(client) < needMoney)
                            {
                                GameManager.ClientMgr.NotifyImportantMsg(client, StringUtil.substitute(Global.GetLang("金币不足【{0}】,无法传送到【{1}】!"), needMoney, Global.GetMapName(toMapCode)), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, (int)HintErrCodeTypes.NoTongQian);
                                result = StdErrorCode.Error_JinBi_Not_Enough;
                            }
                            else
                            {
                                int[] enterFlags = new int[(int)EKuaFuMapEnterFlag.Max];
                                enterFlags[(int)EKuaFuMapEnterFlag.FromMapCode]  = fromMapCode;
                                enterFlags[(int)EKuaFuMapEnterFlag.FromTeleport] = teleportId;
                                enterFlags[(int)EKuaFuMapEnterFlag.TargetBossId] = toBoss;
                                Global.SaveRoleParamsIntListToDB(client, new List <int>(enterFlags), RoleParamName.EnterKuaFuMapFlag, true);

                                GlobalNew.RecordSwitchKuaFuServerLog(client);
                                client.sendCmd((int)TCPGameServerCmds.CMD_SPR_KF_SWITCH_SERVER, Global.GetClientKuaFuServerLoginData(client));
                            }
                        }
                    }
                    else
                    {
                        Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                        result = kuaFuServerId;
                    }
                } while (false);

                client.sendCmd(nID, result);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Exemple #14
0
        public static void TimerProc()
        {
            if (!GameManager.IsKuaFuServer)
            {
                long nowTicks = TimeUtil.NOW();
                lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex)
                {
                    if (Math.Abs(nowTicks - ZhuanShengShiLian.LastHeartBeatTicks) < 1000L)
                    {
                        return;
                    }
                    ZhuanShengShiLian.LastHeartBeatTicks = nowTicks;
                }
                if (157 == ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.ActivityType && ZhuanShengShiLian.ZhuanShengRunTimeData.ThemeZSActivity.InActivityTime())
                {
                    foreach (KeyValuePair <int, ZSSLScene> scenes in ZhuanShengShiLian.SceneDict)
                    {
                        lock (ZhuanShengShiLian.ZhuanShengRunTimeData.Mutex)
                        {
                            switch (scenes.Value.State)
                            {
                            case BattleStates.NoBattle:
                            {
                                DateTime startTime = DateTime.Parse(scenes.Value.SceneInfo.TimePoints[0]).AddSeconds((double)scenes.Value.SceneInfo.ReadyTime);
                                scenes.Value.StartTick     = startTime.Ticks / 10000L;
                                scenes.Value.EndTick       = startTime.AddSeconds((double)scenes.Value.SceneInfo.FightSecs).Ticks / 10000L;
                                scenes.Value.StatusEndTime = scenes.Value.StartTick;
                                ZhuanShengShiLian.BroadMsg(scenes.Value.SceneInfo.MapCode, GLang.GetLang(4010, new object[0]));
                                scenes.Value.State = BattleStates.WaitingFight;
                                break;
                            }

                            case BattleStates.WaitingFight:
                                if (nowTicks >= scenes.Value.StartTick && null != scenes.Value.m_CopyMap)
                                {
                                    GameManager.MonsterZoneMgr.AddDynamicMonsters(scenes.Value.SceneInfo.MapCode, scenes.Value.SceneInfo.MonstersID, scenes.Value.m_CopyMap.FuBenSeqID, 1, scenes.Value.SceneInfo.BornX / 100, scenes.Value.SceneInfo.BornY / 100, 0, 0, SceneUIClasses.Normal, null, null);
                                    scenes.Value.State         = BattleStates.StartFight;
                                    scenes.Value.StatusEndTime = scenes.Value.EndTick;
                                    ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks);
                                }
                                break;

                            case BattleStates.StartFight:
                                if (nowTicks >= scenes.Value.EndTick)
                                {
                                    scenes.Value.State         = BattleStates.EndFight;
                                    scenes.Value.StatusEndTime = scenes.Value.EndTick;
                                    scenes.Value.BossDie       = false;
                                    List <object> monsterList = GameManager.MonsterMgr.GetObjectsByMap(scenes.Value.SceneInfo.MapCode);
                                    foreach (object monster in monsterList)
                                    {
                                        if (monster is Monster)
                                        {
                                            GameManager.MonsterMgr.DeadMonsterImmediately(monster as Monster);
                                        }
                                    }
                                }
                                break;

                            case BattleStates.EndFight:
                                try
                                {
                                    List <ShiLianReward> rewardList;
                                    if (ZhuanShengShiLian.ZhuanShengRunTimeData.ShiLianRewardDict.TryGetValue(scenes.Value.SceneInfo.MapCode, out rewardList))
                                    {
                                        List <BHAttackLog> bhAttackLogList = scenes.Value.AttackLog.BHInjure.Values.ToList <BHAttackLog>();
                                        int i;
                                        for (i = 0; i < bhAttackLogList.Count; i++)
                                        {
                                            if (bhAttackLogList[i].BHInjure > 0L)
                                            {
                                                int rank = scenes.Value.AttackLog.BHAttackRank.FindIndex((BHAttackLog x) => object.ReferenceEquals(x, bhAttackLogList[i]));
                                                rank++;
                                                ShiLianReward reward = rewardList.Find((ShiLianReward _x) => _x.MinRank <= rank && (rank <= _x.MaxRank || _x.MaxRank < 0));
                                                if (null != reward)
                                                {
                                                    int    exp   = scenes.Value.BossDie ? reward.WinrewardExp : reward.LoseRewardExp;
                                                    int    money = scenes.Value.BossDie ? reward.WinRewardMoney : reward.LoseRewardMoney;
                                                    string goods = scenes.Value.BossDie ? reward.WinRewardItem : reward.LoseRewardItem;
                                                    foreach (KeyValuePair <int, long> role in bhAttackLogList[i].RoleInjure)
                                                    {
                                                        GameClient client = GameManager.ClientMgr.FindClient(role.Key);
                                                        if (null != client)
                                                        {
                                                            if (client.ClientData.MapCode == scenes.Value.SceneInfo.MapCode)
                                                            {
                                                                GameManager.ClientMgr.ProcessRoleExperience(client, (long)exp, false, true, false, "none");
                                                                GameManager.ClientMgr.AddMoney1(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, money, "转生试炼添加绑金", true);
                                                                ZhuanShengShiLian.GiveGoodsAward(client, goods);
                                                                client.sendCmd(1908, string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                                                                {
                                                                    scenes.Value.BossDie ? 1 : 0,
                                                                    goods,
                                                                    exp,
                                                                    money,
                                                                    rank
                                                                }), false);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    scenes.Value.AttackLog = null;
                                }
                                catch (Exception ex)
                                {
                                    DataHelper.WriteExceptionLogEx(ex, "转生试炼调度异常");
                                }
                                scenes.Value.ClearTick     = nowTicks + (long)(scenes.Value.SceneInfo.ClearRolesSecs * 1000);
                                scenes.Value.StatusEndTime = scenes.Value.ClearTick;
                                scenes.Value.State         = BattleStates.ClearBattle;
                                ZhuanShengShiLian.SendTimeInfoToAll(scenes.Value, nowTicks);
                                break;

                            case BattleStates.ClearBattle:
                                if (nowTicks >= scenes.Value.ClearTick)
                                {
                                    List <GameClient> objsList = scenes.Value.m_CopyMap.GetClientsList();
                                    if (objsList != null && objsList.Count > 0)
                                    {
                                        for (int j = 0; j < objsList.Count; j++)
                                        {
                                            GameClient client = objsList[j];
                                            if (client != null)
                                            {
                                                int toMapCode = GameManager.MainMapCode;
                                                int toPosX    = -1;
                                                int toPosY    = -1;
                                                if (client.ClientData.LastMapCode != -1 && client.ClientData.LastPosX != -1 && client.ClientData.LastPosY != -1)
                                                {
                                                    if (MapTypes.Normal == Global.GetMapType(client.ClientData.LastMapCode))
                                                    {
                                                        toMapCode = client.ClientData.LastMapCode;
                                                        toPosX    = client.ClientData.LastPosX;
                                                        toPosY    = client.ClientData.LastPosY;
                                                    }
                                                }
                                                GameMap gameMap = null;
                                                if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                                {
                                                    GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, toMapCode, toPosX, toPosY, -1, 0);
                                                }
                                            }
                                        }
                                    }
                                    scenes.Value.State = BattleStates.NoBattle;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 添加一个场景
        /// </summary>
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            if (sceneType == SceneUIClasses.KingOfBattle)
            {
                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap))
                {
                    return(false);
                }

                int      fuBenSeqId = copyMap.FuBenSeqID;
                int      mapCode    = copyMap.MapCode;
                int      roleId     = client.ClientData.RoleID;
                int      gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                DateTime now        = TimeUtil.NowDateTime();
                lock (RuntimeData.Mutex)
                {
                    KingOfBattleScene scene = null;
                    if (!SceneDict.TryGetValue(fuBenSeqId, out scene))
                    {
                        KingOfBattleSceneInfo     sceneInfo = null;
                        YongZheZhanChangFuBenData fuBenData;
                        if (!RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的跨服副本数据,GameID:" + gameId);
                        }

                        if (!RuntimeData.SceneDataDict.TryGetValue(fuBenData.GroupIndex, out sceneInfo))
                        {
                            LogManager.WriteLog(LogTypes.Error, "王者战场没有为副本找到对应的档位数据,ID:" + fuBenData.GroupIndex);
                        }

                        scene         = new KingOfBattleScene();
                        scene.CopyMap = copyMap;
                        scene.CleanAllInfo();
                        scene.GameId         = gameId;
                        scene.m_nMapCode     = mapCode;
                        scene.CopyMapId      = copyMap.CopyMapID;
                        scene.FuBenSeqId     = fuBenSeqId;
                        scene.m_nPlarerCount = 1;
                        scene.SceneInfo      = sceneInfo;
                        scene.MapGridWidth   = gameMap.MapGridWidth;
                        scene.MapGridHeight  = gameMap.MapGridHeight;
                        DateTime startTime = now.Date.Add(GetStartTime(sceneInfo.Id));
                        scene.StartTimeTicks = startTime.Ticks / 10000;
                        InitScene(scene, client);
                        scene.GameStatisticalData.GameId = gameId;

                        SceneDict[fuBenSeqId] = scene;
                    }
                    else
                    {
                        scene.m_nPlarerCount++;
                    }

                    KingOfBattleClientContextData clientContextData;
                    if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData))
                    {
                        clientContextData = new KingOfBattleClientContextData()
                        {
                            RoleId = roleId, ServerId = client.ServerId, BattleWhichSide = client.ClientData.BattleWhichSide
                        };
                        scene.ClientContextDataDict[roleId] = clientContextData;
                    }
                    else
                    {
                        clientContextData.KillNum = 0;
                    }

                    client.SceneObject       = scene;
                    client.SceneGameId       = scene.GameId;
                    client.SceneContextData2 = clientContextData;

                    copyMap.IsKuaFuCopy = true;
                    copyMap.SetRemoveTicks(TimeUtil.NOW() + scene.SceneInfo.TotalSecs * TimeUtil.SECOND);
                }

                //更新状态
                YongZheZhanChangClient.getInstance().GameFuBenRoleChangeState(roleId, (int)KuaFuRoleStates.StartGame);
                return(true);
            }
            return(false);
        }
Exemple #16
0
        /// <summary>
        // 开始动作
        /// </summary>
        public static void StartAction(DelayAction action)
        {
            DelayActionType nActionID = action.m_DelayActionType;

            switch (nActionID)
            {
            case DelayActionType.DA_BLINK:
            {
                // 闪现
                int        nParams = action.m_Params[0];    // 距离
                GameClient client  = action.m_Client;

                int     nRadius     = nParams * 100;                                          // 半径
                GameMap gameMap     = GameManager.MapMgr.DictMaps[client.ClientData.MapCode]; // 取得地图信息
                int     nDirection  = client.ClientData.RoleDirection;                        // 玩家朝向
                Point   pClientGrid = client.CurrentGrid;                                     // 玩家所在的格子
                int     nGridNum    = nRadius / gameMap.MapGridWidth;                         // 取得半径长度包含的格子数量
                int     nTmp        = nGridNum;

                // 根据当前所在的格子列表、半径  取得范围内的格子数量
                //int nGridWidthNum = nRadius / gameMap.MapGridWidth;
                //int nGridHeightNum = nRadius / gameMap.MapGridHeight;

                //List<Point> lPointsList = Global.GetGridPointByRadius((int)pClientGrid.X, (int)pClientGrid.Y, nGridWidthNum, nGridHeightNum);   // 格子列表
                //int nGridNum = lPointsList.Count;

                // 根据朝向、当前所在格子、将要行进的格子数量  取得前方的格子列表
                List <Point> lMovePointsList = Global.GetGridPointByDirection(nDirection, (int)pClientGrid.X, (int)pClientGrid.Y, nGridNum);

                // 玩家、怪的阻挡设置 将影响能不能到达有人物或者怪的格子
                byte holdBitSet = 0;
                holdBitSet |= (byte)ForceHoldBitSets.HoldRole;
                holdBitSet |= (byte)ForceHoldBitSets.HoldMonster;

                for (int i = 0; i < lMovePointsList.Count; i++)
                {
                    if (Global.InObsByGridXY(client.ObjectType, client.ClientData.MapCode, (int)lMovePointsList[i].X, (int)lMovePointsList[i].Y, 0, holdBitSet))
                    {
                        break;
                    }
                    else
                    {
                        --nGridNum;
                    }
                }

                if (nGridNum < nTmp)
                {
                    pClientGrid = lMovePointsList[nTmp - nGridNum - 1];
                }

                Point canMovePoint = pClientGrid;
                if (!Global.CanQueueMoveObject(client, nDirection, (int)pClientGrid.X, (int)pClientGrid.Y, nGridNum, nGridNum, holdBitSet, out canMovePoint, false))
                {
                    Point clientMoveTo = new Point(canMovePoint.X * gameMap.MapGridWidth + gameMap.MapGridWidth / 2, canMovePoint.Y * gameMap.MapGridHeight + gameMap.MapGridHeight / 2);

                    GameManager.ClientMgr.ChangePosition(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, (int)clientMoveTo.X, (int)clientMoveTo.Y,
                                                         client.ClientData.RoleDirection, (int)TCPGameServerCmds.CMD_SPR_CHANGEPOS, 3);
                }
                else
                {
                    Point clientMoveTo = new Point(lMovePointsList[lMovePointsList.Count - 1].X * gameMap.MapGridWidth + gameMap.MapGridWidth / 2, lMovePointsList[lMovePointsList.Count - 1].Y * gameMap.MapGridHeight + gameMap.MapGridHeight / 2);

                    GameManager.ClientMgr.ChangePosition(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, (int)clientMoveTo.X, (int)clientMoveTo.Y,
                                                         client.ClientData.RoleDirection, (int)TCPGameServerCmds.CMD_SPR_CHANGEPOS, 3);
                }

                List <Object> objsList = Global.GetAll9Clients(client);
                string        strcmd   = string.Format("{0}", client.ClientData.RoleID);
                GameManager.ClientMgr.SendToClients(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, null, objsList, strcmd, (int)TCPGameServerCmds.CMD_SPR_ENDBLINK);

                RemoveDelayAction(action);
            }
            break;

            default:
                break;
            }
        }
Exemple #17
0
        /// <summary>
        /// 初始化配置
        /// </summary>
        public bool InitConfig()
        {
            bool     success          = true;
            XElement xml              = null;
            string   fileName         = "";
            string   fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (RuntimeData.Mutex)
            {
                try
                {
                    //出生点配置
                    RuntimeData.MapBirthPointDict.Clear();

                    fileName         = "Config/ThroughServiceBossRebirth.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        KuaFuBossBirthPoint item = new KuaFuBossBirthPoint();
                        item.ID          = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.PosX        = (int)Global.GetSafeAttributeLong(node, "PosX");
                        item.PosY        = (int)Global.GetSafeAttributeLong(node, "PosY");
                        item.BirthRadius = (int)Global.GetSafeAttributeLong(node, "BirthRadius");

                        RuntimeData.MapBirthPointDict[item.ID] = item;
                    }

                    //活动配置
                    RuntimeData.SceneDataDict.Clear();
                    RuntimeData.LevelRangeSceneIdDict.Clear();
                    RuntimeData.SceneDynMonsterDict.Clear();

                    fileName         = "Config/ThroughServiceBoss.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        KuaFuBossSceneInfo sceneItem = new KuaFuBossSceneInfo();
                        int id      = (int)Global.GetSafeAttributeLong(node, "MapCode");
                        int mapCode = (int)Global.GetSafeAttributeLong(node, "MapCode");

                        sceneItem.Id               = id;
                        sceneItem.MapCode          = mapCode;
                        sceneItem.MinLevel         = (int)Global.GetSafeAttributeLong(node, "MinLevel");
                        sceneItem.MaxLevel         = (int)Global.GetSafeAttributeLong(node, "MaxLevel");
                        sceneItem.MinZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MinZhuanSheng");
                        sceneItem.MaxZhuanSheng    = (int)Global.GetSafeAttributeLong(node, "MaxZhuanSheng");
                        sceneItem.PrepareSecs      = (int)Global.GetSafeAttributeLong(node, "PrepareSecs");
                        sceneItem.WaitingEnterSecs = (int)Global.GetSafeAttributeLong(node, "WaitingEnterSecs");
                        sceneItem.FightingSecs     = (int)Global.GetSafeAttributeLong(node, "FightingSecs");
                        sceneItem.ClearRolesSecs   = (int)Global.GetSafeAttributeLong(node, "ClearRolesSecs");

                        ConfigParser.ParseStrInt2(Global.GetSafeAttributeStr(node, "ApplyTime"), ref sceneItem.SignUpStartSecs, ref sceneItem.SignUpEndSecs);
                        sceneItem.SignUpStartSecs += sceneItem.SignUpEndSecs;

                        if (!ConfigParser.ParserTimeRangeListWithDay(sceneItem.TimePoints, Global.GetSafeAttributeStr(node, "TimePoints")))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("读取{0}时间配置(TimePoints)出错", fileName));
                        }

                        for (int i = 0; i < sceneItem.TimePoints.Count; ++i)
                        {
                            TimeSpan ts = new TimeSpan(sceneItem.TimePoints[i].Hours, sceneItem.TimePoints[i].Minutes, sceneItem.TimePoints[i].Seconds);
                            sceneItem.SecondsOfDay.Add(ts.TotalSeconds);
                        }

                        GameMap gameMap = null;
                        if (!GameManager.MapMgr.DictMaps.TryGetValue(mapCode, out gameMap))
                        {
                            success = false;
                            LogManager.WriteLog(LogTypes.Fatal, string.Format("22地图配置中缺少{0}所需的地图:{1}", fileName, mapCode));
                        }

                        RangeKey range = new RangeKey(Global.GetUnionLevel(sceneItem.MinZhuanSheng, sceneItem.MinLevel), Global.GetUnionLevel(sceneItem.MaxZhuanSheng, sceneItem.MaxLevel));
                        RuntimeData.LevelRangeSceneIdDict[range] = sceneItem;
                        RuntimeData.SceneDataDict[id]            = sceneItem;
                    }

                    fileName         = "Config/ThroughServiceBossMonster.xml";
                    fullPathFileName = Global.GameResPath(fileName); //Global.IsolateResPath(fileName);
                    xml   = XElement.Load(fullPathFileName);
                    nodes = xml.Elements();
                    foreach (var node in nodes)
                    {
                        BattleDynamicMonsterItem item = new BattleDynamicMonsterItem();
                        item.Id            = (int)Global.GetSafeAttributeLong(node, "ID");
                        item.MapCode       = (int)Global.GetSafeAttributeLong(node, "CodeID");
                        item.MonsterID     = (int)Global.GetSafeAttributeLong(node, "MonsterID");
                        item.PosX          = (int)Global.GetSafeAttributeLong(node, "X");
                        item.PosY          = (int)Global.GetSafeAttributeLong(node, "Y");
                        item.DelayBirthMs  = (int)Global.GetSafeAttributeLong(node, "Time");
                        item.PursuitRadius = (int)Global.GetSafeAttributeLong(node, "PursuitRadius");
                        item.Num           = (int)Global.GetSafeAttributeLong(node, "Num");
                        item.Radius        = (int)Global.GetSafeAttributeLong(node, "Radius");

                        List <BattleDynamicMonsterItem> itemList = null;
                        if (!RuntimeData.SceneDynMonsterDict.TryGetValue(item.MapCode, out itemList))
                        {
                            itemList = new List <BattleDynamicMonsterItem>();
                            RuntimeData.SceneDynMonsterDict[item.MapCode] = itemList;
                        }

                        itemList.Add(item);
                    }
                }
                catch (System.Exception ex)
                {
                    success = false;
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。", fileName), ex);
                }
            }

            return(success);
        }
Exemple #18
0
        public bool AddCopyScenes(GameClient client, CopyMap copyMap, SceneUIClasses sceneType)
        {
            bool result;

            if (sceneType == SceneUIClasses.KarenWest)
            {
                GameMap gameMap = null;
                if (!GameManager.MapMgr.DictMaps.TryGetValue(client.ClientData.MapCode, out gameMap))
                {
                    result = false;
                }
                else
                {
                    int      fuBenSeqId = copyMap.FuBenSeqID;
                    int      mapCode    = copyMap.MapCode;
                    int      roleId     = client.ClientData.RoleID;
                    int      gameId     = (int)Global.GetClientKuaFuServerLoginData(client).GameId;
                    DateTime now        = TimeUtil.NowDateTime();
                    lock (this.RuntimeData.Mutex)
                    {
                        KarenBattleScene scene = null;
                        if (!this.SceneDict.TryGetValue(fuBenSeqId, out scene))
                        {
                            KarenFuBenData fuBenData;
                            if (!this.RuntimeData.FuBenItemData.TryGetValue(gameId, out fuBenData))
                            {
                                LogManager.WriteLog(LogTypes.Error, "阿卡伦战场没有为副本找到对应的跨服副本数据,GameID:" + gameId, null, true);
                            }
                            KarenBattleSceneInfo sceneInfo;
                            if (null == (sceneInfo = KarenBattleManager.getInstance().TryGetKarenBattleSceneInfo(mapCode)))
                            {
                                LogManager.WriteLog(LogTypes.Error, "阿卡伦战场没有为副本找到对应的档位数据,ID:" + mapCode, null, true);
                            }
                            scene         = new KarenBattleScene();
                            scene.CopyMap = copyMap;
                            scene.CleanAllInfo();
                            scene.GameId         = gameId;
                            scene.m_nMapCode     = mapCode;
                            scene.CopyMapId      = copyMap.CopyMapID;
                            scene.FuBenSeqId     = fuBenSeqId;
                            scene.m_nPlarerCount = 1;
                            scene.SceneInfo      = sceneInfo;
                            scene.MapGridWidth   = gameMap.MapGridWidth;
                            scene.MapGridHeight  = gameMap.MapGridHeight;
                            DateTime startTime = now.Date.Add(KarenBattleManager.getInstance().GetStartTime(sceneInfo.MapCode));
                            scene.StartTimeTicks = startTime.Ticks / 10000L;
                            this.InitScene(scene, client);
                            this.SceneDict[fuBenSeqId] = scene;
                        }
                        else
                        {
                            scene.m_nPlarerCount++;
                        }
                        KarenBattleClientContextData clientContextData;
                        if (!scene.ClientContextDataDict.TryGetValue(roleId, out clientContextData))
                        {
                            clientContextData = new KarenBattleClientContextData
                            {
                                RoleId          = roleId,
                                ServerId        = client.ServerId,
                                BattleWhichSide = client.ClientData.BattleWhichSide
                            };
                            scene.ClientContextDataDict[roleId] = clientContextData;
                        }
                        client.SceneObject       = scene;
                        client.SceneGameId       = (long)scene.GameId;
                        client.SceneContextData2 = clientContextData;
                        copyMap.IsKuaFuCopy      = true;
                        copyMap.SetRemoveTicks(TimeUtil.NOW() + (long)(scene.SceneInfo.TotalSecs * 1000));
                    }
                    JunTuanClient.getInstance().GameFuBenRoleChangeState(client.ServerId, roleId, gameId, client.ClientData.BattleWhichSide, 5);
                    result = true;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemple #19
0
        /// <summary>
        // 心跳处理
        /// </summary>
        static public void HeartBeatDaimonSquareScene()
        {
            foreach (var DaimonSquareScenes in m_DaimonSquareListScenes)
            {
                DaimonSquareDataInfo bcDataTmp = Data.DaimonSquareDataInfoList[DaimonSquareScenes.Key];
                DaimonSquareScene    bcTmp     = GetDaimonSquareListScenes(DaimonSquareScenes.Key);
                if (bcTmp == null || bcDataTmp == null)
                {
                    continue;
                }

                int nRoleNum = 0;
                nRoleNum = GameManager.ClientMgr.GetMapClientsCount(bcTmp.m_nMapCode);
                if (nRoleNum <= 0)
                {
                    if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_BEGIN)
                    {
                        // 做清空处理  比如 所有动态刷出的怪 都delete掉
                        CleanDaimonSquareScene(bcTmp.m_nMapCode);
                        bcTmp.CleanAllInfo();
                        bcTmp.m_nMapCode = DaimonSquareScenes.Key;
                    }
                    //continue;
                }

                // 当前tick
                long ticks = DateTime.Now.Ticks / 10000;

                if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_NULL)
                {
                    bool bPushMsg = false;

                    if (Global.CanEnterDaimonSquareOnTime(bcDataTmp.BeginTime, 0))
                    {
                        // 场景开启
                        bcTmp.m_eStatus           = DaimonSquareStatus.FIGHT_STATUS_PREPARE;
                        bcTmp.m_lPrepareTime      = DateTime.Now.Ticks / 10000;
                        bcTmp.m_nMonsterTotalWave = bcDataTmp.MonsterID.Length;

                        // 消息推送
                        if (bPushMsg)
                        {
                            int nNow = DateTime.Now.DayOfYear;

                            if (bPushMsg && m_nPushMsgDayID != nNow)
                            {
                                //Global.DayActivityTiggerPushMessage((int)SpecialActivityTypes.DemoSque);

                                Global.UpdateDBGameConfigg(GameConfigNames.DemoSquarePushMsgDayID, nNow.ToString());

                                m_nPushMsgDayID = nNow;
                            }
                        }
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_PREPARE)
                {
                    if (ticks >= (bcTmp.m_lPrepareTime + (bcDataTmp.PrepareTime * 1000)))
                    {
                        // 准备战斗
                        bcTmp.m_eStatus = DaimonSquareStatus.FIGHT_STATUS_BEGIN;

                        bcTmp.m_lBeginTime = DateTime.Now.Ticks / 10000;
                        int nTimer = (int)((bcDataTmp.DurationTime * 1000 - (ticks - bcTmp.m_lBeginTime)) / 1000);

                        GameManager.ClientMgr.NotifyDaimonSquareMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                    (int)TCPGameServerCmds.CMD_SPR_QUERYDAIMONSQUARETIMERINFO, (int)DaimonSquareStatus.FIGHT_STATUS_BEGIN, nTimer, 0, 0, 0); // 战斗结束倒计时
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_BEGIN)
                {
                    // 开始战斗 -- 刷怪
                    if (bcTmp.m_nCreateMonsterFlag == 0 && bcTmp.m_nMonsterWave < bcTmp.m_nMonsterTotalWave)
                    {
                        DaimonSquareSceneCreateMonster(bcTmp, bcDataTmp);
                    }

                    if (ticks >= (bcTmp.m_lBeginTime + (bcDataTmp.DurationTime * 1000)) || bcTmp.m_nKillMonsterTotalNum == bcDataTmp.MonsterSum)
                    {
                        bcTmp.m_eStatus  = DaimonSquareStatus.FIGHT_STATUS_END;
                        bcTmp.m_lEndTime = DateTime.Now.Ticks / 10000;
                    }
                }
                else if (bcTmp.m_eStatus == DaimonSquareStatus.FIGHT_STATUS_END)
                {
                    // 战斗结束

                    int nTimer = (int)((bcDataTmp.LeaveTime * 1000 - (ticks - bcTmp.m_lEndTime)) / 1000);

                    if (bcTmp.m_bEndFlag == false)
                    {
                        GameManager.ClientMgr.NotifyDaimonSquareMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                    (int)TCPGameServerCmds.CMD_SPR_QUERYDAIMONSQUARETIMERINFO, (int)DaimonSquareStatus.FIGHT_STATUS_END, nTimer, 0, 0, 0);

                        // 剩余时间奖励
                        long nTimeInfo = 0;
                        nTimeInfo = bcTmp.m_lEndTime - bcTmp.m_lBeginTime;

                        long nRemain = 0;
                        nRemain = ((bcDataTmp.DurationTime * 1000) - nTimeInfo) / 1000;

                        if (nRemain >= bcDataTmp.DurationTime)
                        {
                            nRemain = bcDataTmp.DurationTime / 2;
                        }

                        int nTimeAward = 0;
                        nTimeAward = (int)(bcDataTmp.TimeModulus * nRemain);

                        if (nTimeAward < 0)
                        {
                            nTimeAward = 0;
                        }

                        GameManager.ClientMgr.NotifyDaimonSquareMsgEndFight(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, DaimonSquareScenes.Key,
                                                                            (int)TCPGameServerCmds.CMD_SPR_DAIMONSQUAREENDFIGHT, nTimeAward);

                        bcTmp.m_bEndFlag = true;
                    }

                    if (ticks >= (bcTmp.m_lEndTime + (bcDataTmp.LeaveTime * 1000)))
                    {
                        // 清场
                        List <Object> objsList = GameManager.ClientMgr.GetMapClients(DaimonSquareScenes.Key);
                        if (objsList != null)
                        {
                            for (int n = 0; n < objsList.Count; ++n)
                            {
                                GameClient c = objsList[n] as GameClient;
                                if (c == null)
                                {
                                    continue;
                                }

                                if (c.ClientData.MapCode != DaimonSquareScenes.Key)
                                {
                                    continue;
                                }

                                //CompleteDaimonSquareScene(c, bcTmp, bcDataTmp);

                                // 根据公式和积分奖励经验
                                //GiveAwardDaimonSquareScene(c);

                                // 退出场景
                                int toMapCode = GameManager.MainMapCode;    //主城ID 防止意外
                                int toPosX    = -1;
                                int toPosY    = -1;
                                if (MapTypes.Normal == Global.GetMapType(c.ClientData.LastMapCode))
                                {
                                    if (GameManager.BattleMgr.BattleMapCode != c.ClientData.LastMapCode || GameManager.ArenaBattleMgr.BattleMapCode != c.ClientData.LastMapCode)
                                    {
                                        toMapCode = c.ClientData.LastMapCode;
                                        toPosX    = c.ClientData.LastPosX;
                                        toPosY    = c.ClientData.LastPosY;
                                    }
                                }

                                GameMap gameMap = null;
                                if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap))
                                {
                                    c.ClientData.bIsInDaimonSquareMap = false;
                                    GameManager.ClientMgr.NotifyChangeMap(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, c, toMapCode, toPosX, toPosY, -1);
                                }
                            }
                        }

                        CleanDaimonSquareScene(DaimonSquareScenes.Key);
                        bcTmp.CleanAllInfo();
                        bcTmp.m_nMapCode = DaimonSquareScenes.Key;
                    }
                }
            }
        }