public static void MonsterMoveStepGoldCopySceneCopyMap(Monster monster) { long ticks = TimeUtil.NOW(); if (ticks - monster.MoveTime >= 500L) { int nStep = monster.Step; int nNumStep = monster.PatrolPath.Count <int[]>() - 1; int nNextStep = nStep + 1; if (nNextStep >= nNumStep) { GameManager.MonsterMgr.AddDelayDeadMonster(monster); } else { int nMapCode = 5100; MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[nMapCode]; int nNextX = monster.PatrolPath[nNextStep][0]; int nNextY = monster.PatrolPath[nNextStep][1]; int gridX = nNextX / mapGrid.MapGridWidth; int gridY = nNextY / mapGrid.MapGridHeight; Point ToGrid = new Point((double)gridX, (double)gridY); Point grid = monster.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; double Direction = Global.GetDirectionByAspect(gridX, gridY, nCurrX, nCurrY); ChuanQiUtils.WalkTo(monster, (Dircetions)Direction); monster.MoveTime = ticks; if (Global.GetTwoPointDistance(ToGrid, grid) < 2.0) { monster.Step = nStep + 1; } } } }
protected static bool RunXY1(IObject obj, int nX, int nY, Dircetions nDir, string pathStr) { bool result; if (!ChuanQiUtils.CanMove(obj, nX, nY)) { result = false; } else { Point grid = obj.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[obj.CurrentMapCode]; if (mapGrid.MoveObjectEx(nCurrX, nCurrY, nX, nY, obj)) { ChuanQiUtils.NotifyOthersMyMoving1(obj, pathStr, nCurrX, nCurrY, nX, nY, nDir); obj.CurrentGrid = new Point((double)nX, (double)nY); obj.CurrentDir = nDir; ChuanQiUtils.Notify9Grid(obj, false); result = true; } else { result = false; } } return(result); }
public static bool WalkTo(IObject obj, Dircetions nDir) { if (obj is Monster) { if (obj is Monster && (obj as Monster).IsMonsterDongJie()) { return(false); } long nowTicks = TimeUtil.NOW(); if (obj is Monster && nowTicks - (obj as Monster).LastActionTick <= (long)(obj as Monster).GetMovingNeedTick()) { return(false); } } int nX; int nY; ChuanQiUtils.WalkNextPos(obj, nDir, out nX, out nY); Point grid = obj.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; string pathStr = string.Format("{0}_{1}|{2}_{3}", new object[] { nCurrX, nCurrY, nX, nY }); bool fResult = ChuanQiUtils.WalkXY(obj, nX, nY, nDir, pathStr); if (fResult) { } return(fResult); }
/// <summary> /// 处理行走 /// </summary> public static void MonsterMoveStepLuoLanFaZhenCopySenceCopyMap(Monster monster) { long ticks = TimeUtil.NOW(); // 1秒走一步 如果体验不好 就调整之 todo... if (ticks - monster.MoveTime < (1 * 500)) { return; } int nStep = monster.Step; int nNumStep = monster.PatrolPath.Count() - 1; int nNextStep = nStep + 1; // 已经到最后一个点了 删除怪 if (nNextStep >= nNumStep) { IncreaceEscapeCount(monster.CopyMapID); GameManager.MonsterMgr.DeadMonsterImmediately(monster); return; } // 取得目标坐标的格子信息 int nMapCode = (int)monster.CurrentMapCode; MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[nMapCode]; int nNextX = monster.PatrolPath[nNextStep][0]; int nNextY = monster.PatrolPath[nNextStep][1]; int gridX = nNextX / mapGrid.MapGridWidth; int gridY = nNextY / mapGrid.MapGridHeight; Point ToGrid = new Point(gridX, gridY); Point grid = monster.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; // 取得和目标坐标的方向值 double Direction = Global.GetDirectionByAspect(gridX, gridY, nCurrX, nCurrY); // 行走 if (ChuanQiUtils.WalkTo(monster, (Dircetions)Direction) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 7) % 8)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 9) % 8)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 6) % 8)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 10) % 8)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 5) % 8)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 11) % 8))) { monster.MoveTime = ticks; } // 允许误差 if (Global.GetTwoPointDistance(ToGrid, grid) < 2) { monster.Step = nStep + 1; } }
public static bool RunTo(IObject obj, Dircetions nDir) { Point grid = obj.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; int nX = nCurrX; int nY = nCurrY; int nWalk = 2; string pathStr = string.Format("{0}_{1}", nCurrX, nCurrY); for (int i = 0; i < nWalk; i++) { switch (nDir) { case Dircetions.DR_UP: nY++; break; case Dircetions.DR_UPRIGHT: nX++; nY++; break; case Dircetions.DR_RIGHT: nX++; break; case Dircetions.DR_DOWNRIGHT: nX++; nY--; break; case Dircetions.DR_DOWN: nY--; break; case Dircetions.DR_DOWNLEFT: nX--; nY--; break; case Dircetions.DR_LEFT: nX--; break; case Dircetions.DR_UPLEFT: nX--; nY++; break; } if (!ChuanQiUtils.CanMove(obj, nX, nY)) { return(false); } pathStr += string.Format("|{0}_{1}", nX, nY); } return(ChuanQiUtils.RunXY(obj, nX, nY, nDir, pathStr)); }
/// <summary> /// 被伤害时是否被击飞 /// </summary> /// <param name="client"></param> /// <param name="enemy"></param> public static Point HitFly(GameClient client, IObject enemy, int gridNum) { bool isDead = false; if (enemy is Monster) { isDead = ((enemy as Monster).VLife <= 0); if ((int)MonsterTypes.Noraml != (enemy as Monster).MonsterType /* && (int)MonsterTypes.Rarity != (enemy as Monster).MonsterType*/) { return(new Point(-1, -1)); } } Point grid = enemy.CurrentGrid; Point selfGrid = client.CurrentGrid; int direction = (int)Global.GetDirectionByAspect((int)grid.X, (int)grid.Y, (int)selfGrid.X, (int)selfGrid.Y); // 根据传入的格子坐标和方向返回指定方向的格子列表 List <Point> gridList = Global.GetGridPointByDirection(direction, (int)grid.X, (int)grid.Y, gridNum); if (null == gridList) { return(new Point(-1, -1)); } for (int i = 0; i < gridList.Count; i++) { if (isDead) //如果死亡,就不顾及障碍物了,主要是为了血色城堡中的效果 { continue; } if (Global.InOnlyObs(enemy.ObjectType, client.ClientData.MapCode, (int)gridList[i].X, (int)gridList[i].Y)) { gridList.RemoveRange(i, gridList.Count - i); break; } } if (gridList.Count <= 0) { return(new Point(-1, -1)); } Point toGrid = gridList[gridList.Count - 1]; if (!ChuanQiUtils.TransportTo(enemy, (int)toGrid.X, (int)toGrid.Y, (Dircetions)enemy.CurrentDir, enemy.CurrentMapCode, "")) { return(new Point(-1, -1)); } return(toGrid); }
/// <summary> /// 处理行走 /// </summary> public static void MonsterMoveStepGoldCopySceneCopyMap(Monster monster) { long ticks = TimeUtil.NOW(); // 1秒走一步 如果体验不好 就调整之 todo... if (ticks - monster.MoveTime < (1 * 500)) { return; } int nStep = monster.Step; // 当前点 int nNumStep = monster.PatrolPath.Count() - 1; // 最后一个点 int nNextStep = nStep + 1; // 下一个路径点 // 已经到最后一个点了 删除怪 if (nNextStep >= nNumStep) { GameManager.MonsterMgr.AddDelayDeadMonster(monster); // 将怪物加入延迟死亡 return; } // 取得目标坐标的格子信息 int nMapCode = (int)GoldCopySceneEnum.GOLDCOPYSCENEMAPCODEID; MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[nMapCode]; int nNextX = monster.PatrolPath[nNextStep][0]; // 目标路径x int nNextY = monster.PatrolPath[nNextStep][1]; // 目标路径y // 目标格子 int gridX = nNextX / mapGrid.MapGridWidth; int gridY = nNextY / mapGrid.MapGridHeight; Point ToGrid = new Point(gridX, gridY); // 怪物当前格子 Point grid = monster.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; // 取得和目标坐标的方向值 double Direction = Global.GetDirectionByAspect(gridX, gridY, nCurrX, nCurrY); // 行走 ChuanQiUtils.WalkTo(monster, (Dircetions)Direction); monster.MoveTime = ticks; // 允许误差 if (Global.GetTwoPointDistance(ToGrid, grid) < 2) { monster.Step = nStep + 1; } }
public static Point HitFly(GameClient client, IObject enemy, int gridNum) { bool isDead = false; if (enemy is Monster) { isDead = ((enemy as Monster).VLife <= 0.0); if (101 != (enemy as Monster).MonsterType && 1001 != (enemy as Monster).MonsterType && 1801 != (enemy as Monster).MonsterType) { return(new Point(-1.0, -1.0)); } } Point grid = enemy.CurrentGrid; Point selfGrid = client.CurrentGrid; int direction = (int)Global.GetDirectionByAspect((int)grid.X, (int)grid.Y, (int)selfGrid.X, (int)selfGrid.Y); List <Point> gridList = Global.GetGridPointByDirection(direction, (int)grid.X, (int)grid.Y, gridNum); Point result; if (null == gridList) { result = new Point(-1.0, -1.0); } else { if (!isDead) { for (int i = 0; i < gridList.Count; i++) { if (Global.InOnlyObs(enemy.ObjectType, client.ClientData.MapCode, (int)gridList[i].X, (int)gridList[i].Y)) { gridList.RemoveRange(i, gridList.Count - i); break; } } if (gridList.Count <= 0) { return(new Point(-1.0, -1.0)); } } Point toGrid = gridList[gridList.Count - 1]; if (!ChuanQiUtils.TransportTo(enemy, (int)toGrid.X, (int)toGrid.Y, enemy.CurrentDir, enemy.CurrentMapCode, "")) { result = new Point(-1.0, -1.0); } else { result = toGrid; } } return(result); }
public static int NotifyInjured(SocketListener sl, TCPOutPacketPool pool, GameClient client, FakeRoleItem enemy, int burst, int injure, double injurePercent, int attackType, bool forceBurst, int addInjure, double attackPercent, int addAttackMin, int addAttackMax, double baseRate = 1.0, int addVlue = 0, int nHitFlyDistance = 0) { int ret = 0; if ((enemy as FakeRoleItem).CurrentLifeV > 0) { injure = 1000; injure = (int)((double)injure * injurePercent); ret = injure; (enemy as FakeRoleItem).CurrentLifeV -= injure; (enemy as FakeRoleItem).CurrentLifeV = Global.GMax((enemy as FakeRoleItem).CurrentLifeV, 0); int enemyLife = (enemy as FakeRoleItem).CurrentLifeV; (enemy as FakeRoleItem).AttackedRoleID = client.ClientData.RoleID; GameManager.ClientMgr.SpriteInjure2Blood(sl, pool, client, injure); (enemy as FakeRoleItem).AddAttacker(client.ClientData.RoleID, Global.GMax(0, injure)); GameManager.SystemServerEvents.AddEvent(string.Format("假人减血, Injure={0}, Life={1}", injure, enemyLife), EventLevels.Debug); if ((enemy as FakeRoleItem).CurrentLifeV <= 0) { GameManager.SystemServerEvents.AddEvent(string.Format("假人死亡, roleID={0}", (enemy as FakeRoleItem).FakeRoleID), EventLevels.Debug); FakeRoleManager.ProcessFakeRoleDead(sl, pool, client, enemy as FakeRoleItem); } Point hitToGrid = new Point(-1.0, -1.0); if (nHitFlyDistance > 0) { MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[client.ClientData.MapCode]; int nGridNum = nHitFlyDistance * 100 / mapGrid.MapGridWidth; if (nGridNum > 0) { hitToGrid = ChuanQiUtils.HitFly(client, enemy, nGridNum); } } if ((enemy as FakeRoleItem).AttackedRoleID >= 0 && (enemy as FakeRoleItem).AttackedRoleID != client.ClientData.RoleID) { GameClient findClient = GameManager.ClientMgr.FindClient((enemy as FakeRoleItem).AttackedRoleID); if (null != findClient) { GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (enemy as FakeRoleItem).FakeRoleID, 0, 0, (double)enemyLife, findClient.ClientData.Level, hitToGrid, 0, EMerlinSecretAttrType.EMSAT_None, 0); ClientManager.NotifySelfEnemyInjured(sl, pool, findClient, findClient.ClientData.RoleID, enemy.FakeRoleID, 0, 0, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0); } } GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (enemy as FakeRoleItem).FakeRoleID, burst, injure, (double)enemyLife, client.ClientData.Level, hitToGrid, 0, EMerlinSecretAttrType.EMSAT_None, 0); ClientManager.NotifySelfEnemyInjured(sl, pool, client, client.ClientData.RoleID, enemy.FakeRoleID, burst, injure, (double)enemyLife, 0L, 0, EMerlinSecretAttrType.EMSAT_None, 0); if (!client.ClientData.DisableChangeRolePurpleName) { GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client); } } return(ret); }
public static Point MonsterHitFly(Monster attacker, GameClient injurer, int gridNum) { bool isDead = false; Point attackGrid = attacker.CurrentGrid; Point injureGrid = injurer.CurrentGrid; int direction = (int)Global.GetDirectionByAspect((int)injureGrid.X, (int)injureGrid.Y, (int)attackGrid.X, (int)attackGrid.Y); List <Point> gridList = Global.GetGridPointByDirection(direction, (int)injureGrid.X, (int)injureGrid.Y, gridNum); Point result; if (null == gridList) { result = new Point(-1.0, -1.0); } else { if (!isDead) { for (int i = 0; i < gridList.Count; i++) { if (Global.InOnlyObs(attacker.ObjectType, injurer.ClientData.MapCode, (int)gridList[i].X, (int)gridList[i].Y)) { gridList.RemoveRange(i, gridList.Count - i); break; } } if (gridList.Count <= 0) { return(new Point(-1.0, -1.0)); } } Point toGrid = gridList[gridList.Count - 1]; if (!ChuanQiUtils.TransportTo(injurer, (int)toGrid.X, (int)toGrid.Y, injurer.CurrentDir, injurer.CurrentMapCode, "")) { result = new Point(-1.0, -1.0); } else { result = toGrid; } } return(result); }
public static void MonsterMoveStepEMoLaiXiCopySenceCopyMap(Monster monster) { long ticks = TimeUtil.NOW(); if (ticks - monster.MoveTime >= 500L) { int nStep = monster.Step; int nNumStep = monster.PatrolPath.Count <int[]>() - 1; int nNextStep = nStep + 1; if (nNextStep >= nNumStep) { EMoLaiXiCopySceneManager.IncreaceEscapeCount(monster.CopyMapID); GameManager.MonsterMgr.DeadMonsterImmediately(monster); } else { int nMapCode = monster.CurrentMapCode; MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[nMapCode]; int nNextX = monster.PatrolPath[nNextStep][0]; int nNextY = monster.PatrolPath[nNextStep][1]; int gridX = nNextX / mapGrid.MapGridWidth; int gridY = nNextY / mapGrid.MapGridHeight; Point ToGrid = new Point((double)gridX, (double)gridY); Point grid = monster.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; double Direction = Global.GetDirectionByAspect(gridX, gridY, nCurrX, nCurrY); if (ChuanQiUtils.WalkTo(monster, (Dircetions)Direction) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 7.0) % 8.0)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 9.0) % 8.0)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 6.0) % 8.0)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 10.0) % 8.0)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 5.0) % 8.0)) || ChuanQiUtils.WalkTo(monster, (Dircetions)((Direction + 11.0) % 8.0))) { monster.MoveTime = ticks; } if (Global.GetTwoPointDistance(ToGrid, grid) < 2.0) { monster.Step = nStep + 1; } } } }
public static bool TransportTo(IObject obj, int nX, int nY, Dircetions nDir, int oldMapCode, string pathStr = "") { Point grid = obj.CurrentGrid; int nCurrX = (int)grid.X; int nCurrY = (int)grid.Y; if (oldMapCode > 0 && oldMapCode != obj.CurrentMapCode) { MapGrid oldMapGrid = GameManager.MapGridMgr.DictGrids[oldMapCode]; if (oldMapGrid != null) { oldMapGrid.RemoveObject(obj); } nCurrX = -1; nCurrY = -1; } MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[obj.CurrentMapCode]; bool result; if (mapGrid.MoveObjectEx(nCurrX, nCurrY, nX, nY, obj)) { obj.CurrentGrid = new Point((double)nX, (double)nY); obj.CurrentDir = nDir; if (obj is Monster && (obj as Monster).MonsterType == 1001) { GameManager.MonsterMgr.ChangePosition(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, obj as Monster, (int)obj.CurrentPos.X, (int)obj.CurrentPos.Y, (int)nDir, 159, 0); } ChuanQiUtils.Notify9Grid(obj, true); result = true; } else { result = false; } return(result); }
/// <summary> /// 通知其他人被攻击(单攻),并且被伤害(同一个地图才需要通知) /// </summary> /// <param name="client"></param> public static int NotifyInjured(SocketListener sl, TCPOutPacketPool pool, GameClient client, FakeRoleItem enemy, int burst, int injure, double injurePercent, int attackType, bool forceBurst, int addInjure, double attackPercent, int addAttackMin, int addAttackMax, double baseRate = 1.0, int addVlue = 0, int nHitFlyDistance = 0) { int ret = 0; object obj = enemy; { //怪物必须或者才操作 if ((obj as FakeRoleItem).CurrentLifeV > 0) { injure = 1000; // 技能改造[3/13/2014 LiaoWei] //injure = (int)(injure * baseRate + addVlue); // 技能中可配置伤害百分比 injure = (int)(injure * injurePercent); ret = injure; (obj as FakeRoleItem).CurrentLifeV -= (int)injure; //是否需要锁定 (obj as FakeRoleItem).CurrentLifeV = Global.GMax((obj as FakeRoleItem).CurrentLifeV, 0); int enemyLife = (int)(obj as FakeRoleItem).CurrentLifeV; (obj as FakeRoleItem).AttackedRoleID = client.ClientData.RoleID; //判断是否将给敌人的伤害转化成自己的血量增长 GameManager.ClientMgr.SpriteInjure2Blood(sl, pool, client, injure); //将攻击者加入历史列表 (obj as FakeRoleItem).AddAttacker(client.ClientData.RoleID, Global.GMax(0, injure)); GameManager.SystemServerEvents.AddEvent(string.Format("假人减血, Injure={0}, Life={1}", injure, enemyLife), EventLevels.Debug); //判断怪物是否死亡 if ((int)(obj as FakeRoleItem).CurrentLifeV <= 0) { GameManager.SystemServerEvents.AddEvent(string.Format("假人死亡, roleID={0}", (obj as FakeRoleItem).FakeRoleID), EventLevels.Debug); /// 处理怪物死亡 ProcessFakeRoleDead(sl, pool, client, (obj as FakeRoleItem)); } Point hitToGrid = new Point(-1, -1); // 处理击飞 [3/15/2014 LiaoWei] if (nHitFlyDistance > 0) { MapGrid mapGrid = GameManager.MapGridMgr.DictGrids[client.ClientData.MapCode]; int nGridNum = nHitFlyDistance * 100 / mapGrid.MapGridWidth; if (nGridNum > 0) { hitToGrid = ChuanQiUtils.HitFly(client, enemy, nGridNum); } } if ((obj as FakeRoleItem).AttackedRoleID >= 0 && (obj as FakeRoleItem).AttackedRoleID != client.ClientData.RoleID) { GameClient findClient = GameManager.ClientMgr.FindClient((obj as FakeRoleItem).AttackedRoleID); if (null != findClient) { //通知其他在线客户端 GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, 0, 0, enemyLife, findClient.ClientData.Level, hitToGrid); //向自己发送敌人受伤的信息 ClientManager.NotifySelfEnemyInjured(sl, pool, findClient, findClient.ClientData.RoleID, enemy.FakeRoleID, 0, 0, enemyLife, 0); } } //通知其他在线客户端 GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, burst, injure, enemyLife, client.ClientData.Level, hitToGrid); //向自己发送敌人受伤的信息 ClientManager.NotifySelfEnemyInjured(sl, pool, client, client.ClientData.RoleID, enemy.FakeRoleID, burst, injure, enemyLife, 0); //通知紫名信息(限制当前地图) if (!client.ClientData.DisableChangeRolePurpleName) { GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client); } } } return(ret); }
public static bool CanMove(IObject obj, int nX, int nY) { bool result; if (obj is Monster && (obj as Monster).CopyMapID > 0) { Monster monsterObj = obj as Monster; result = (monsterObj.CurrentMapCode == 5100 || (1502 == monsterObj.MonsterType && monsterObj.Tag is CompMineTruckConfig) || ChuanQiUtils.CanMonsterMoveOnCopyMap(monsterObj, nX, nY)); } else { result = !Global.InObsByGridXY(obj.ObjectType, obj.CurrentMapCode, nX, nY, 0, 0); } return(result); }