Ejemplo n.º 1
0
        public void UpdateValues(string msg)
        {
            // Check for seed
            string SeedRegex = "seed:([0-9]{1,})";
            Match  seedMatch = Regex.Match(msg, SeedRegex);

            // Check if we have a seed
            if (seedMatch.Value != String.Empty)
            {
                int levelSeed = int.Parse(seedMatch.Groups[1].Value);
                this.field = new BG_Field(MainForm.Width - 180, MainForm.Height - 24, levelSeed);
            }


            // Check for moving players
            string          MoveRegex   = "\\(([^,;.]+);([0-9]{1,3});([0-9]{1,3})\\)";
            MatchCollection moveMatches = Regex.Matches(msg, MoveRegex);

            foreach (Match match in moveMatches)
            {
                string[] MoveValues = Regex.Split(match.Value, MoveRegex);

                string name = MoveValues[1];
                int    x    = int.Parse(MoveValues[2]);
                int    y    = int.Parse(MoveValues[3]);

                BG_Cannon currentPlayerCannon = new BG_Cannon(Color.Red, new BG_Location(x, y));
                BG_Player currentPlayer       = new BG_Player(name, currentPlayerCannon);

                this.listPlayers.Add(currentPlayer);
            }


            // Check for new turn
            string newTurnRegex = "[^,.-]{1,};newturn";
            Match  newTurnMatch = Regex.Match(msg, newTurnRegex);

            // Check if we have to start a new turn
            if (newTurnMatch.Value == (this.Name + ";" + "newturn"))
            {
                // Start the turn
            }


            // Check for end turn
            string testStr      = "endturn";
            string endTurnRegex = "^endturn$";
            Match  endTurnMatch = Regex.Match(testStr, endTurnRegex);

            // Check if we have to start a new turn
            if (endTurnMatch.Value == "endturn")
            {
                // End the turn
            }
        }
Ejemplo n.º 2
0
        public BG_Client(string serverAddress, int port, string name, FrmView view)
        {
            // Create a non-connected TcpClient
            this.TcpClient = new TcpClient();
            this.TcpClient.SendBufferSize    = this.BufferSize;
            this.TcpClient.ReceiveBufferSize = this.BufferSize;
            this.Running = false;

            // Set the other things
            this.ServerAddress = serverAddress;
            this.Port          = port;
            this.Name          = name;
            this.MainForm      = view;

            this.listPlayers = new List <BG_Player>();
            this.field       = new BG_Field(MainForm.Width, MainForm.Height, 0);
        }