本文整理汇总了C#中NetworkReader.ReadVector2方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkReader.ReadVector2方法的具体用法?C# NetworkReader.ReadVector2怎么用?C# NetworkReader.ReadVector2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkReader
的用法示例。
在下文中一共展示了NetworkReader.ReadVector2方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnserializeMode2D
private void UnserializeMode2D(NetworkReader reader, bool initialState)
{
if (this.hasAuthority)
{
reader.ReadVector2();
reader.ReadVector2();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
{
double num1 = (double) NetworkTransform.UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (!this.syncSpin)
return;
double num2 = (double) NetworkTransform.UnserializeSpin2D(reader, this.rotationSyncCompression);
}
else
{
if ((UnityEngine.Object) this.m_RigidBody2D == (UnityEngine.Object) null)
return;
if (this.isServer && this.m_ClientMoveCallback2D != null)
{
Vector2 position = reader.ReadVector2();
Vector2 velocity = reader.ReadVector2();
float rotation = 0.0f;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
rotation = NetworkTransform.UnserializeRotation2D(reader, this.rotationSyncCompression);
if (!this.m_ClientMoveCallback2D(ref position, ref velocity, ref rotation))
return;
this.m_TargetSyncPosition = (Vector3) position;
this.m_TargetSyncVelocity = (Vector3) velocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation2D = rotation;
}
else
{
this.m_TargetSyncPosition = (Vector3) reader.ReadVector2();
this.m_TargetSyncVelocity = (Vector3) reader.ReadVector2();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation2D = NetworkTransform.UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (this.syncSpin)
this.m_TargetSyncAngularVelocity2D = NetworkTransform.UnserializeSpin2D(reader, this.rotationSyncCompression);
if (this.isServer && !this.isClient)
{
this.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
}
else if ((double) this.GetNetworkSendInterval() == 0.0)
{
this.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
if (!this.syncSpin)
return;
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
else
{
if ((double) (this.m_RigidBody2D.position - (Vector2) this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
{
this.m_RigidBody2D.position = (Vector2) this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
}
if ((double) this.interpolateRotation == 0.0 && this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
{
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
if (this.syncSpin)
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
if ((double) this.m_InterpolateMovement == 0.0)
this.m_RigidBody2D.position = (Vector2) this.m_TargetSyncPosition;
if (!initialState)
return;
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
}
}
}
示例2: HandleFillAtMessage
public void HandleFillAtMessage(NetworkReader nr)
{
Vector2 cursorWorld = nr.ReadVector2();
FloorType floorType = (FloorType)(1 + (int)(UnityEngine.Random.value * 2.0f));
SetCompartmentFloor(floorType, CompartmentAt(WorldToLocal(cursorWorld)));
}
示例3: UnserializeVelocity2D
public static Vector3 UnserializeVelocity2D(NetworkReader reader, NetworkTransform.CompressionSyncMode compression)
{
return (Vector3) reader.ReadVector2();
}
示例4: Sync
public void Sync(NetworkReader nr)
{
this.interiorPosition = nr.ReadVector2();
}
示例5: UnserializeMode2D
private void UnserializeMode2D(NetworkReader reader, bool initialState)
{
if ((UnityEngine.Object) this.m_RigidBody2D == (UnityEngine.Object) null)
return;
this.m_TargetSyncPosition = (Vector3) reader.ReadVector2();
this.m_TargetSyncVelocity = (Vector3) reader.ReadVector2();
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_TargetSyncRotation2D = this.UnserializeRotation2D(reader, this.rotationSyncCompression);
if (this.syncSpin)
this.m_TargetSyncAngularVelocity2D = this.UnserializeSpin2D(reader, this.rotationSyncCompression);
if (this.isServer && !this.isClient)
{
this.m_RigidBody2D.MovePosition((Vector2) this.m_TargetSyncPosition);
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
}
else if ((double) this.GetNetworkSendInterval() == 0.0)
{
this.m_RigidBody2D.MovePosition((Vector2) this.m_TargetSyncPosition);
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
if (this.syncRotationAxis != NetworkTransform.AxisSyncMode.None)
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
if (!this.syncSpin)
return;
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
else
{
if ((double) (this.m_RigidBody2D.position - (Vector2) this.m_TargetSyncPosition).magnitude > (double) this.snapThreshold)
{
this.m_RigidBody2D.position = (Vector2) this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = (Vector2) this.m_TargetSyncVelocity;
}
if ((double) this.interpolateRotation == 0.0)
{
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
if (this.syncSpin)
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
if ((double) this.m_InterpolateMovement == 0.0)
this.m_RigidBody2D.position = (Vector2) this.m_TargetSyncPosition;
if (!initialState)
return;
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
}
}
示例6: UnserializeMode2D
private void UnserializeMode2D(NetworkReader reader, bool initialState)
{
if (base.hasAuthority)
{
Vector2 vector = reader.ReadVector2();
Vector2 vector2 = reader.ReadVector2();
float angle = 0f;
if (this.syncRotationAxis != AxisSyncMode.None)
{
angle = UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (this.syncSpin)
{
UnserializeSpin2D(reader, this.rotationSyncCompression);
}
Vector2 vector5 = vector - this.m_RigidBody2D.position;
if (Mathf.Abs(vector5.magnitude) > this.m_SnapThreshold)
{
base.transform.position = (Vector3) vector;
this.m_RigidBody2D.MoveRotation(angle);
this.m_RigidBody2D.velocity = vector2;
}
}
else if (this.m_RigidBody2D != null)
{
if (base.isServer && (this.m_ClientMoveCallback2D != null))
{
Vector2 position = reader.ReadVector2();
Vector2 velocity = reader.ReadVector2();
float rotation = 0f;
if (this.syncRotationAxis != AxisSyncMode.None)
{
rotation = UnserializeRotation2D(reader, this.rotationSyncCompression);
}
if (!this.m_ClientMoveCallback2D(ref position, ref velocity, ref rotation))
{
return;
}
this.m_TargetSyncPosition = (Vector3) position;
this.m_TargetSyncVelocity = (Vector3) velocity;
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_TargetSyncRotation2D = rotation;
}
}
else
{
this.m_TargetSyncPosition = (Vector3) reader.ReadVector2();
this.m_TargetSyncVelocity = (Vector3) reader.ReadVector2();
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_TargetSyncRotation2D = UnserializeRotation2D(reader, this.rotationSyncCompression);
}
}
if (this.syncSpin)
{
this.m_TargetSyncAngularVelocity2D = UnserializeSpin2D(reader, this.rotationSyncCompression);
}
if (base.isServer && !base.isClient)
{
base.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
}
else if (this.GetNetworkSendInterval() == 0f)
{
base.transform.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
if (this.syncRotationAxis != AxisSyncMode.None)
{
this.m_RigidBody2D.MoveRotation(this.m_TargetSyncRotation2D);
}
if (this.syncSpin)
{
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
}
else
{
Vector2 vector6 = this.m_RigidBody2D.position - this.m_TargetSyncPosition;
if (vector6.magnitude > this.snapThreshold)
{
this.m_RigidBody2D.position = this.m_TargetSyncPosition;
this.m_RigidBody2D.velocity = this.m_TargetSyncVelocity;
}
if ((this.interpolateRotation == 0f) && (this.syncRotationAxis != AxisSyncMode.None))
{
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
if (this.syncSpin)
{
this.m_RigidBody2D.angularVelocity = this.m_TargetSyncAngularVelocity2D;
}
}
if (this.m_InterpolateMovement == 0f)
{
this.m_RigidBody2D.position = this.m_TargetSyncPosition;
}
if (initialState)
{
this.m_RigidBody2D.rotation = this.m_TargetSyncRotation2D;
//.........这里部分代码省略.........
示例7: ReceiveCreateAvatar
private void ReceiveCreateAvatar(NetworkReader reader)
{
var avatar = new World.Avatar
{
id = reader.ReadInt32(),
destination = reader.ReadVector2(),
source = reader.ReadVector2(),
graphic = BlankTexture.FullSprite(BlankTexture.New(32, 32, Color.clear)),
};
AddAvatar(avatar);
}
示例8: Update
//.........这里部分代码省略.........
}
else if (type == Type.Walls)
{
world.walls.Clear();
foreach (var wall in reader.ReadBytesAndSize())
{
world.walls.Add(wall);
}
worldView.RefreshWalls();
}
else if (type == Type.Tileset)
{
int id = reader.ReadInt32();
tiledata[id] = reader.ReadBytesAndSize();
}
else if (type == Type.ReplicateAvatar)
{
ReceiveCreateAvatar(reader);
}
else if (type == Type.DestroyAvatar)
{
ReceiveDestroyAvatar(reader);
}
else if (type == Type.GiveAvatar)
{
ReceiveGiveAvatar(reader);
}
else if (type == Type.MoveAvatar)
{
World.Avatar avatar = ID2Avatar(reader.ReadInt32());
Vector2 dest = reader.ReadVector2();
if (hosting)
{
if (connectionID == avatar.id
&& !Blocked(avatar, dest))
{
avatar.source = avatar.destination;
avatar.destination = dest;
avatar.u = 0;
SendAll(MoveAvatarMessage(avatar, avatar.destination), except: avatar.id);
}
else
{
Send(connectionID, MoveAvatarMessage(avatar, avatar.destination));
}
}
else
{
avatar.source = avatar.destination;
avatar.destination = dest;
avatar.u = 0;
}
}
else if (type == Type.Chat)
{
World.Avatar avatar = ID2Avatar(reader.ReadInt32());
string message = reader.ReadString();
if (hosting)
{
if (connectionID == avatar.id)
示例9: ReadInputsMessage
public void ReadInputsMessage(NetworkReader nr)
{
Vector2 movement = nr.ReadVector2();
Vector2 facing = nr.ReadVector2();
Move(movement, facing);
}
示例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;
}
}