internal static void Execute(object msg, NetConnection conn) { Msg_RC_NpcSkill targetmsg = msg as Msg_RC_NpcSkill; if (null == targetmsg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(targetmsg.npc_id); if (null == npc) { return; } float x = 0.0f; float z = 0.0f; ProtoHelper.DecodePosition2D(targetmsg.stand_pos, out x, out z); float faceDir = ProtoHelper.DecodeFloat(targetmsg.face_direction); int skillId = targetmsg.skill_id; LogSystem.Info("Receive Msg_RC_NpcSkill, EntityId={0}, SkillId={1}", targetmsg.npc_id, skillId); MovementStateInfo msi = npc.GetMovementStateInfo(); if (targetmsg.target_id <= 0) { msi.SetPosition2D(x, z); msi.SetFaceDir(faceDir); npc.GetAiStateInfo().Target = 0; UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, z)); actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(faceDir), 0); } else { npc.GetAiStateInfo().Target = targetmsg.target_id; } SkillInfo skillInfo = npc.GetSkillStateInfo().GetSkillInfoById(skillId); if (null != skillInfo) { if (skillInfo.ConfigData.skillData.canmove == 0) { EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.StopMove(); } } if (GfxSkillSystem.Instance.StartSkill(npc.GetId(), skillInfo.ConfigData, 0)) { Utility.EventSystem.Publish("ui_skill_cooldown", "ui", npc.GetId(), skillId, skillInfo.ConfigData.skillData.cooldown / 1000.0f); } } }
internal static void Execute(object msg, NetConnection conn) { Msg_RC_NpcMove targetmsg = msg as Msg_RC_NpcMove; if (null == targetmsg) { return; } EntityInfo npc = PluginFramework.Instance.GetEntityById(targetmsg.npc_id); if (null == npc) { return; } if (targetmsg.velocity > 0) { float x, y; float tx, ty; ProtoHelper.DecodePosition2D(targetmsg.cur_pos, out x, out y); ProtoHelper.DecodePosition2D(targetmsg.target_pos, out tx, out ty); Vector2 curPos = new Vector2(x, y); Vector2 targetPos = new Vector2(tx, ty); MovementStateInfo msi = npc.GetMovementStateInfo(); float velocity = ProtoHelper.DecodeFloat(targetmsg.velocity); npc.ActualProperty.SetFloat(CharacterPropertyEnum.x2011_最终速度, velocity); if (Geometry.DistanceSquare(msi.GetPosition2D(), curPos) > c_MaxPosDeltaSqr) { msi.SetPosition2D(curPos); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, y)); } EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.MoveTo(targetPos.X, 0, targetPos.Y); } } else { float x, y; ProtoHelper.DecodePosition2D(targetmsg.cur_pos, out x, out y); Vector2 curPos = new Vector2(x, y); MovementStateInfo msi = npc.GetMovementStateInfo(); if (Geometry.DistanceSquare(msi.GetPosition2D(), curPos) > c_MaxPosDeltaSqr) { msi.SetPosition2D(curPos); UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId()); GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, actor.transform.position.y, y)); } else { EntityViewModel viewModel = EntityViewModelManager.Instance.GetEntityViewById(targetmsg.npc_id); if (null != viewModel) { viewModel.MoveTo(curPos.X, 0, curPos.Y); } } } }