示例#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);
        }
    }
        protected override bool ExecCommand(StoryInstance instance, StoryValueParam <int, float, float> _params, long delta)
        {
            BoxedValue us;

            if (instance.GlobalVariables.TryGetValue("EntityInfo", out us))
            {
                EntityInfo user = us.ObjectVal as EntityInfo;
                if (null != user)
                {
                    int        objId   = _params.Param1Value;
                    float      x       = _params.Param2Value;
                    float      z       = _params.Param3Value;
                    EntityInfo charObj = user.SceneContext.GetEntityById(objId);
                    if (null != charObj)
                    {
                        MovementStateInfo msi = charObj.GetMovementStateInfo();
                        msi.SetPosition2D(x, z);

                        Scene scene = user.SceneContext.CustomData as Scene;
                        if (null != scene)
                        {
                            GameFrameworkMessage.Msg_RC_AdjustPosition adjustPos = new GameFrameworkMessage.Msg_RC_AdjustPosition();
                            adjustPos.role_id  = objId;
                            adjustPos.face_dir = msi.GetFaceDir();
                            adjustPos.x        = x;
                            adjustPos.z        = z;

                            scene.NotifyAllUser(RoomMessageDefine.Msg_RC_AdjustPosition, adjustPos);
                        }
                    }
                }
            }
            return(false);
        }
示例#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);
            }
        }
    }
示例#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);
                }
            }
        }
    }