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); }
public void Listen(int width, int height, OnAsynCreate callback) { if (inProgress) { return; } inProgress = true; network.Listen(7777, () => { CreateServerGame(width, height, callback); }); }
public void Join(int width, int height, String host, OnAsynCreate callback) { if (inProgress) { return; } inProgress = true; network.Join(host, 7777); network.HandleEvent(() => { OnEvent(width, height, callback); }); }
private void OnEvent(int width, int height, OnAsynCreate callback) { object message = network.TakeFirst(); if (message is ShareGameEvent) { ShareGameEvent shareMessage = (ShareGameEvent)message; CreateClientGame(shareMessage.model, width, height, callback); return; } network.HandleEvent(() => { OnEvent(width, height, callback); }); }
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); }
public void create(int screenWidth, int screenHeight, OnAsynCreate callback) { }
public void create(int screenWidth, int screenHeight, OnAsynCreate callback) { CreateServerGame(screenWidth, screenHeight, callback); }