public ConnectingState(String nick, String address, int port) { this.nick = nick; this.address = address; this.port = port; NetworkIn = new Common.Network.S2CInterface { Connected = (ep, map) => { FileStream f = new FileStream("Maps/" + map, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //BinaryFormatter b = new BinaryFormatter(); Common.XmlFormatter b = new Common.XmlFormatter(); Program.Instance.Map = (Common.Map.Map)b.Deserialize(f); f.Close(); if (File.Exists("Maps/" + map + ".terrain")) { BinaryFormatter bf = new BinaryFormatter(); f = new FileStream("Maps/" + map + ".terrain", FileMode.Open); Program.Instance.Map.Heightmap = (float[,])bf.Deserialize(f); f.Close(); } Program.Instance.ChangeState(new LobbyState()); } }; }
public QuickStart(String nick, String map, int port) { this.nick = nick; this.map = map; this.port = port; NetworkIn = new Common.Network.S2CInterface { Connected = (ep, map_) => { FileStream f = new FileStream("Maps/" + map_, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); //BinaryFormatter b = new BinaryFormatter(); Common.XmlFormatter b = new Common.XmlFormatter(); Program.Instance.Map = (Common.Map.Map)b.Deserialize(f); f.Close(); if (File.Exists("Maps/" + map + ".terrain")) { BinaryFormatter bf = new BinaryFormatter(); f = new FileStream("Maps/" + map + ".terrain", FileMode.Open); Program.Instance.Map.Heightmap = (float[,])bf.Deserialize(f); f.Close(); } Program.Instance.NetworkOut.StartGame(Program.Instance.ServerEndpoint); title.Text = "Starting..."; }, StartGame = (ep) => { Program.Instance.ChangeState(new GameState()); }, PlayerJoined = (ep, nick_, slot) => { }, PlayerChangedSlot = (ep, oldslot, slot) => { }, }; }