Exemplo n.º 1
0
 private void btn_initTCP_Click(object sender, EventArgs e)
 {
     Network.ConnectionPort = Int32.Parse(txt_conPort.Text);
     tcp = Network.getNetwork();
     txt_output.AppendText(tcp.tcp_initialiseServer());
     btn_initTCP.Enabled   = false;
     btn_listenTCP.Enabled = true;
     decoder = new Messages(ConnectedClients);
 }
Exemplo n.º 2
0
        public GameSession(Client player1, Client player2, Messages decoder)
        {
            noOfSessions++;
            gameID = noOfSessions;
            Server.gameSessions.Add(this);

            p1ready      = p2ready = false;
            this.players = new List <Client>();
            this.players.Add(player1);
            this.players.Add(player2);
            sessionDecoder = new GSMessages(this.players[0], this.players[1], gameID);
            tcp            = Network.getNetwork();

            //Assign first turn
            //0 = false - p2 turn
            //1= true - p1 turn
            Random random = new Random();
            int    turn   = random.Next(2);

            p1Turn = Convert.ToBoolean(turn);

            //Generate Seed
            //populate List with available symbols
            List <String> icons = new List <string>()
            {
                "!", "!", "N", "N", ",", ",", "k", "k",
                "b", "b", "v", "v", "w", "w", "z", "z"
            };

            //assign random icon to each label card
            string seed = "";

            for (int i = 0; i < 16; i++)
            {
                int iconIndex = random.Next(icons.Count);
                seed = seed + icons[iconIndex];
                icons.RemoveAt(iconIndex);
            }

            sessionDecoder.gameInitialisation(p1Turn, seed);
        }
Exemplo n.º 3
0
 public Messages()
 {
     this.tcp = Network.getNetwork();
 }
Exemplo n.º 4
0
 public Messages(List <Client> connectedClients)
 {
     this.tcp = Network.getNetwork();
     this.ConnectedClients = connectedClients;
 }