|
|
- 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 const short Vegetable = 207;
- }
-
- 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();
- }
- }
-
- public class VegMsg : PlayerMsg
- {
- public string String;
- public int Int;
-
- public VegMsg() { }
-
- public VegMsg(byte PlayerID, string String, int Int) : base(PlayerID)
- {
- this.String = String;
- this.Int = Int;
- }
-
- public override void Serialize(NetworkWriter writer)
- {
- base.Serialize(writer);
- writer.Write(String);
- writer.Write(Int);
- }
-
- public override void Deserialize(NetworkReader reader)
- {
- base.Deserialize(reader);
- String = reader.ReadString();
- Int = reader.ReadInt32();
- }
-
- }
-
- public class PlayerDataMsg : PlayerMsg
- {
- public string Name;
- public Color Color;
-
- public PlayerDataMsg() { }
-
- public PlayerDataMsg(byte PlayerID, string Name, Color Color) : base(PlayerID)
- {
- this.Name = Name;
- this.Color = Color;
- }
-
- public override void Serialize(NetworkWriter writer)
- {
- base.Serialize(writer);
- writer.Write(Name);
- writer.Write(Color);
- }
-
-
- public override void Deserialize(NetworkReader reader)
- {
- base.Deserialize(reader);
- Name = reader.ReadString();
- Color = reader.ReadColor();
- }
-
- }
-
- }
|