Esempio n. 1
0
        public void handle()
        {
            TcpClient       soc = new TcpClient(ip, port);
            NetworkStream   ns  = soc.GetStream();
            StreamReader    sr  = new StreamReader(ns);
            StreamWriter    sw  = new StreamWriter(ns);
            BinaryFormatter bf  = new BinaryFormatter();


            //communicate with server
            bool isWaiting = true;

            while (isWaiting)
            {
                //                Opponent opponent = (Opponent)bf.Deserialize(ns);
                //                Console.WriteLine("Your Opponent Port is " + opponent.Ip.Port);
                String              msg       = sr.ReadLine();
                String[]            op        = msg.Split(',');
                IPEndPoint          opIp      = new IPEndPoint(IPAddress.Parse(op[0]), Convert.ToInt32(op[1]));
                Opponent.PlayerType type      = op[2] == "T" ? Opponent.PlayerType.Top : Opponent.PlayerType.Bottom;
                IPEndPoint          currentIp = new IPEndPoint(IPAddress.Parse(op[3]), Convert.ToInt32(op[4]));
                Application.Run(new GameForm(new Opponent(opIp, type, currentIp)));

                isWaiting = false;
            }
            Console.WriteLine("stop");


            sr.Close();
            sw.Close();
            soc.Close();
        }
Esempio n. 2
0
        public Player(float defaultX, float defaultY, Color innerColor, Color outerColor, Opponent.PlayerType type) : base(defaultX, defaultY, innerColor, outerColor)
        {
            brush = new SolidBrush(innerColor);
            pen   = new Pen(outerColor, 100);

            this.type   = type;
            this.width  = radius * 2;
            this.height = radius * 2;

            X = defaultX;
            Y = defaultY;
        }