本文整理汇总了C#中NetworkReader.ReadSingle方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReader.ReadSingle方法的具体用法?C# NetworkReader.ReadSingle怎么用?C# NetworkReader.ReadSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkReader
的用法示例。
在下文中一共展示了NetworkReader.ReadSingle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public override void Deserialize(NetworkReader reader)
{
this.netId = reader.ReadNetworkId();
this.stateHash = (int) reader.ReadPackedUInt32();
this.normalizedTime = reader.ReadSingle();
this.parameters = reader.ReadBytesAndSize();
}
示例2: OnDeserialize
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
base.OnDeserialize (reader, initialState);
float time = 0f;
try {
time = reader.ReadSingle ();
} catch (System.Exception e) {
Debug.LogError ("Custom deserialization exception.");
Debug.LogError (e);
}
animator.playbackTime = time;
}
示例3: Deserialize
public override void Deserialize(NetworkReader reader) {
//Get the no of inputs received
int count = reader.ReadInt32();
//Prepaare list
if (inputsList != null) {
inputsList.Clear(); //Detatch prev elements
}
inputsList = new List<Inputs>(); //Detatch prev mem
//Build all inputs
for (int i = 0; i < count; i++){
//Create
Inputs input = new Inputs();
//Deserialize individually
input.crouch = reader.ReadBoolean();
input.jump = reader.ReadBoolean();
input.move = reader.ReadBoolean();
input.pitch = reader.ReadSingle();
input.rotate = reader.ReadBoolean();
input.timeStamp = reader.ReadDouble();
input.walk = reader.ReadBoolean();
bool[] wasd = new bool[4];
wasd[0] = reader.ReadBoolean();
wasd[1] = reader.ReadBoolean();
wasd[2] = reader.ReadBoolean();
wasd[3] = reader.ReadBoolean();
input.wasd = wasd;
input.yaw = reader.ReadSingle();
//Add to the message list
inputsList.Add(input);
//Check if is the last input and register stamp
if(i == count - 1) {
stamp = input.timeStamp;
}
}
}
示例4: ReadAngle
private static float ReadAngle(NetworkReader reader, NetworkTransform.CompressionSyncMode compression)
{
switch (compression)
{
case NetworkTransform.CompressionSyncMode.None:
return reader.ReadSingle();
case NetworkTransform.CompressionSyncMode.Low:
return (float) reader.ReadInt16();
case NetworkTransform.CompressionSyncMode.High:
return (float) reader.ReadInt16();
default:
return 0.0f;
}
}
示例5: ReadParameters
private void ReadParameters(NetworkReader reader, bool autoSend)
{
for (int i = 0; i < this.m_Animator.parameters.Length; i++)
{
if (!autoSend || this.GetParameterAutoSend(i))
{
AnimatorControllerParameter parameter = this.m_Animator.parameters[i];
if (parameter.type == AnimatorControllerParameterType.Int)
{
int num2 = (int) reader.ReadPackedUInt32();
this.m_Animator.SetInteger(parameter.nameHash, num2);
this.SetRecvTrackingParam(parameter.name + ":" + num2, i);
}
if (parameter.type == AnimatorControllerParameterType.Float)
{
float num3 = reader.ReadSingle();
this.m_Animator.SetFloat(parameter.nameHash, num3);
this.SetRecvTrackingParam(parameter.name + ":" + num3, i);
}
if (parameter.type == AnimatorControllerParameterType.Bool)
{
bool flag = reader.ReadBoolean();
this.m_Animator.SetBool(parameter.nameHash, flag);
this.SetRecvTrackingParam(parameter.name + ":" + flag, i);
}
}
}
}
示例6: OnDeserialize
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
if (initialState)
{
int stateNameHash = reader.ReadInt32();
float normalizedTime = reader.ReadSingle();
this.ReadParameters(reader, false);
this.m_Animator.Play(stateNameHash, 0, normalizedTime);
}
}
示例7: ReadParameters
private void ReadParameters(NetworkReader reader, bool autoSend)
{
for (int index = 0; index < this.m_Animator.parameters.Length; ++index)
{
if (!autoSend || this.GetParameterAutoSend(index))
{
AnimatorControllerParameter parameter = this.m_Animator.parameters[index];
if (parameter.type == AnimatorControllerParameterType.Int)
{
int num = (int) reader.ReadPackedUInt32();
this.m_Animator.SetInteger(parameter.nameHash, num);
this.SetRecvTrackingParam(parameter.name + ":" + (object) num, index);
}
if (parameter.type == AnimatorControllerParameterType.Float)
{
float num = reader.ReadSingle();
this.m_Animator.SetFloat(parameter.nameHash, num);
this.SetRecvTrackingParam(parameter.name + ":" + (object) num, index);
}
if (parameter.type == AnimatorControllerParameterType.Bool)
{
bool flag = reader.ReadBoolean();
this.m_Animator.SetBool(parameter.nameHash, flag);
this.SetRecvTrackingParam(parameter.name + ":" + (object) flag, index);
}
}
}
}
示例8: FakeOnUnserializeVars
// ShipControl
public void FakeOnUnserializeVars(NetworkReader reader, bool initialState)
{
int num = (int)reader.ReadPackedUInt32();
if ((num & 1) != 0)
{
if (initialState)
{
this.health = (int)reader.ReadPackedUInt32();
}
else
{
this.OnHealth((int)reader.ReadPackedUInt32());
}
}
if ((num & 2) != 0)
{
this.energy = (int)reader.ReadPackedUInt32();
}
if ((num & 4) != 0)
{
this.speedBufTimer = reader.ReadSingle();
}
if ((num & 8) != 0)
{
this.rotateBufTimer = reader.ReadSingle();
}
if ((num & 16) != 0)
{
this.tripleshotTimer = reader.ReadSingle();
}
if ((num & 32) != 0)
{
this.doubleshotTimer = reader.ReadSingle();
}
if ((num & 64) != 0)
{
this.quadDamageTimer = reader.ReadSingle();
}
if ((num & 128) != 0)
{
this.bounceTimer = reader.ReadSingle();
}
if ((num & 256) != 0)
{
this.playerName = reader.ReadString();
}
if ((num & 512) != 0)
{
this.thrusting = reader.ReadSingle();
}
}
示例9: ReadAngle
private static float ReadAngle(NetworkReader reader, CompressionSyncMode compression)
{
switch (compression)
{
case CompressionSyncMode.None:
return reader.ReadSingle();
case CompressionSyncMode.Low:
return (float) reader.ReadInt16();
case CompressionSyncMode.High:
return (float) reader.ReadInt16();
}
return 0f;
}
示例10: Deserialize
public override void Deserialize(NetworkReader reader)
{
name = reader.ReadString();
var isNull = reader.ReadBoolean();
if (isNull){
value = null;
return;
}
var typeName = reader.ReadString();
var t = System.Type.GetType(typeName);
if (t == typeof(string)){
value = reader.ReadString();
return;
}
if (t == typeof(bool)){
value = reader.ReadBoolean();
return;
}
if (t == typeof(int)){
value = reader.ReadInt32();
return;
}
if (t == typeof(float)){
value = reader.ReadSingle();
return;
}
if (t == typeof(Color)){
value = reader.ReadColor();
return;
}
if (t == typeof(Vector2)){
value = reader.ReadVector2();
return;
}
if (t == typeof(Vector3)){
value = reader.ReadVector3();
return;
}
if (t == typeof(Vector4)){
value = reader.ReadVector4();
return;
}
if (t == typeof(Quaternion)){
value = reader.ReadQuaternion();
return;
}
if (t == typeof(GameObject)){
value = reader.ReadGameObject();
return;
}
if (typeof(Component).RTIsAssignableFrom(t)){
var go = reader.ReadGameObject();
if (go != null){
value = go.GetComponent(t);
}
return;
}
}
示例11: ReadAngle
private static float ReadAngle(NetworkReader reader, CompressionSyncMode compression)
{
if (compression != CompressionSyncMode.None)
{
if (compression == CompressionSyncMode.Low)
{
return (float) reader.ReadInt16();
}
if (compression == CompressionSyncMode.High)
{
return (float) reader.ReadInt16();
}
}
else
{
return reader.ReadSingle();
}
return 0f;
}