Beispiel #1
0
        // parse engine input and update the game state
        private void parseUpdate(List <string> input)
        {
            // do some stuff first

            foreach (string line in input)
            {
                if (line.Length <= 0)
                {
                    continue;
                }

                string[] tokens = line.Split();

                if (tokens.Length >= 3)
                {
                    int row = int.Parse(tokens[1]);
                    int col = int.Parse(tokens[2]);

                    if (tokens[0].Equals("a"))
                    {
                        state.addAnt(row, col, int.Parse(tokens[3]));
                    }
                    else if (tokens[0].Equals("f"))
                    {
                        state.addFood(row, col);
                    }
                    else if (tokens[0].Equals("r"))
                    {
                        state.removeFood(row, col);
                    }
                    else if (tokens[0].Equals("w"))
                    {
                        state.addWater(row, col);
                    }
                    else if (tokens[0].Equals("d"))
                    {
                        state.deadAnt(row, col);
                    }
                }
            }
        }