Ejemplo n.º 1
0
    internal static void Execute(object msg, NetConnection conn)
    {
        Msg_RC_AdjustPosition _msg = msg as Msg_RC_AdjustPosition;

        if (null == _msg)
        {
            return;
        }
        EntityInfo npc = PluginFramework.Instance.GetEntityById(_msg.role_id);

        if (null != npc)
        {
            float x       = ProtoHelper.DecodeFloat(_msg.x);
            float z       = ProtoHelper.DecodeFloat(_msg.z);
            float faceDir = ProtoHelper.DecodeFloat(_msg.face_dir);

            MovementStateInfo msi = npc.GetMovementStateInfo();
            msi.SetPosition2D(x, z);
            msi.SetFaceDir(faceDir);

            UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId());
            GameFramework.Skill.Trigers.TriggerUtil.MoveObjTo(actor, new UnityEngine.Vector3(x, 0, z));
            actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(faceDir), 0);
        }
    }
Ejemplo n.º 2
0
    internal static void Execute(object msg, NetConnection conn)
    {
        Msg_RC_NpcFace face_msg = msg as Msg_RC_NpcFace;

        if (null == face_msg)
        {
            return;
        }
        EntityInfo npc = PluginFramework.Instance.GetEntityById(face_msg.npc_id);

        if (npc == null)
        {
            return;
        }
        if (npc.HaveState(CharacterPropertyEnum.x3002_昏睡))
        {
            return;
        }
        float dir = ProtoHelper.DecodeFloat(face_msg.face_direction);

        npc.GetMovementStateInfo().SetFaceDir(dir);

        UnityEngine.GameObject actor = EntityController.Instance.GetGameObject(npc.GetId());
        actor.transform.localRotation = UnityEngine.Quaternion.Euler(0, Utility.RadianToDegree(dir), 0);
    }
Ejemplo n.º 3
0
    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);
            }
        }
    }
Ejemplo n.º 4
0
    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);
                }
            }
        }
    }