public void SendImpactToCharacter(CharacterInfo sender, int impactId, int targetId) { //LogSystem.Debug("character {0} send impact {1} to character {2}", sender.GetId(), impactId, targetId); if (null != sender) { CharacterInfo target = sender.SceneContext.GetCharacterInfoById(targetId); if (null != target) { ImpactLogicData impactLogicData = (ImpactLogicData)SkillConfigProvider.Instance.ExtractData(SkillConfigType.SCT_IMPACT, impactId); if (null != impactLogicData) { IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(impactLogicData.ImpactLogicId); if (null != logic) { ImpactInfo impactInfo = new ImpactInfo(); impactInfo.m_IsActivated = true; impactInfo.m_ImpactId = impactLogicData.ImpactId; impactInfo.ConfigData = impactLogicData; impactInfo.m_StartTime = TimeUtility.GetServerMilliseconds(); impactInfo.m_ImpactDuration = impactLogicData.ImpactTime; impactInfo.m_ImpactSenderId = sender.GetId(); impactInfo.m_HasEffectApplyed = false; target.GetSkillStateInfo().AddImpact(impactInfo); } } } } }
public void RemoveImpact(int impactId) { ImpactInfo oriImpact = GetImpactInfoById(impactId); if (oriImpact != null) { if ((int)ImpactType.BUFF == oriImpact.m_ImpactType) { m_BuffChanged = true; } m_ImpactList.Remove(oriImpact); } }
private void IdleHandler(NpcInfo npc, AiCommandDispatcher aiCmdDispatcher, long deltaTime) { if (npc.IsDead()) { return; } NpcAiStateInfo info = npc.GetAiStateInfo(); AiData_PveNpc_Trap data = GetAiData(npc); if (null != data) { info.Time += deltaTime; if (info.Time > 100) { info.Time = 0; if (data.HideImpact > 0) { ImpactInfo impactInfo = npc.GetSkillStateInfo().GetImpactInfoById(data.HideImpact); if (null == impactInfo) { ServerNpcImpact(npc, data.HideImpact, npc); } } IList <ISpaceObject> objs = npc.SpatialSystem.GetObjectInCircle(npc.GetMovementStateInfo().GetPosition3D(), data.RadiusOfTrigger); foreach (ISpaceObject obj in objs) { if (obj.GetObjType() == SpatialObjType.kNPC || obj.GetObjType() == SpatialObjType.kUser) { CharacterInfo charInfo = obj.RealObject as CharacterInfo; if (null != charInfo) { if (CharacterInfo.GetRelation(npc, charInfo) == CharacterRelation.RELATION_ENEMY) { info.Time = 0; info.Target = charInfo.GetId(); ChangeToState(npc, (int)AiStateId.Combat); NotifyNpcTargetChange(npc); break; } } } } } } }
public void AddImpact(ImpactInfo info) { ImpactInfo oriImpact = GetImpactInfoById(info.m_ImpactId); if (oriImpact == null) { m_ImpactList.Add(info); } else { m_ImpactList.Remove(oriImpact); m_ImpactList.Add(info); } if ((int)ImpactType.BUFF == info.m_ImpactType) { m_BuffChanged = true; } }
public void Tick(CharacterInfo character, int impactId) { ImpactInfo impactInfo = character.GetSkillStateInfo().GetImpactInfoById(impactId); if (null != impactInfo) { if (impactInfo.m_IsActivated) { float damageDelayTime = float.Parse(impactInfo.ConfigData.ExtraParams[0]); if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + damageDelayTime * 1000 && !impactInfo.m_HasEffectApplyed) { int damage = int.Parse(impactInfo.ConfigData.ExtraParams[1]); if (!character.IsHaveStateFlag(CharacterState_Type.CST_Invincible)) { ApplyDamage(impactInfo.m_ImpactSenderId, character, damage); } impactInfo.m_HasEffectApplyed = true; if (impactInfo.ConfigData.ExtraParams.Count >= 3) { int rage = int.Parse(impactInfo.ConfigData.ExtraParams[2]); if (character.IsUser) { character.SetRage(Operate_Type.OT_Relative, rage); } else { CharacterInfo user = character.SceneContext.GetCharacterInfoById(impactInfo.m_ImpactSenderId); if (user != null && user.IsUser) { user.SetRage(Operate_Type.OT_Relative, rage); } } } } if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + impactInfo.m_ImpactDuration) { impactInfo.m_IsActivated = false; } } } }
public void Tick(CharacterInfo obj) { List <ImpactInfo> impactInfos = obj.GetSkillStateInfo().GetAllImpact(); int ct = impactInfos.Count; for (int i = ct - 1; i >= 0; --i) { ImpactInfo info = impactInfos[i]; IImpactLogic logic = ImpactLogicManager.Instance.GetImpactLogic(info.ConfigData.ImpactLogicId); if (info.m_IsActivated) { if (null != logic) { logic.Tick(obj, info.m_ImpactId); } } else { obj.GetSkillStateInfo().RemoveImpact(info.m_ImpactId); } } }
public void Tick(CharacterInfo character, int impactId) { ImpactInfo impactInfo = character.GetSkillStateInfo().GetImpactInfoById(impactId); if (null == impactInfo) { return; } if (!impactInfo.m_IsActivated) { return; } if (!impactInfo.m_HasEffectApplyed) { character.SetStateFlag(Operate_Type.OT_AddBit, CharacterState_Type.CST_Invincible); impactInfo.m_HasEffectApplyed = true; } if (TimeUtility.GetServerMilliseconds() > impactInfo.m_StartTime + impactInfo.m_ImpactDuration) { character.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); impactInfo.m_IsActivated = false; } }
internal static void Execute(object msg, User user) { Msg_CRC_GfxControlMoveStop _msg = msg as Msg_CRC_GfxControlMoveStop; if (_msg == null) { return; } Scene scene = user.OwnRoom.GetActiveScene(); if (null != scene) { CharacterInfo info = scene.SceneContext.GetCharacterInfoById(_msg.obj_id); if (null != info && (_msg.obj_id == user.RoleId || info.OwnerId == user.RoleId)) { MovementStateInfo msi = info.GetMovementStateInfo(); Vector3 pos; if (_msg.obj_id == user.RoleId) { pos = user.LastClientPosition; } else { pos = msi.GetPosition3D(); } Vector3 newPos = new Vector3(_msg.target_pos.x, 0, _msg.target_pos.z); msi.IsSkillMoving = false; bool enableControl = false; if (_msg.is_skill) { SkillInfo skillInfo = info.GetSkillStateInfo().GetSkillInfoById(_msg.skill_or_impact_id); float distance = Geometry.Distance(pos, newPos); if (null != skillInfo && (skillInfo.m_LeftEnableMoveCount > 0 || distance <= 0.3)) { //校验 --skillInfo.m_LeftEnableMoveCount; if (distance <= skillInfo.m_MaxMoveDistance + 1) { enableControl = true; //LogSys.Log(LOG_TYPE.WARN, "Msg_CRC_GfxControlMoveStopHandler {0} ({1} <= {2}) LeftEnableMoveCount:{3} skill:{4} accept by server ({5}->{6})", _msg.obj_id, distSqr, skillInfo.m_MaxMoveDistanceSqr, skillInfo.m_LeftEnableMoveCount, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } else { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler {0} ({1} > {2}) LeftEnableMoveCount:{3} skill:{4} can't accept by server ({5}->{6})", _msg.obj_id, distance, skillInfo.m_MaxMoveDistance, skillInfo.m_LeftEnableMoveCount, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } } else { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler {0} (LeftEnableMoveCount:{1} skill:{2}) can't accept by server ({3}->{4})", _msg.obj_id, skillInfo != null ? skillInfo.m_LeftEnableMoveCount : -1, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } } else { ImpactInfo impactInfo = info.GetSkillStateInfo().GetImpactInfoForCheck(_msg.skill_or_impact_id); if (null != impactInfo && impactInfo.m_LeftEnableMoveCount > 0) { //校验 --impactInfo.m_LeftEnableMoveCount; float distance = Geometry.Distance(pos, newPos); if (distance <= impactInfo.m_MaxMoveDistance + 1) { enableControl = true; //LogSys.Log(LOG_TYPE.WARN, "Msg_CRC_GfxControlMoveStopHandler {0} ({1} <= {2}) LeftEnableMoveCount:{3} skill:{4} impact:{5} accept by server ({6}->{7})", _msg.obj_id, distSqr, impactInfo.m_MaxMoveDistanceSqr, impactInfo.m_LeftEnableMoveCount, impactInfo.m_SkillId, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } else { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler {0} ({1} > {2}) LeftEnableMoveCount:{3} skill:{4} impact:{5} can't accept by server ({6}->{7})", _msg.obj_id, distance, impactInfo.m_MaxMoveDistance, impactInfo.m_LeftEnableMoveCount, impactInfo.m_SkillId, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } } else { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler {0} (LeftEnableMoveCount:{1} skill:{2} impact:{3}) can't accept by server ({4}->{5})", _msg.obj_id, impactInfo != null ? impactInfo.m_LeftEnableMoveCount : -1, impactInfo != null ? impactInfo.m_SkillId : -1, _msg.skill_or_impact_id, pos.ToString(), newPos.ToString()); } } if (enableControl) { msi.SetFaceDir(_msg.face_dir); msi.SetPosition(newPos); } else { //todo:记录违规次数 } if (_msg.obj_id == user.RoleId) { float velocity = (float)user.Info.GetActualProperty().MoveSpeed; user.SampleMoveData(msi.PositionX, msi.PositionZ, velocity, msi.MoveDirCosAngle, msi.MoveDirSinAngle, _msg.send_time); } } else { if (null == info) { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler, charactor {0} not exist", _msg.obj_id); } else { LogSys.Log(LOG_TYPE.ERROR, "Msg_CRC_GfxControlMoveStopHandler, charactor {0} or owner {1} not user {2}", info.GetId(), info.OwnerId, user.RoleId); } } } }
public void RefreshItemSkills(SendImpactToSelfDelegation sendImpactToSelf, StopMyImpactDelegation stopImpact) { //标记所有物品带的技能与buff foreach (SkillInfo info in GetSkillStateInfo().GetAllSkill()) { if (info.IsItemSkill) { info.IsMarkToRemove = true; } } foreach (ImpactInfo info in GetSkillStateInfo().GetAllImpact()) { if (info.m_IsItemImpact) { info.m_IsMarkToRemove = true; } } //刷新物品带的技能与buff EquipmentStateInfo equipInfo = GetEquipmentStateInfo(); for (int ix = 0; ix < EquipmentStateInfo.c_PackageCapacity; ++ix) { ItemDataInfo itemInfo = equipInfo.GetItemData(ix); if (null != itemInfo && itemInfo.ItemNum == 1 && null != itemInfo.ItemConfig) { ItemConfig cfg = itemInfo.ItemConfig; if (null != cfg.m_AddSkillOnEquiping) { foreach (int id in cfg.m_AddSkillOnEquiping) { SkillInfo skillInfo = GetSkillStateInfo().GetSkillInfoById(id); if (null == skillInfo) { skillInfo = new SkillInfo(id); skillInfo.IsItemSkill = true; skillInfo.IsMarkToRemove = false; GetSkillStateInfo().AddSkill(skillInfo); } else { skillInfo.IsMarkToRemove = false; } } } if (null != cfg.m_AddBuffOnEquiping && null != sendImpactToSelf) { //此分支为服务器端处理,参数为加impact的回调,这个回调里包括加impact并发消息给客户端(现在ImpactSystem是这样实现的) foreach (int id in cfg.m_AddBuffOnEquiping) { ImpactInfo impactInfo = GetSkillStateInfo().GetImpactInfoById(id); if (null == impactInfo) { impactInfo = sendImpactToSelf(id); if (null != impactInfo) { impactInfo.m_IsItemImpact = true; impactInfo.m_IsMarkToRemove = false; } } else { impactInfo.m_IsMarkToRemove = false; } } } } } //移除不再有效的技能与buff List <int> removeSkills = new List <int>(); foreach (SkillInfo info in GetSkillStateInfo().GetAllSkill()) { if (info.IsItemSkill && info.IsMarkToRemove) { removeSkills.Add(info.SkillId); } } foreach (int id in removeSkills) { GetSkillStateInfo().RemoveSkill(id); } removeSkills.Clear(); List <int> removeImpacts = new List <int>(); foreach (ImpactInfo info in GetSkillStateInfo().GetAllImpact()) { if (info.m_IsItemImpact && info.m_IsMarkToRemove) { removeImpacts.Add(info.m_ImpactId); } } foreach (int id in removeImpacts) { if (null != stopImpact) { stopImpact(id); } } removeImpacts.Clear(); }