public WorldScene() { this.world = new World(); this.world.DetailInterationTriggered += World_DetailInterationTriggered; this.debug = new DebugRenderer(); this.worldRenderer = new WorldRenderer(this.world); using (var stream = typeof(WorldScene).Assembly.GetManifestResourceStream("BlocksWorld.Textures.UI.png")) { this.uiTextures = Image.FromStream(stream); } this.largeFont = new Font(FontFamily.GenericSansSerif, 16.0f); this.smallFont = new Font(FontFamily.GenericSansSerif, 8.0f); this.ui = new UIRenderer(1280, 720); this.ui.Paint += Ui_Paint; this.network = new Network(new TcpClient("localhost", 4523)); this.receiver = new BasicReceiver(this.network, this.world); this.sender = new PhraseTranslator(this.network); this.network[NetworkPhrase.LoadWorld] = this.LoadWorldFromNetwork; this.network[NetworkPhrase.SpawnPlayer] = this.SpawnPlayer; this.network[NetworkPhrase.UpdateProxy] = this.UpdateProxy; this.network[NetworkPhrase.DestroyProxy] = this.DestroyProxy; this.network[NetworkPhrase.CreateDetail] = this.CreateDetail; this.network[NetworkPhrase.UpdateDetail] = this.UpdateDetail; this.network[NetworkPhrase.DestroyDetail] = this.DestroyDetail; this.network[NetworkPhrase.SetInteractions] = this.SetInteractions; }
public Player(Server server, TcpClient tcp, int id) { this.id = id; this.server = server; this.network = new Network(tcp); this.receiver = new BasicReceiver(this.Network, this.server.World); this.network[NetworkPhrase.SetPlayer] = this.SetPlayer; this.network[NetworkPhrase.SpawnDetail] = this.SpawnDetail; this.network[NetworkPhrase.DestroyDetail] = this.DestroyDetail; this.network[NetworkPhrase.TriggerInteraction] = this.TriggerInteraction; this.client = new PhraseTranslator(this.network); this.broadcast = new PhraseTranslator(this.server); this.others = new PhraseTranslator(this); this.client.SendWorld(this.server.World); this.client.SpawnPlayer(new Vector3(16.0f, 4.0f, 3.0f)); foreach (var detail in this.server.World.Details) { this.CreateDetail(detail); } this.server.World.BlockChanged += World_BlockChanged; this.server.World.DetailCreated += (s, e) => { this.CreateDetail(e.Detail); }; this.server.World.DetailChanged += (s, e) => { this.client.UpdateDetail(e.Detail); }; this.server.World.DetailRemoved += (s, e) => { e.Detail.InteractionsChanged -= Detail_InteractionsChanged; this.client.DestroyDetail(e.Detail); }; }