本文整理汇总了C#中KBEngine.Bundle.writeFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Bundle.writeFloat方法的具体用法?C# Bundle.writeFloat怎么用?C# Bundle.writeFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBEngine.Bundle
的用法示例。
在下文中一共展示了Bundle.writeFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: updatePlayerToServer
/*
更新当前玩家的位置与朝向到服务端, 可以通过开关_syncPlayer关闭这个机制
*/
public void updatePlayerToServer()
{
if(!_args.syncPlayer || spaceID == 0)
{
return;
}
TimeSpan span = DateTime.Now - _lastUpdateToServerTime;
if(span.Milliseconds < 50)
return;
Entity playerEntity = player();
if(playerEntity == null || playerEntity.inWorld == false)
return;
_lastUpdateToServerTime = System.DateTime.Now;
Vector3 position = playerEntity.position;
Vector3 direction = playerEntity.direction;
bool posHasChanged = Vector3.Distance(_entityLastLocalPos, position) > 0.001f;
bool dirHasChanged = Vector3.Distance(_entityLastLocalDir, direction) > 0.001f;
if(posHasChanged || dirHasChanged)
{
_entityLastLocalPos = position;
_entityLastLocalDir = direction;
Bundle bundle = new Bundle();
bundle.newMessage(Message.messages["Baseapp_onUpdateDataFromClient"]);
bundle.writeFloat(position.x);
bundle.writeFloat(position.y);
bundle.writeFloat(position.z);
bundle.writeFloat((float)((double)direction.x / 360 * 6.283185307179586));
bundle.writeFloat((float)((double)direction.y / 360 * 6.283185307179586));
bundle.writeFloat((float)((double)direction.z / 360 * 6.283185307179586));
bundle.writeUint8((Byte)(playerEntity.isOnGround == true ? 1 : 0));
bundle.writeUint32(spaceID);
bundle.send(_networkInterface);
}
}
示例2: addToStream
public override void addToStream(Bundle stream, object v)
{
stream.writeUint32(4);
stream.writeFloat(((Vector4)v).x);
stream.writeFloat(((Vector4)v).y);
stream.writeFloat(((Vector4)v).z);
stream.writeFloat(((Vector4)v).w);
}
示例3: updatePlayerToServer
public void updatePlayerToServer()
{
Entity playerEntity = player();
if(playerEntity == null || playerEntity.inWorld == false)
return;
Vector3 position = playerEntity.position;
Vector3 direction = playerEntity.direction;
Bundle bundle = new Bundle();
bundle.newMessage(Message.messages["Baseapp_onUpdateDataFromClient"]);
bundle.writeFloat(position.x);
bundle.writeFloat(position.y);
bundle.writeFloat(position.z);
bundle.writeFloat(direction.z);
bundle.writeFloat(direction.y);
bundle.writeFloat(direction.x);
bundle.writeUint8((Byte)(playerEntity.isOnGound == true ? 1 : 0));
bundle.send(networkInterface_);
}
示例4: addToStream
public override void addToStream(Bundle stream, object v)
{
stream.writeUint32(4);
stream.writeFloat(((Vector4)v).X);
stream.writeFloat(((Vector4)v).Y);
stream.writeFloat(((Vector4)v).Z);
stream.writeFloat(((Vector4)v).W);
}