/// <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); }
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); }