Example #1
0
        public void ConnectTo(System.Net.IPAddress ip, int port)
        {
            DisposeCommunication();
            Client client = new Client(ip, port);
            _communication = client;
            KaroGameManager = new KaroCommunicatedGameManager(_communication);

            // Attach handlers
            KaroGameManager.OnPlayerWin += PlayerWon;
            client.OnConnectionFailed += ConnectionFailed;
            AddGlobalHandlers();

            _communication.StartCommunicating();
            AddGameComponents();
        }
Example #2
0
        public void StartOnlineGame(int modus)
        {
            if (modus == 0) // client
            {
                Components.Add(new ConnectComponent(this));
                return;
            }
            if(modus == 1){ // server
                DisposeCommunication();
                _communication = new Server(43594);
                _communication.Connected += ConnectionSucceed;
                AddGlobalHandlers();
                KaroGameManager = new KaroCommunicatedGameManager(_communication);
                KaroGameManager.OnPlayerWin += PlayerWon;
                Components.Add(new MessageComponent(this, "Waiting for opponent...", "Hit enter to cancel", new MenuComponent(this)));
                return;
            }
            if(modus == 2){
                // play with yourself
                DisposeCommunication();
                if(otherMeServer != null){
                    otherMeServer.CleanUp();
                }
                otherMeServer = new Server(43594);
                otherMe = new KaroCommunicatedGameManager(otherMeServer);
                // change number to change openent
                // 0: mimax ai (slowest possible)
                // 1: alfa beta ai
                // 2: moverordering ab ai
                // >=3: move ordering alfa beta transpositiontable ai

                // the other me is configurable but connecto ai always uses the best one
                // the best one is with the longest name
                otherMe.Game.SetAI(0);
                otherMe.name = "Messed up ai";
                ConnectTo(IPAddress.Parse("127.0.0.1"), 43594);
            }
        }