void RPC_WallMyData(NetData info) { foreach (NetData index in Global.Instance.PlayersData) { if (index.Id == info.Id) { index.Name = info.Name; index.Ready = info.Ready; return; } } Global.Instance.PlayersData.Add(info); }
static object DeserializeNetData(byte[] bytes) { NetData data = new NetData(); int index = 0; int @bool; Protocol.Deserialize(out data.Id, bytes, ref index); Protocol.Deserialize(out @bool, bytes, ref index); Protocol.Deserialize(out data.Score, bytes, ref index); data.Ready = @bool == 1 ? true : false; data.Name = Encoding.Default.GetString(bytes, index, bytes.Length - 2 * 4 - 4); return(data); }
static byte[] SerializeNetData(object obj) { int index = 0; NetData data = (NetData)obj; byte[] strBytes = Encoding.Default.GetBytes(data.Name); byte[] bytes = new byte[2 * 4 + 1 * 4 + strBytes.Length]; int @bool = data.Ready ? 1 : 0; Protocol.Serialize(data.Id, bytes, ref index); Protocol.Serialize(@bool, bytes, ref index); Protocol.Serialize(data.Score, bytes, ref index); strBytes.CopyTo(bytes, index); return(bytes); }
public override void Init() { MyData = new NetData(); PlayersData = new List <NetData>(); }
public NetData FindData(NetData data) { return(PlayersData.Find(value => value == data)); }
public void Send_WallMyData(RpcTarget who, NetData wallData) { photonView.RPC("RPC_WallMyData", who, wallData); }
void RPC_Client_GetMasterNetData(NetData data) { Global.Instance.PlayersData.Add(data); }