- 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 const short Lobby = 202;
- public const short GameWin = 203;
- public const short GameOver = 204;
- public const short GameStart = 205;
- public const short QueryPosition = 206;
- }
-
- public class PlayerMsg : MessageBase
- {
-
- public byte ID;
-
- public PlayerMsg() { }
-
- public PlayerMsg(byte playerID)
- {
- this.ID = playerID;
- }
-
- public override void Serialize(NetworkWriter writer)
- {
- writer.Write(ID);
- }
-
- public override void Deserialize(NetworkReader reader)
- {
- ID = reader.ReadByte();
- }
-
- }
-
- public class VectorMsg : PlayerMsg
- {
-
- public Vector3 vector;
-
- public VectorMsg() { }
- public VectorMsg(byte 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(byte 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 longMsg : PlayerMsg
- {
- public long Long;
-
- public longMsg() { }
-
- public longMsg(byte PlayerID, long Long) : base(PlayerID)
- {
- this.Long = Long;
- }
-
-
- public override void Serialize(NetworkWriter writer)
- {
- base.Serialize(writer);
- writer.Write(Long);
- }
-
- public override void Deserialize(NetworkReader reader)
- {
- base.Deserialize(reader);
- Long = reader.ReadInt64();
- }
- }
-
- public class StringMsg : PlayerMsg
- {
-
- public string String;
-
- public StringMsg() { }
-
- public StringMsg(byte 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();
- }
- }
- }
|