You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

117 lines
2.4 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
namespace Multiplayer
{
public class PlayerMsgID
{
public const short Position = 200;
public const short Rotation = 201;
}
public class PlayerMsg : MessageBase
{
public ushort playerID;
public PlayerMsg() { }
public PlayerMsg(ushort playerID)
{
this.playerID = playerID;
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(playerID);
}
public override void Deserialize(NetworkReader reader)
{
playerID = reader.ReadUInt16();
}
}
public class VectorMsg : PlayerMsg
{
public Vector3 vector;
public VectorMsg() { }
public VectorMsg(ushort PlayerID, Vector3 Vector) : base(PlayerID)
{
this.vector = Vector;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(vector);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
vector = reader.ReadVector3();
}
}
public class QuaternionMsg : PlayerMsg
{
public Quaternion quaternion;
public QuaternionMsg() { }
public QuaternionMsg(ushort PlayerID, Quaternion quaternion) : base(PlayerID)
{
this.quaternion = quaternion;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(quaternion);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
quaternion = reader.ReadQuaternion();
}
}
public class StringMsg : PlayerMsg
{
public string String;
public StringMsg() { }
public StringMsg(ushort PlayerID, string String) : base(PlayerID)
{
this.String = String;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(String);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
String = reader.ReadString();
}
}
}