public void RunClient(object ipAddress)
        {
            client = new TcpClient(ipAddress.ToString(), 6969);

            while (true)
            {
                JObject received = TcpReadWrite.Read(client);
                string  command  = (string)received["command"];

                switch (command)
                {
                case "id":
                    form.Invoke(new Action(() => form.GetId(TcpProtocol.ReadId(received))));
                    break;

                case "questionScores":
                    form.Invoke(new Action(() => form.HandleQuestionsScores(TcpProtocol.QuestionAndScoreParse(received))));
                    break;

                case "endScores":
                    form.Invoke(new Action(() => form.HandleEndGame(TcpProtocol.EndScoresParse(received))));
                    client.GetStream().Close();
                    client.Close();
                    return;
                }
            }
        }
Beispiel #2
0
        public override void Update(ClientForm cf, Entity e)
        {
            Coin c = (Coin)e;

            if (c.Consumed && !_consumed)
            {
                cf.Invoke(new RemoveFormControlDelegate(cf.RemoveGamePanelControl), _p, _pb);
                _consumed = true;
            }
            else if (!c.Consumed && _consumed)
            {
                ReInit(e);
            }
        }
 protected void Debug(string str)
 {
     parent.Invoke(parent.debug, new Object[] { str });
 }
 public void UpdateScore(Player p)
 {
     _cf.Invoke(new UpdatePlayerScoreDelegate(_cf.UpdatePlayerScore), p.Score);
 }
Beispiel #5
0
 public override void Update(ClientForm cf, Entity e)
 {
     cf.Invoke(new UpdateFormControlPositionDelegate(cf.UpdateControlPosition), _pb,
               new Point(e.x - e.hitboxRadius, e.y - e.hitboxRadius));
 }