Exemple #1
0
        void Start()
        {
            marakeshServer = new FakeMarakeshServer(playersCount);
            my_player_id   = marakeshServer.GetMyPlayerID();
            marakeshServer.activePlayerChanged += delegate { current_player_id = marakeshServer.GetActivePlayerId(); };

            mainCamera = Camera.main;
            map        = new Map();

            selectionOrientation = SelectionOrientation.Horizontal;

            orientationLength = System.Enum.GetValues(typeof(SelectionOrientation)).Length;

            marakeshModelController = new MarakeshModelController(marakeshModel, map.GetTile(new Vector2Int(map.size / 2, map.size / 2)));

            currentState    = GameState.Move;
            gameStateLength = System.Enum.GetValues(typeof(GameState)).Length;

            marakeshModelController.move_finished += GoToNextGameState;
        }
        void Start()
        {
            var serverCancellationTokenSource = new CancellationTokenSource(6000);

            marakeshServer = new MarakeshServer();

            //TODO: moe this to UI button
            Task.Run(() =>
            {
                marakeshServer.StartServer(serverCancellationTokenSource.Token);
                Debug.Log($" marakeshServer.StartServer ");
            });

            marakeshClient = new MarakeshServerClient(marakeshServer.IpAddress);
            var clientCancellationTokenSource = new CancellationTokenSource(3000);

            //TODO: moe this to UI button
            Task.Run(async() =>
            {
                var playerCount = await marakeshClient.GetPlayerCount(clientCancellationTokenSource.Token);
                Debug.Log($" playerCount {playerCount}");
            });
            //TODO: catch exceptions


            mainCamera = Camera.main;
            map        = new Map();

            selectionOrientation = SelectionOrientation.Horizontal;

            orientationLength = System.Enum.GetValues(typeof(SelectionOrientation)).Length;

            marakeshModelController = new MarakeshModelController(marakeshModel, map.GetTile(new Vector2Int(map.size / 2, map.size / 2)));

            currentState    = GameState.Move;
            gameStateLength = System.Enum.GetValues(typeof(GameState)).Length;

            marakeshModelController.move_finished += GoToNextGameState;
        }