private void OnAppendImpact(CharacterInfo target, int impactid, int senderid, Vector3 pos, float dir) { Msg_CRC_SendImpactToEntity msg = new Msg_CRC_SendImpactToEntity(); msg.target_id = target.GetId(); msg.sender_id = senderid; msg.sender_pos = new Position3D(); msg.sender_pos.x = pos.X; msg.sender_pos.y = pos.Y; msg.sender_pos.z = pos.Z; msg.sender_dir = dir; msg.impact_id = impactid; msg.hit_count = 0; msg.skill_id = -1; LogSys.Log(LOG_TYPE.DEBUG, "---on append impact send Msg_CRC_SendImpactToEntity"); for (LinkedListNode <UserInfo> linkNode = target.UserManager.Users.FirstValue; null != linkNode; linkNode = linkNode.Next) { UserInfo info = linkNode.Value; if (null != info && null != info.CustomData) { User u = info.CustomData as User; if (null != u) { LogSys.Log(LOG_TYPE.DEBUG, "---on append impact send Msg_CRC_SendImpactToEntity to " + u.GetKey()); u.SendMessage(msg); } } } }
internal static void Execute(object msg, NetConnection conn, NetworkSystem networkSystem) { Msg_CRC_SendImpactToEntity message = msg as Msg_CRC_SendImpactToEntity; if (null == message) { return; } }
internal static Msg_CRC_SendImpactToEntity BuildSendImpactToEntityMessage(int senderId, int targetId, int impactId, int skillId) { Msg_CRC_SendImpactToEntity bd = new Msg_CRC_SendImpactToEntity(); bd.sender_id = senderId; bd.target_id = targetId; bd.impact_id = impactId; bd.skill_id = skillId; return(bd); }
internal static void Execute(object msg, RoomPeer peer) { Msg_CRC_SendImpactToEntity _msg = msg as Msg_CRC_SendImpactToEntity; if (null == _msg) { return; } peer.BroadCastMsgToRoom(_msg); }
internal static void SyncBuffListToUser(CharacterInfo obj, User user) { List <ImpactInfo> impacts = obj.GetSkillStateInfo().GetAllImpact(); foreach (ImpactInfo info in impacts) { if (info.m_ImpactType == (int)ImpactType.BUFF) { Msg_CRC_SendImpactToEntity bd = BuildSendImpactToEntityMessage(info.m_ImpactSenderId, obj.GetId(), info.m_ImpactId, info.m_SkillId); user.SendMessage(bd); } } }
internal static void SyncBuffListToObservers(CharacterInfo obj, Scene scene) { List <ImpactInfo> impacts = obj.GetSkillStateInfo().GetAllImpact(); foreach (ImpactInfo info in impacts) { if (info.m_ImpactType == (int)ImpactType.BUFF) { Msg_CRC_SendImpactToEntity bd = BuildSendImpactToEntityMessage(info.m_ImpactSenderId, obj.GetId(), info.m_ImpactId, info.m_SkillId); scene.NotifyAllObserver(bd); } } }
internal static void SyncBuffListToCaredUsers(CharacterInfo obj) { Scene scene = obj.SceneContext.CustomData as Scene; if (null != scene) { List <ImpactInfo> impacts = obj.GetSkillStateInfo().GetAllImpact(); foreach (ImpactInfo info in impacts) { if (info.m_ImpactType == (int)ImpactType.BUFF) { Msg_CRC_SendImpactToEntity bd = BuildSendImpactToEntityMessage(info.m_ImpactSenderId, obj.GetId(), info.m_ImpactId, info.m_SkillId); scene.NotifyAreaUser(obj, bd, false); } } } }
private void OnNpcImpact(NpcInfo npc, int impactId) { Scene scene = npc.SceneContext.CustomData as Scene; if (null != scene) { Msg_CRC_SendImpactToEntity sendImpactBuilder = new Msg_CRC_SendImpactToEntity(); sendImpactBuilder.duration = -1; sendImpactBuilder.impact_id = impactId; sendImpactBuilder.sender_dir = npc.GetMovementStateInfo().GetFaceDir(); sendImpactBuilder.sender_id = npc.GetId(); Vector3 pos = npc.GetMovementStateInfo().GetPosition3D(); sendImpactBuilder.sender_pos = new Position3D(); sendImpactBuilder.sender_pos.x = pos.X; sendImpactBuilder.sender_pos.y = pos.Y; sendImpactBuilder.sender_pos.z = pos.Z; sendImpactBuilder.skill_id = -1; sendImpactBuilder.target_id = npc.GetId(); scene.NotifyAreaUser(npc, sendImpactBuilder); } }
internal void SyncSendImpact(int senderId, int impactId, int targetId, int skillId, int duration, float senderPosX, float senderPosY, float senderPosZ, float senderDir) { Msg_CRC_SendImpactToEntity bd = new Msg_CRC_SendImpactToEntity(); bd.sender_id = senderId; bd.impact_id = impactId; bd.target_id = targetId; bd.skill_id = skillId; bd.duration = duration; bd.sender_pos = new Position3D(); bd.sender_pos.x = senderPosX; bd.sender_pos.y = senderPosY; bd.sender_pos.z = senderPosZ; bd.sender_dir = senderDir; SendMessage(bd); }
internal void SyncSendImpact(CharacterInfo sender, int impactId, int targetId, int skillId, int duration, Vector3 senderPos, float senderDir, int hit_count) { Msg_CRC_SendImpactToEntity bd = new Msg_CRC_SendImpactToEntity(); bd.sender_id = sender.GetId(); bd.impact_id = impactId; bd.target_id = targetId; bd.skill_id = skillId; bd.duration = duration; bd.sender_pos = new Position3D(); bd.sender_pos.x = senderPos.X; bd.sender_pos.y = senderPos.Y; bd.sender_pos.z = senderPos.Z; bd.sender_dir = senderDir; bd.hit_count = hit_count; SendMessage(bd); }
internal static void Execute(object msg, User user) { Msg_CRC_SendImpactToEntity impact_msg = msg as Msg_CRC_SendImpactToEntity; if (null != impact_msg) { Scene scene = user.OwnRoom.GetActiveScene(); if (null != scene) { CharacterInfo character = scene.SceneContext.GetCharacterInfoById(impact_msg.sender_id); if (null != character && (character.OwnerId == user.RoleId || impact_msg.sender_id == user.RoleId)) { //校验 Vector3 senderPos = new Vector3(impact_msg.sender_pos.x, impact_msg.sender_pos.y, impact_msg.sender_pos.z); SkillInfo skillInfo = character.GetSkillStateInfo().GetSkillInfoById(impact_msg.skill_id); if (null != skillInfo && null != skillInfo.m_EnableImpactsToMyself && null != skillInfo.m_EnableImpactsToOther) { //LogSys.Log(LOG_TYPE.DEBUG, "----update hit count to " + impact_msg.hit_count); UpdateCharacterHitCount(character, impact_msg.hit_count); bool isSend = false; if (impact_msg.sender_id == impact_msg.target_id) { if (skillInfo.m_LeftEnableImpactsToMyself.Contains(impact_msg.impact_id)) {//给自己发impact skillInfo.m_LeftEnableImpactsToOther.Remove(impact_msg.impact_id); ImpactSystem.Instance.SendImpactToCharacter(character, impact_msg.impact_id, impact_msg.target_id, impact_msg.skill_id, impact_msg.duration, senderPos, impact_msg.sender_dir); isSend = true; //LogSys.Log(LOG_TYPE.WARN, "SendImpactToEntityHandler, send impact {0} to charactor {1}, leftImpacts:{2} skill:{3}", impact_msg.impact_id, impact_msg.target_id, string.Join<int>(",", skillInfo.m_LeftEnableImpactsToMyself), impact_msg.skill_id); } else { LogSys.Log(LOG_TYPE.ERROR, "SendImpactToEntityHandler, can't send impact {0} to charactor {1}, leftImpacts:{2} skill:{3}", impact_msg.impact_id, impact_msg.target_id, string.Join <int>(",", skillInfo.m_LeftEnableImpactsToMyself), impact_msg.skill_id); } } else {//给别人发impact List <int> leftImpacts; if (!skillInfo.m_LeftEnableImpactsToOther.TryGetValue(impact_msg.target_id, out leftImpacts)) { leftImpacts = new List <int>(); leftImpacts.AddRange(skillInfo.m_EnableImpactsToOther); if (TimeUtility.GetServerMilliseconds() <= character.GetSkillStateInfo().SimulateEndTime) { leftImpacts.AddRange(skillInfo.m_EnableImpactsToOther); } skillInfo.m_LeftEnableImpactsToOther.Add(impact_msg.target_id, leftImpacts); } if (null != leftImpacts && leftImpacts.Contains(impact_msg.impact_id)) { leftImpacts.Remove(impact_msg.impact_id); ImpactSystem.Instance.SendImpactToCharacter(character, impact_msg.impact_id, impact_msg.target_id, impact_msg.skill_id, impact_msg.duration, senderPos, impact_msg.sender_dir); isSend = true; //LogSys.Log(LOG_TYPE.WARN, "SendImpactToEntityHandler, send impact {0} to charactor {1}, leftImpacts:{2} skill:{3}", impact_msg.impact_id, impact_msg.target_id, string.Join<int>(",", leftImpacts), impact_msg.skill_id); } else { LogSys.Log(LOG_TYPE.ERROR, "SendImpactToEntityHandler, can't send impact {0} to charactor {1}, leftImpacts:{2} skill:{3}", impact_msg.impact_id, impact_msg.target_id, string.Join <int>(",", leftImpacts), impact_msg.skill_id); } } if (!isSend) { //todo:记录违规次数 } } else { LogSys.Log(LOG_TYPE.WARN, "SendImpactToEntityHandler, can't add impact!!"); } } else { if (null == character) { LogSys.Log(LOG_TYPE.ERROR, "SendImpactToEntityHandler, charactor {0} not exist", impact_msg.target_id); } else { LogSys.Log(LOG_TYPE.ERROR, "SendImpactToEntityHandler, charactor {0} or owner {1} not user {2}", character.GetId(), character.OwnerId, user.RoleId); } } } } }