private void restart() { gameFactory.create(ScreenWidth, ScreenHeight, game => { this.game = game; this.ActiveControl = null; }); }
public void create(int screenWidth, int screenHeight, OnAsynCreate callback) { QuantumGame game = new QuantumGame(); QuantumMapBuilder mapBuilder = new QuantumMapBuilder(); game.start(mapBuilder.initializeMap(screenWidth, screenHeight), screenWidth, screenHeight); callback(game); }
private void CreateClientGame(QuantumModel model, int width, int height, OnAsynCreate callback) { QuantumGame game = new QuantumGame(); game.gameNetwork = network; game.AddController(new NetworkSync(false)); game.start(model, width, height); callback(game); }
private void CreateServerGame(int width, int height, OnAsynCreate callback) { currentTeam = (random.Next() % 2 == 0) ? Team.blue : Team.green; QuantumMapBuilder mapBuilder = new QuantumMapBuilder(); model = mapBuilder.initializeMap(width, height); ShareGameEvent shareGame = new ShareGameEvent(); shareGame.model = model; network.BroadcastMessage(shareGame); QuantumGame game = new QuantumGame(); game.gameNetwork = network; game.AddController(new NetworkSync(true)); game.start(model, width, height); callback(game); }
private void onKeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'h') { serverGameFactory.Listen(Width, Height, newGame => { this.gameFactory = serverGameFactory; this.game = newGame; }); MessageBox.Show("Waiting for second player.\nPlease. press ok to proceeded"); } if (e.KeyChar == 'j') { JoinWindow joinWindow = new JoinWindow(); joinWindow.ShowDialog(); String address = joinWindow.HostAddress; clientGameFactory.Join(Width, Height, address, newGame => { this.gameFactory = clientGameFactory; this.game = newGame; }); } if (e.KeyChar == 'r') { DialogResult result = MessageBox.Show("Are you sure want to restart game?", "Game restart", MessageBoxButtons.OKCancel); if (result == DialogResult.OK) { restart(); } } }