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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public void Listen(int width, int height, OnAsynCreate callback)
        {
            if (inProgress)
            {
                return;
            }

            inProgress = true;
            network.Listen(7777, () =>
            {
                CreateServerGame(width, height, callback);
            });
        }
예제 #4
0
        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);
            });
        }
예제 #5
0
        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);
            });
        }
예제 #6
0
        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);
        }
예제 #7
0
 public void create(int screenWidth, int screenHeight, OnAsynCreate callback)
 {
 }
예제 #8
0
 public void create(int screenWidth, int screenHeight, OnAsynCreate callback)
 {
     CreateServerGame(screenWidth, screenHeight, callback);
 }