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 BasicReceiver(Network network, World world) { this.network = network; this.world = world; // Register basic callbacks this.network[NetworkPhrase.RemoveBlock] = this.RemoveBlock; this.network[NetworkPhrase.SetBlock] = this.SetBlock; }