Exemplo n.º 1
0
    public void AddSyncData(NFMsg.ReqAckPlayerPosSync reqAckPlayerPosSync)
    {
        Clear();

        for (int i = 0; i < reqAckPlayerPosSync.SyncUnit.Count; ++i)
        {
            NFMsg.PosSyncUnit syncUnit = reqAckPlayerPosSync.SyncUnit[i];
            Vector3           pos      = new Vector3();
            Vector3           dir      = new Vector3();
            pos.x = syncUnit.Pos.X;
            pos.y = syncUnit.Pos.Y;
            pos.z = syncUnit.Pos.Z;

            if (syncUnit.Direction != null)
            {
                dir.x = syncUnit.Direction.X;
                dir.y = syncUnit.Direction.Y;
                dir.z = syncUnit.Direction.Z;
            }

            var keyframe = new NFHeroSyncBuffer.Keyframe();
            keyframe.Position = pos;
            keyframe.Director = dir;
            keyframe.status   = syncUnit.Status;

            if (mxSyncBuffer)
            {
                mxSyncBuffer.AddKeyframe(keyframe);
            }
        }
    }
Exemplo n.º 2
0
    public void AddSyncData(int sequence, NFMsg.PosSyncUnit syncUnit)
    {
        Clear();

        Vector3 pos = new Vector3();
        Vector3 dir = new Vector3();

        if (syncUnit.Pos != null)
        {
            pos.x = syncUnit.Pos.X;
            pos.y = syncUnit.Pos.Y;
            pos.z = syncUnit.Pos.Z;
        }

        if (syncUnit.Orientation != null)
        {
            dir.x = syncUnit.Orientation.X;
            dir.y = syncUnit.Orientation.Y;
            dir.z = syncUnit.Orientation.Z;
        }

        var keyframe = new NFHeroSyncBuffer.Keyframe();

        keyframe.Position          = pos;
        keyframe.Director          = dir;
        keyframe.status            = syncUnit.Status;
        keyframe.InterpolationTime = sequence;

        if (mxSyncBuffer)
        {
            Debug.Log(keyframe.InterpolationTime + " move " + this.transform.position.ToString() + " TO " + keyframe.Position.ToString());

            mxSyncBuffer.AddKeyframe(keyframe);
        }
    }
Exemplo n.º 3
0
    public void SendSyncMessage()
    {
        syncMessageCount++;

        NFMsg.Vector3 position = new NFMsg.Vector3();
        position.X = mxHeroMotor.GetMovePos().x;
        position.Y = mxHeroMotor.GetMovePos().y;
        position.Z = mxHeroMotor.GetMovePos().z;

        NFMsg.Vector3 direction = new NFMsg.Vector3();
        direction.X = mxHeroMotor.GetMoveDrictor().x;
        direction.Y = mxHeroMotor.GetMoveDrictor().y;
        direction.Z = mxHeroMotor.GetMoveDrictor().z;

        NFMsg.ReqAckPlayerPosSync playerPosSync = new NFMsg.ReqAckPlayerPosSync();
        playerPosSync.Mover = mHelpModule.NFToPB(mLoginModule.mRoleID);

        NFMsg.PosSyncUnit posSyncUnit = new NFMsg.PosSyncUnit();
        posSyncUnit.Pos       = position;
        posSyncUnit.Direction = direction;
        posSyncUnit.Status    = (int)mAnimaStateMachine.CurState();
        playerPosSync.SyncUnit.Add(posSyncUnit);


        mxNetModule.RequireSyncPosition(playerPosSync);
    }