public static void ProcessFakeRoleGoBack(int FakeRoleID) { FakeRoleItem fakeRoleItem = FakeRoleManager.FindFakeRoleByID(FakeRoleID); if (null != fakeRoleItem) { GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, fakeRoleItem); int toMapCode = fakeRoleItem.CurrentMapCode; GameMap gameMap = null; if (GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap)) { int defaultBirthPosX = gameMap.DefaultBirthPosX; int defaultBirthPosY = gameMap.DefaultBirthPosY; int defaultBirthRadius = gameMap.BirthRadius; Point newPos = Global.GetMapPoint(ObjectTypes.OT_FAKEROLE, toMapCode, defaultBirthPosX, defaultBirthPosY, defaultBirthRadius); int toMapX = (int)newPos.X; int toMapY = (int)newPos.Y; int oldX = fakeRoleItem.MyRoleDataMini.PosX; int oldY = fakeRoleItem.MyRoleDataMini.PosY; fakeRoleItem.MyRoleDataMini.PosX = toMapX; fakeRoleItem.MyRoleDataMini.PosY = toMapY; fakeRoleItem.MyRoleDataMini.LifeV = fakeRoleItem.MyRoleDataMini.MaxLifeV; GameManager.MapGridMgr.DictGrids[toMapCode].MoveObject(oldX, oldY, toMapX, toMapY, fakeRoleItem); } } }
private static FakeRoleItem AddFakeRole(RoleData4Selector clientData, FakeRoleTypes fakeRoleType) { FakeRoleItem result; if (null == clientData) { result = null; } else { FakeRoleItem fakeRoleItem = new FakeRoleItem { FakeRoleID = (int)GameManager.FakeRoleIDMgr.GetNewID(), FakeRoleType = (int)fakeRoleType, MyRoleDataMini = RoleManager.getInstance().GetRoleDataMiniFromRoleData4Selector(clientData) }; lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict[fakeRoleItem.FakeRoleID] = fakeRoleItem; } string roleID_Type = string.Format("{0}_{1}", fakeRoleItem.MyRoleDataMini.RoleID, (int)fakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict[roleID_Type] = fakeRoleItem; } result = fakeRoleItem; } return(result); }
/// <summary> /// 处理已经假人的超时 /// </summary> /// <param name="client"></param> public static void ProcessAllFakeRoleItems(SocketListener sl, TCPOutPacketPool pool) { List <FakeRoleItem> FakeRoleItemList = new List <FakeRoleItem>(); lock (_ID2FakeRoleDict) { foreach (var val in _ID2FakeRoleDict.Values) { FakeRoleItemList.Add(val); } } long nowTicks = TimeUtil.NOW(); FakeRoleItem FakeRoleItem = null; for (int i = 0; i < FakeRoleItemList.Count; i++) { FakeRoleItem = FakeRoleItemList[i]; //处理假人的死亡 if (ProcessFakeRoleDead(sl, pool, nowTicks, FakeRoleItem)) { continue; } } }
/// <summary> /// 删除自己哪儿的假人 /// </summary> /// <param name="client"></param> public static void DelMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <Object> objsList) { if (null == objsList) { return; } FakeRoleItem fakeRoleItem = null; for (int i = 0; i < objsList.Count; i++) { fakeRoleItem = objsList[i] as FakeRoleItem; if (null == fakeRoleItem) { continue; } if (!GameManager.TestGameShowFakeRoleForUser && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang2 && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang3) { continue; } GameManager.ClientMgr.NotifyMySelfDelFakeRole(sl, pool, client, fakeRoleItem.FakeRoleID); } }
public static void SendMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <object> objsList, int totalRoleAndMonsterNum) { if (null != objsList) { for (int i = 0; i < objsList.Count; i++) { FakeRoleItem fakeRoleItem = objsList[i] as FakeRoleItem; if (null != fakeRoleItem) { if (GameManager.TestGameShowFakeRoleForUser || (fakeRoleItem.FakeRoleType != 1 && fakeRoleItem.FakeRoleType != 2)) { if (fakeRoleItem.CurrentLifeV > 0) { if (totalRoleAndMonsterNum >= 30) { if (fakeRoleItem.FakeRoleType == 2) { goto IL_A0; } } GameManager.ClientMgr.NotifyMySelfNewFakeRole(sl, pool, client, fakeRoleItem); } } } IL_A0 :; } } }
/// <summary> /// 处理添加假人 /// </summary> public static int ProcessNewFakeRole(SafeClientData clientData, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1) { int mapCode = clientData.MapCode; if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode)) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID)); return(-1); } //删除一个假人数据 RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType); //添加一个新的假人数据 FakeRoleItem fakeRoleItem = AddFakeRole(clientData, fakeRoleType); if (null == fakeRoleItem) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID)); return(-1); } if (toPosX >= 0 && toPosY >= 0) { fakeRoleItem.MyRoleDataMini.PosX = toPosX; fakeRoleItem.MyRoleDataMini.PosY = toPosY; } if (direction >= 0) { fakeRoleItem.MyRoleDataMini.RoleDirection = direction; } if (ToExtensionID >= 0) { fakeRoleItem.ToExtensionID = ToExtensionID; } if (FakeRoleTypes.LiXianGuaJi == fakeRoleType) { if (clientData.OfflineMarketState <= 0) { fakeRoleItem.MyRoleDataMini.StallName = ""; } } fakeRoleItem.MyRoleDataMini.LifeV = Math.Max(1, clientData.LifeV); fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV); GameManager.MapGridMgr.DictGrids[clientData.MapCode].MoveObject(-1, -1, (int)fakeRoleItem.MyRoleDataMini.PosX, (int)fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersNewFakeRole(sl, pool, objList, FakeRoleItem); return(fakeRoleItem.FakeRoleID); }
public static void ProcessDelFakeRole(int roleID, FakeRoleTypes fakeRoleType) { FakeRoleItem FakeRoleItem = FakeRoleManager.FindFakeRoleByRoleIDType(roleID, fakeRoleType); if (null != FakeRoleItem) { FakeRoleManager.RemoveFakeRole(FakeRoleItem.FakeRoleID); GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); } }
public static FakeRoleItem FindFakeRoleByID(int FakeRoleID) { FakeRoleItem FakeRoleItem = null; lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict.TryGetValue(FakeRoleID, out FakeRoleItem); } return(FakeRoleItem); }
public static FakeRoleItem FindFakeRoleByRoleIDType(int roleID, FakeRoleTypes fakeRoleType) { FakeRoleItem fakeRoleItem = null; string roleID_Type = string.Format("{0}_{1}", roleID, (int)fakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict.TryGetValue(roleID_Type, out fakeRoleItem); } return(fakeRoleItem); }
public static void ProcessDelFakeRole(int FakeRoleID, bool bBroadcastDelMsg = false) { FakeRoleItem FakeRoleItem = FakeRoleManager.FindFakeRoleByID(FakeRoleID); if (null != FakeRoleItem) { FakeRoleManager.RemoveFakeRole(FakeRoleID); GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); if (bBroadcastDelMsg) { GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, FakeRoleItem); } } }
/// <summary> /// 处理删除假人 /// </summary> public static void ProcessDelFakeRole(int roleID, FakeRoleTypes fakeRoleType) { FakeRoleItem FakeRoleItem = FindFakeRoleByRoleIDType(roleID, fakeRoleType); if (null == FakeRoleItem) { return; } RemoveFakeRole(FakeRoleItem.FakeRoleID); GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersDelFakeRole(sl, pool, objList, FakeRoleID); }
public static void DelMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <object> objsList) { if (null != objsList) { for (int i = 0; i < objsList.Count; i++) { FakeRoleItem fakeRoleItem = objsList[i] as FakeRoleItem; if (null != fakeRoleItem) { if (GameManager.TestGameShowFakeRoleForUser || (fakeRoleItem.FakeRoleType != 1 && fakeRoleItem.FakeRoleType != 2)) { GameManager.ClientMgr.NotifyMySelfDelFakeRole(sl, pool, client, fakeRoleItem.FakeRoleID); } } } } }
/// <summary> /// 是否能被攻击 /// </summary> /// <param name="enemy"></param> /// <returns></returns> public static bool CanAttack(FakeRoleItem enemy) { if (GameManager.TestGameShowFakeRoleForUser) { return(false); } if (null == enemy) { return(false); } if (enemy.GetFakeRoleData().FakeRoleType != (int)FakeRoleTypes.LiXianGuaJi) //不是离线挂机的假人不能攻击 { return(false); } return(true); }
/// <summary> /// 处理假人回城 /// </summary> public static void ProcessFakeRoleGoBack(int FakeRoleID) { FakeRoleItem fakeRoleItem = FindFakeRoleByID(FakeRoleID); if (null == fakeRoleItem) { return; } GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, fakeRoleItem); int toMapCode = fakeRoleItem.CurrentMapCode; GameMap gameMap = null; if (!GameManager.MapMgr.DictMaps.TryGetValue(toMapCode, out gameMap)) //确认地图编号是否有效 { return; } int defaultBirthPosX = gameMap.DefaultBirthPosX; int defaultBirthPosY = gameMap.DefaultBirthPosY; int defaultBirthRadius = gameMap.BirthRadius; //从配置根据地图取默认位置 Point newPos = Global.GetMapPoint(ObjectTypes.OT_FAKEROLE, toMapCode, defaultBirthPosX, defaultBirthPosY, defaultBirthRadius); //从配置根据地图取默认位置 int toMapX = (int)newPos.X; int toMapY = (int)newPos.Y; int oldX = fakeRoleItem.MyRoleDataMini.PosX; int oldY = fakeRoleItem.MyRoleDataMini.PosY; fakeRoleItem.MyRoleDataMini.PosX = toMapX; fakeRoleItem.MyRoleDataMini.PosY = toMapY; fakeRoleItem.MyRoleDataMini.LifeV = fakeRoleItem.MyRoleDataMini.MaxLifeV; GameManager.MapGridMgr.DictGrids[toMapCode].MoveObject(oldX, oldY, toMapX, toMapY, fakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersDelFakeRole(sl, pool, objList, FakeRoleID); }
/// <summary> /// 处理删除假人 /// </summary> public static void ProcessDelFakeRole(int FakeRoleID, bool bBroadcastDelMsg = false) { FakeRoleItem FakeRoleItem = FindFakeRoleByID(FakeRoleID); if (null == FakeRoleItem) { return; } RemoveFakeRole(FakeRoleID); GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); if (bBroadcastDelMsg) { GameManager.ClientMgr.NotifyAllDelFakeRole(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, FakeRoleItem); } //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersDelFakeRole(sl, pool, objList, FakeRoleID); }
private static void RemoveFakeRole(int FakeRoleID) { FakeRoleItem fakeRoleItem = null; lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict.TryGetValue(FakeRoleID, out fakeRoleItem); if (null != fakeRoleItem) { FakeRoleManager._ID2FakeRoleDict.Remove(fakeRoleItem.FakeRoleID); } } if (null != fakeRoleItem) { string roleID_Type = string.Format("{0}_{1}", fakeRoleItem.MyRoleDataMini.RoleID, fakeRoleItem.FakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict.Remove(roleID_Type); } } }
private static void RemoveFakeRoleByRoleIDType(int roleID, FakeRoleTypes fakeRoleType) { FakeRoleItem fakeRoleItem = null; string roleID_Type = string.Format("{0}_{1}", roleID, (int)fakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict.TryGetValue(roleID_Type, out fakeRoleItem); if (null != fakeRoleItem) { FakeRoleManager._RoleIDType2FakeRoleDict.Remove(roleID_Type); } } if (null != fakeRoleItem) { lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict.Remove(fakeRoleItem.FakeRoleID); } } }
public static void ProcessAllFakeRoleItems(SocketListener sl, TCPOutPacketPool pool) { List <FakeRoleItem> FakeRoleItemList = new List <FakeRoleItem>(); lock (FakeRoleManager._ID2FakeRoleDict) { foreach (FakeRoleItem val in FakeRoleManager._ID2FakeRoleDict.Values) { FakeRoleItemList.Add(val); } } long nowTicks = TimeUtil.NOW(); for (int i = 0; i < FakeRoleItemList.Count; i++) { FakeRoleItem FakeRoleItem = FakeRoleItemList[i]; if (FakeRoleManager.ProcessFakeRoleDead(sl, pool, nowTicks, FakeRoleItem)) { } } }
private static FakeRoleItem AddFakeRole(SafeClientData clientData, FakeRoleTypes fakeRoleType) { FakeRoleItem fakeRoleItem = new FakeRoleItem { FakeRoleID = (int)GameManager.FakeRoleIDMgr.GetNewID(), FakeRoleType = (int)fakeRoleType, MyRoleDataMini = Global.ClientDataToRoleDataMini(clientData) }; lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict[fakeRoleItem.FakeRoleID] = fakeRoleItem; } string roleID_Type = string.Format("{0}_{1}", fakeRoleItem.MyRoleDataMini.RoleID, (int)fakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict[roleID_Type] = fakeRoleItem; } return(fakeRoleItem); }
public static int ProcessNewFakeRole(RoleData4Selector clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1) { int result; if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode)) { LogManager.WriteLog(LogTypes.Error, string.Format("生成雕像目标地图不存在, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true); result = -1; } else { FakeRoleManager.RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType); FakeRoleItem fakeRoleItem = FakeRoleManager.AddFakeRole(clientData, fakeRoleType); if (null == fakeRoleItem) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true); result = -1; } else { fakeRoleItem.MyRoleDataMini.MapCode = mapCode; if (toPosX >= 0 && toPosY >= 0) { fakeRoleItem.MyRoleDataMini.PosX = toPosX; fakeRoleItem.MyRoleDataMini.PosY = toPosY; } if (direction >= 0) { fakeRoleItem.MyRoleDataMini.RoleDirection = direction; } if (ToExtensionID >= 0) { fakeRoleItem.ToExtensionID = ToExtensionID; } GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, fakeRoleItem.MyRoleDataMini.PosX, fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem); result = fakeRoleItem.FakeRoleID; } } return(result); }
/// <summary> /// 发送假人到给自己 /// </summary> /// <param name="client"></param> public static void SendMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <Object> objsList, int totalRoleAndMonsterNum) { if (null == objsList) { return; } FakeRoleItem fakeRoleItem = null; for (int i = 0; i < objsList.Count; i++) { fakeRoleItem = objsList[i] as FakeRoleItem; if (null == fakeRoleItem) { continue; } if (!GameManager.TestGameShowFakeRoleForUser && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang2 && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang3 && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.CoupleWishMan && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.CoupleWishWife) { continue; } if (fakeRoleItem.CurrentLifeV <= 0) { continue; } if (totalRoleAndMonsterNum >= 30) { if (fakeRoleItem.FakeRoleType == (int)FakeRoleTypes.LiXianGuaJi) { continue; } } GameManager.ClientMgr.NotifyMySelfNewFakeRole(sl, pool, client, fakeRoleItem); } }
/// <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 CanAttack(FakeRoleItem enemy) { return(!GameManager.TestGameShowFakeRoleForUser && null != enemy && enemy.GetFakeRoleData().FakeRoleType == 2); }
/// <summary> /// 通知所有人隐藏假人 /// </summary> public static void NotifyOthersHideFakeRole(SocketListener sl, TCPOutPacketPool pool, FakeRoleItem FakeRoleItem) { if (null == FakeRoleItem) { return; } GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersDelFakeRole(sl, pool, objList, FakeRoleItem.FakeRoleID); }
/// <summary> /// 处理假人的死亡 /// </summary> /// <param name="sl"></param> /// <param name="pool"></param> /// <param name="FakeRoleItem"></param> /// <returns></returns> private static bool ProcessFakeRoleDead(SocketListener sl, TCPOutPacketPool pool, long nowTicks, FakeRoleItem fakeRoleItem) { if (fakeRoleItem.CurrentLifeV > 0) { return(false); } long subTicks = nowTicks - fakeRoleItem.FakeRoleDeadTicks; //如果还没到时间,则跳过 if (subTicks < (2 * 1000)) { return(false); } ProcessFakeRoleGoBack(fakeRoleItem.FakeRoleID); return(true); }
/// <summary> /// 通知所有人显示假人 /// </summary> public static void NotifyOthersShowFakeRole(SocketListener sl, TCPOutPacketPool pool, FakeRoleItem FakeRoleItem) { if (null == FakeRoleItem) { return; } GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, (int)FakeRoleItem.MyRoleDataMini.PosX, (int)FakeRoleItem.MyRoleDataMini.PosY, FakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersNewFakeRole(sl, pool, objList, FakeRoleItem); }
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); }
/// <summary> /// 处理假人死亡 /// </summary> /// <param name="sl"></param> /// <param name="pool"></param> /// <param name="client"></param> /// <param name="enemy"></param> private static void ProcessFakeRoleDead(SocketListener sl, TCPOutPacketPool pool, GameClient client, FakeRoleItem fakeRoleItem) { if (fakeRoleItem.HandledDead) { return; } fakeRoleItem.HandledDead = true; fakeRoleItem.FakeRoleDeadTicks = TimeUtil.NOW(); int ownerRoleID = fakeRoleItem.GetAttackerFromList(); //根据血量计算 if (ownerRoleID >= 0 && ownerRoleID != client.ClientData.RoleID) { GameClient findClient = GameManager.ClientMgr.FindClient(ownerRoleID); if (null != findClient) { client = findClient; } } }
private static bool ProcessFakeRoleDead(SocketListener sl, TCPOutPacketPool pool, long nowTicks, FakeRoleItem fakeRoleItem) { bool result; if (fakeRoleItem.CurrentLifeV > 0) { result = false; } else { long subTicks = nowTicks - fakeRoleItem.FakeRoleDeadTicks; if (subTicks < 2000L) { result = false; } else { FakeRoleManager.ProcessFakeRoleGoBack(fakeRoleItem.FakeRoleID); result = true; } } return(result); }
/// <summary> /// 处理添加假人 /// </summary> public static int ProcessNewFakeRole(SafeClientData clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1) { if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode)) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID离线挂机时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID)); return(-1); } //删除一个假人数据 RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType); //添加一个新的假人数据 FakeRoleItem fakeRoleItem = AddFakeRole(clientData, fakeRoleType); if (null == fakeRoleItem) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", clientData.MapCode, clientData.RoleID)); return(-1); } fakeRoleItem.MyRoleDataMini.MapCode = mapCode; if (toPosX >= 0 && toPosY >= 0) { fakeRoleItem.MyRoleDataMini.PosX = toPosX; fakeRoleItem.MyRoleDataMini.PosY = toPosY; } if (direction >= 0) { fakeRoleItem.MyRoleDataMini.RoleDirection = direction; } if (ToExtensionID >= 0) { fakeRoleItem.ToExtensionID = ToExtensionID; } if (FakeRoleTypes.LiXianGuaJi == fakeRoleType) { if (clientData.OfflineMarketState <= 0) { fakeRoleItem.MyRoleDataMini.StallName = ""; } } if (FakeRoleTypes.DiaoXiang2 == fakeRoleType) { if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams || fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count <= 0) { int fashionID = 0; foreach (var item in FashionManager.getInstance().RuntimeData.FashingDict.Values) { if (item.Type == (int)FashionTypes.LuoLanYuYi) { fashionID = item.ID; break; } } if (null == fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams) { fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams = new List <int>(); } for (int i = fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Count; i < (int)RoleCommonUseIntParamsIndexs.MaxCount; ++i) { fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams.Add(0); } fakeRoleItem.MyRoleDataMini.RoleCommonUseIntPamams[(int)RoleCommonUseIntParamsIndexs.FashionWingsID] = fashionID; } } fakeRoleItem.MyRoleDataMini.LifeV = Math.Max(1, clientData.LifeV); fakeRoleItem.MyRoleDataMini.MagicV = Math.Max(1, clientData.MagicV); GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, (int)fakeRoleItem.MyRoleDataMini.PosX, (int)fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem); //List<Object> objList = Global.GetAll9Clients(FakeRoleItem); //GameManager.ClientMgr.NotifyOthersNewFakeRole(sl, pool, objList, FakeRoleItem); return(fakeRoleItem.FakeRoleID); }