예제 #1
0
        /// <summary>
        /// 查找指定格子内的敌人
        /// </summary>
        /// <param name="toX"></param>
        /// <param name="toY"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static void LookupEnemiesAtGridXY(IObject attacker, int gridX, int gridY, List <Object> enemiesList)
        {
            int     mapCode = attacker.CurrentMapCode;
            MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];

            List <Object> objList = mapGrid.FindObjects((int)gridX, (int)gridY);

            if (null == objList)
            {
                return;
            }

            for (int i = 0; i < objList.Count; i++)
            {
                if (!(objList[i] is FakeRoleItem))
                {
                    continue;
                }

                //不在同一个副本
                if (null != attacker && attacker.CurrentCopyMapID != (objList[i] as FakeRoleItem).CopyMapID)
                {
                    continue;
                }

                enemiesList.Add(objList[i]);
            }
        }
예제 #2
0
        public static void LookupEnemiesInCircleByAngle(GameClient client, int direction, int mapCode, int toX, int toY, int radius, List <object> enemiesList, double angle, bool near180)
        {
            MapGrid       mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            List <object> objList = mapGrid.FindObjects(toX, toY, radius);

            if (null != objList)
            {
                double loAngle = 0.0;
                double hiAngle = 0.0;
                Global.GetAngleRangeByDirection(direction, angle, out loAngle, out hiAngle);
                Point center = new Point((double)toX, (double)toY);
                for (int i = 0; i < objList.Count; i++)
                {
                    if (objList[i] is FakeRoleItem)
                    {
                        if (client == null || Global.IsOpposition(client, objList[i] as FakeRoleItem))
                        {
                            if (client == null || client.ClientData.CopyMapID == (objList[i] as FakeRoleItem).CopyMapID)
                            {
                                Point pt = new Point((double)(objList[i] as FakeRoleItem).MyRoleDataMini.PosX, (double)(objList[i] as FakeRoleItem).MyRoleDataMini.PosY);
                                if (Global.InCircleByAngle(pt, center, (double)radius, loAngle, hiAngle))
                                {
                                    enemiesList.Add(objList[i]);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        // 增加扫描类型 矩形扫描 [11/27/2013 LiaoWei]
        /// <summary>
        /// 查找指定矩形范围内的怪
        /// </summary>
        /// <param name="toX"></param>
        /// <param name="toY"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static void LookupRolesInSquare(GameClient client, int mapCode, int radius, int nWidth, List <Object> rolesList)
        {
            MapGrid       mapGrid  = GameManager.MapGridMgr.DictGrids[mapCode];
            List <Object> objsList = mapGrid.FindObjects((int)client.ClientData.PosX, (int)client.ClientData.PosY, radius);

            if (null == objsList)
            {
                return;
            }

            // 源点
            Point source = new Point(client.ClientData.PosX, client.ClientData.PosY);

            Point toPos = Global.GetAPointInCircle(source, radius, client.ClientData.RoleYAngle);

            int toX = (int)toPos.X;
            int toY = (int)toPos.Y;

            // 矩形的中心点
            Point center = new Point();

            center.X = (client.ClientData.PosX + toX) / 2;
            center.Y = (client.ClientData.PosY + toY) / 2;

            // 矩形方向向量
            int fDirectionX = toX - client.ClientData.PosX;
            int fDirectionY = toY - client.ClientData.PosY;

            //Point center = new Point(toX, toY);

            for (int i = 0; i < objsList.Count; i++)
            {
                if (!(objsList[i] is FakeRoleItem))
                {
                    continue;
                }

                if ((objsList[i] as FakeRoleItem).CurrentLifeV <= 0)
                {
                    continue;
                }

                // 不在同一个副本
                if (null != client && client.ClientData.CopyMapID != (objsList[i] as FakeRoleItem).CopyMapID)
                {
                    continue;
                }

                Point target = new Point((objsList[i] as FakeRoleItem).CurrentPos.X, (objsList[i] as FakeRoleItem).CurrentPos.Y);

                if (Global.InSquare(center, target, radius, nWidth, fDirectionX, fDirectionY))
                {
                    rolesList.Add(objsList[i]);
                }
                else if (Global.InCircle(target, source, (double)100))  // 补充扫描
                {
                    rolesList.Add((objsList[i]));
                }
            }
        }
예제 #4
0
        public static void LookupEnemiesInCircle(GameClient client, int mapCode, int toX, int toY, int radius, List <object> enemiesList)
        {
            MapGrid       mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            List <object> objList = mapGrid.FindObjects(toX, toY, radius);

            if (null != objList)
            {
                Point center = new Point((double)toX, (double)toY);
                for (int i = 0; i < objList.Count; i++)
                {
                    if (objList[i] is FakeRoleItem)
                    {
                        if (client == null || Global.IsOpposition(client, objList[i] as FakeRoleItem))
                        {
                            if (client == null || client.ClientData.CopyMapID == (objList[i] as FakeRoleItem).CopyMapID)
                            {
                                Point pt = new Point((double)(objList[i] as FakeRoleItem).MyRoleDataMini.PosX, (double)(objList[i] as FakeRoleItem).MyRoleDataMini.PosY);
                                if (Global.InCircle(pt, center, (double)radius))
                                {
                                    enemiesList.Add(objList[i] as FakeRoleItem);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 判断怪物是否能在副本地图上移动
        /// </summary>
        /// <param name="monster"></param>
        /// <param name="nX"></param>
        /// <param name="nY"></param>
        /// <returns></returns>
        public static bool CanMonsterMoveOnCopyMap(Monster monster, int nX, int nY)
        {
            if (monster.CopyMapID <= 0)
            {
                return(false);
            }

            //如果是障碍
            if (Global.InOnlyObs(monster.ObjectType, monster.CurrentMapCode, nX, nY))
            {
                return(false);
            }

            MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[monster.CurrentMapCode];

            if (mapGrid.CanMove(monster.ObjectType, nX, nY, 0, 0)) //如果能移动
            {
                return(true);
            }

            bool canMove = true;

            /// 获取指定格子中的对象列表
            List <Object> objsList = mapGrid.FindObjects(nX, nY);

            if (null != objsList)
            {
                for (int objIndex = 0; objIndex < objsList.Count; objIndex++)
                {
                    if (objsList[objIndex] == monster) //自己不计算在内
                    {
                        continue;
                    }

                    if ((objsList[objIndex] is GameClient) && (objsList[objIndex] as GameClient).CurrentCopyMapID == monster.CopyMapID)
                    {
                        canMove = false;
                        break;
                    }

                    if (objsList[objIndex] is NPC)
                    {
                        canMove = false;
                        break;
                    }

                    if ((objsList[objIndex] is Monster) && (objsList[objIndex] as Monster).CopyMapID == monster.CopyMapID)
                    {
                        canMove = false;
                        break;
                    }
                }
            }

            return(canMove);
        }
예제 #6
0
        public static bool CanMonsterMoveOnCopyMap(Monster monster, int nX, int nY)
        {
            bool result;

            if (monster.CopyMapID <= 0)
            {
                result = false;
            }
            else if (Global.InOnlyObs(monster.ObjectType, monster.CurrentMapCode, nX, nY))
            {
                result = false;
            }
            else
            {
                MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[monster.CurrentMapCode];
                if (mapGrid.CanMove(monster.ObjectType, nX, nY, 0, 0))
                {
                    result = true;
                }
                else
                {
                    bool          canMove  = true;
                    List <object> objsList = mapGrid.FindObjects(nX, nY);
                    if (null != objsList)
                    {
                        for (int objIndex = 0; objIndex < objsList.Count; objIndex++)
                        {
                            if (objsList[objIndex] != monster)
                            {
                                if (objsList[objIndex] is GameClient && (objsList[objIndex] as GameClient).CurrentCopyMapID == monster.CopyMapID)
                                {
                                    canMove = false;
                                    break;
                                }
                                if (objsList[objIndex] is NPC)
                                {
                                    canMove = false;
                                    break;
                                }
                                if (objsList[objIndex] is Monster && (objsList[objIndex] as Monster).CopyMapID == monster.CopyMapID)
                                {
                                    canMove = false;
                                    break;
                                }
                            }
                        }
                    }
                    result = canMove;
                }
            }
            return(result);
        }
예제 #7
0
        /// <summary>
        /// 查找指定半圆周范围内的敌人
        /// </summary>
        /// <param name="toX"></param>
        /// <param name="toY"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static void LookupEnemiesInCircleByAngle(GameClient client, int direction, int mapCode, int toX, int toY, int radius, List <Object> enemiesList, double angle, bool near180)
        {
            MapGrid       mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            List <Object> objList = mapGrid.FindObjects((int)toX, (int)toY, radius);

            if (null == objList)
            {
                return;
            }

            double loAngle = 0.0, hiAngle = 0.0;

            Global.GetAngleRangeByDirection(direction, angle, out loAngle, out hiAngle);
            Point center = new Point(toX, toY);

            for (int i = 0; i < objList.Count; i++)
            {
                if (!(objList[i] is FakeRoleItem))
                {
                    continue;
                }

                //非敌对对象
                if (null != client && !Global.IsOpposition(client, (objList[i] as FakeRoleItem)))
                {
                    continue;
                }

                //不在同一个副本
                if (null != client && client.ClientData.CopyMapID != (objList[i] as FakeRoleItem).CopyMapID)
                {
                    continue;
                }

                Point pt = new Point((objList[i] as FakeRoleItem).MyRoleDataMini.PosX, (objList[i] as FakeRoleItem).MyRoleDataMini.PosY);
                if (Global.InCircleByAngle(pt, center, (double)radius, loAngle, hiAngle))
                {
                    enemiesList.Add((objList[i]));
                }
                else
                {
                    ;
                }
            }
        }
예제 #8
0
        public static void LookupEnemiesAtGridXY(IObject attacker, int gridX, int gridY, List <object> enemiesList)
        {
            int           mapCode = attacker.CurrentMapCode;
            MapGrid       mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            List <object> objList = mapGrid.FindObjects(gridX, gridY);

            if (null != objList)
            {
                for (int i = 0; i < objList.Count; i++)
                {
                    if (objList[i] is FakeRoleItem)
                    {
                        if (attacker == null || attacker.CurrentCopyMapID == (objList[i] as FakeRoleItem).CopyMapID)
                        {
                            enemiesList.Add(objList[i]);
                        }
                    }
                }
            }
        }
예제 #9
0
        public static void LookupRolesInSquare(GameClient client, int mapCode, int radius, int nWidth, List <object> rolesList)
        {
            MapGrid       mapGrid  = GameManager.MapGridMgr.DictGrids[mapCode];
            List <object> objsList = mapGrid.FindObjects(client.ClientData.PosX, client.ClientData.PosY, radius);

            if (null != objsList)
            {
                Point source = new Point((double)client.ClientData.PosX, (double)client.ClientData.PosY);
                Point toPos  = Global.GetAPointInCircle(source, radius, client.ClientData.RoleYAngle);
                int   toX    = (int)toPos.X;
                int   toY    = (int)toPos.Y;
                Point center = default(Point);
                center.X = (double)((client.ClientData.PosX + toX) / 2);
                center.Y = (double)((client.ClientData.PosY + toY) / 2);
                int fDirectionX = toX - client.ClientData.PosX;
                int fDirectionY = toY - client.ClientData.PosY;
                for (int i = 0; i < objsList.Count; i++)
                {
                    if (objsList[i] is FakeRoleItem)
                    {
                        if ((objsList[i] as FakeRoleItem).CurrentLifeV > 0)
                        {
                            if (client == null || client.ClientData.CopyMapID == (objsList[i] as FakeRoleItem).CopyMapID)
                            {
                                Point target = new Point((objsList[i] as FakeRoleItem).CurrentPos.X, (objsList[i] as FakeRoleItem).CurrentPos.Y);
                                if (Global.InSquare(center, target, radius, nWidth, fDirectionX, fDirectionY))
                                {
                                    rolesList.Add(objsList[i]);
                                }
                                else if (Global.InCircle(target, source, 100.0))
                                {
                                    rolesList.Add(objsList[i]);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        /// 查找指定圆周范围内的镖车
        /// </summary>
        /// <param name="toX"></param>
        /// <param name="toY"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static void LookupEnemiesInCircle(GameClient client, int mapCode, int toX, int toY, int radius, List <int> enemiesList)
        {
            MapGrid       mapGrid = GameManager.MapGridMgr.DictGrids[mapCode];
            List <Object> objList = mapGrid.FindObjects((int)toX, (int)toY, radius);

            if (null == objList)
            {
                return;
            }

            Point center = new Point(toX, toY);

            for (int i = 0; i < objList.Count; i++)
            {
                if (!(objList[i] is BiaoCheItem))
                {
                    continue;
                }

                //非敌对对象
                if (null != client && !Global.IsOpposition(client, (objList[i] as BiaoCheItem)))
                {
                    continue;
                }

                //不在同一个副本
                if (null != client && client.ClientData.CopyMapID != (objList[i] as BiaoCheItem).CopyMapID)
                {
                    continue;
                }

                Point pt = new Point((objList[i] as BiaoCheItem).PosX, (objList[i] as BiaoCheItem).PosY);
                if (Global.InCircle(pt, center, (double)radius))
                {
                    enemiesList.Add((objList[i] as BiaoCheItem).BiaoCheID);
                }
            }
        }