Beispiel #1
0
        private void btnJoin_Click(object sender, EventArgs e)
        {
            btnJoin.Enabled = false;

            Player p = GetPlayer();
            AddPlayer(p.Name);

            n = new Client(p, tbIpClient.Text, Int16.Parse(tbPortClient.Text));
            n.Controller = this;
            n.UpdateStatusEvent += new Networker.StringEventHandler(LogUpdateText);
            n.AddPlayerEvent += new Networker.StringEventHandler(AddPlayer);
            n.UpdateScoreEvent += new Networker.UpdateScoreEventHandler(DisplayScore);
            n.MessageEvent += new Networker.MessageEventHandler(MessageEvent);
            ((Client)n).GameStartEvent += new Client.GameStartEventHandler(GameStart);
            ((Client)n).Connect();
        }
Beispiel #2
0
        private void btnHost_Click(object sender, EventArgs e)
        {
            btnHost.Enabled = false;
            btnStart.Enabled = true;

            Player p = GetPlayer();
            AddPlayer(p.Name);

            n = new Host(p, "127.0.0.1", 2000);
            n.Controller = this;
            n.UpdateStatusEvent += new Networker.StringEventHandler(LogUpdateText);
            n.AddPlayerEvent += new Networker.StringEventHandler(AddPlayer);
            n.UpdateScoreEvent += new Networker.UpdateScoreEventHandler(DisplayScore);
            n.MessageEvent += new Networker.MessageEventHandler(MessageEvent);
            ((Host) n).StartListening();
        }