public void Decode(NetIncomingMessage im) { this.Id = im.ReadInt32(); this.MessageTime = im.ReadDouble(); this.Position = im.ReadVector3(); /*this.MoveUp = im.ReadBoolean(); this.MoveDown = im.ReadBoolean(); this.MoveLeft = im.ReadBoolean(); this.MoveRight = im.ReadBoolean();*/ this.Object = Utility.Serializer.DeserializeObjectFromString<Model.Object.Object>(im.ReadString()); }
public void Decode(NetIncomingMessage im) { this.Id = im.ReadInt32(); this.MessageTime = im.ReadDouble(); //this.Region = Utility.Serializer.DeserializeObjectFromString<Model.Map.Region.Region>(im.ReadString()); //this.Region.Parent = Model.Map.World.World.world; this.Position = im.ReadVector3(); this.RegionEnum = (Model.Map.Region.RegionEnum)im.ReadInt32(); }
public void Decode(NetIncomingMessage im) { this.Id = im.ReadInt32(); this.MessageTime = im.ReadDouble(); this.RegionId = im.ReadInt32(); //this.Chunk = Utility.Serializer.DeserializeObjectFromString<Model.Map.Chunk.Chunk>(im.ReadString()); //this.Chunk.Parent = Model.Map.World.World.world.getRegion(this.RegionId); //this.Chunk.setAllNeighboursOfBlocks(); this.Position = im.ReadVector3(); Model.Map.Chunk.Chunk var_Chunk = Model.Map.World.World.world.getChunkAtPosition(Position); if (var_Chunk != null) { if (var_Chunk.IsRequested) { var_Chunk.IsRequested = false; } } }
public void Decode(NetIncomingMessage im) { this.MessageTime = im.ReadDouble(); this.ChunkId = im.ReadInt32(); Microsoft.Xna.Framework.Vector3 var_Position = im.ReadVector3(); this.Block = GameLibrary.Model.Map.World.World.world.getBlockAtCoordinate(var_Position); int var_Size = Enum.GetValues(typeof(GameLibrary.Model.Map.Block.BlockLayerEnum)).Length; if (this.Block != null) { if (this.Block.IsRequested) { for (int i = 0; i < var_Size; i++) { this.Block.Layer[i] = (Model.Map.Block.BlockEnum)im.ReadInt32(); } } this.Block.IsRequested = false; } }
public void Decode(NetIncomingMessage im) { this.Id = im.ReadInt32(); this.MessageTime = im.ReadDouble(); this.Position = im.ReadVector3(); this.Velocity = im.ReadVector3(); this.MoveUp = im.ReadBoolean(); this.MoveDown = im.ReadBoolean(); this.MoveLeft = im.ReadBoolean(); this.MoveRight = im.ReadBoolean(); }
public void Update() { // Recieve messages from the server. while ((_msgBuffer = _client.ReadMessage()) != null) { NetIncomingMessageType msgType = _msgBuffer.MessageType; switch (msgType) { case NetIncomingMessageType.StatusChanged: { NetConnectionStatus status = (NetConnectionStatus)_msgBuffer.ReadByte(); if (status == NetConnectionStatus.Disconnected) { string reason = _msgBuffer.ReadString(); switch (reason) { case "kicked": { _pbag.GameManager.SetErrorState(ErrorMsg.Kicked); break; } case "banned": { _pbag.GameManager.SetErrorState(ErrorMsg.Banned); break; } case "serverfull": { _pbag.GameManager.SetErrorState(ErrorMsg.ServerFull); break; } case "versionmismatch": { _pbag.GameManager.SetErrorState(ErrorMsg.VersionMismatch); break; } case "shutdown": { _pbag.GameManager.SetErrorState(ErrorMsg.ServerShutdown); break; } case "restart": { _pbag.GameManager.SetErrorState(ErrorMsg.ServerRestart); break; } case "exit": { //Todo need to find more info about this case in the disconnect switch break; } default: { _pbag.GameManager.Temperrormsg(reason); //Pbag.GameManager.SetErrorState(ErrorMsg.Unkown); break; } } } break; } case NetIncomingMessageType.DiscoveryResponse: { string name = _msgBuffer.ReadString(); int playercount = _msgBuffer.ReadInt32(); int playermax = _msgBuffer.ReadInt32(); bool lan = _msgBuffer.ReadBoolean(); string ip = _msgBuffer.SenderEndpoint.Address.ToString(); ServerInformation newserver = new ServerInformation(name,ip,playercount,playermax,lan); _pbag.GameManager.AddServer(newserver); break; } case NetIncomingMessageType.ConnectionApproval: { break; } case NetIncomingMessageType.Data: { PacketType dataType = (PacketType)_msgBuffer.ReadByte(); switch (dataType) { case PacketType.WorldMapSize: { _pbag.WorldManager.Mapsize = _msgBuffer.ReadInt32(); _pbag.WorldManager.Start(); break; } case PacketType.PlayerInitialUpdate: { _pbag.Player.Myid = _msgBuffer.ReadInt32(); _pbag.Player.Name = _msgBuffer.ReadString(); _pbag.Player.Position = _msgBuffer.ReadVector3(); break; } case PacketType.PlayerJoined: { ClientPlayer dummy = new ClientPlayer(_pbag.GameManager.Conmanager); dummy.Id = _msgBuffer.ReadInt32(); dummy.Name = _msgBuffer.ReadString(); dummy.Position = _msgBuffer.ReadVector3(); dummy.Heading = _msgBuffer.ReadVector3(); _pbag.WorldManager.Playerlist.Add(dummy.Id, dummy); break; } case PacketType.PlayerLeft: { int id = _msgBuffer.ReadInt32(); _pbag.WorldManager.Playerlist.Remove(id); break; } case PacketType.PlayerMovementUpdate: { int id = _msgBuffer.ReadInt32(); if (_pbag.WorldManager.Playerlist.ContainsKey(id)) { _pbag.WorldManager.Playerlist[id].Position = _msgBuffer.ReadVector3(); } break; } case PacketType.PlayerNameSet: { int id = _msgBuffer.ReadInt32(); //Lets see if its my id or someones else id if (_pbag.Player.Myid == id) { _pbag.Player.Name = _msgBuffer.ReadString(); } else { //Then its someones else its id if (_pbag.WorldManager.Playerlist.ContainsKey(id)) { _pbag.WorldManager.Playerlist[id].Position = _msgBuffer.ReadVector3(); } } break; } default: { break; } } } break; } } }
public void Decode(NetIncomingMessage im) { this.MessageTime = im.ReadDouble(); this.Position = im.ReadVector3(); }