Exemplo n.º 1
0
 public Coin createCoin(int x, int y, int t, int value)
 {
     Coin coin = new Coin(x, y, t, value);
     coins.Add(coin);
     return coin;
 }
Exemplo n.º 2
0
        public void decode(String str)
        {
            if(str.StartsWith("S:")){
                int length=str.Length;
                String str1=str.Substring(2,length-3);
                String[] temp=str1.Split(new char[] {':'});

                foreach(String s in temp )
                    createPlayer(s);

            }

            if (str.StartsWith("I:")) {
                int i = 0;
                int length = str.Length;
                String str1 = str.Substring(2,length - 3);
                myId = Convert.ToInt32(str.Substring(3, 1));
                Console.WriteLine("ME: P" + myId);
                String[] temp = str1.Split(new char[] { ':' });

                foreach (String tempStr in temp) {
                    if (tempStr.StartsWith("P")) {
                        i++;
                    }
                }

                String[] bricksList = temp[i].Split(new char[] {';'});

                foreach (String tempStr in bricksList) {
                    createBricks(tempStr);
                }

                String[] stonesList = temp[i+1].Split(new char[] { ';' });

                foreach (String tempStr in stonesList) {
                    createStone(tempStr);
                }

                String[] waterList = temp[i+2].Split(new char[] { ';' });

                foreach (String tempStr in waterList) {
                    createWater(tempStr);
                }
            }

            if (str.StartsWith("C:"))
            {
                int length = str.Length;
                String str1 = str.Substring(2, length - 3);
                String[] temp = str1.Split(new char[] { ':' });

                String[] cor = temp[0].Split(new char[] {','});
                int x = Convert.ToInt32(cor[0]);
                int y = Convert.ToInt32(cor[1]);
                int time = Convert.ToInt32(temp[1]);
                int value = Convert.ToInt32(temp[2]);
                coin = createCoin(x, y, time, value);

            }

            if (str.StartsWith("L:"))
            {
                int length = str.Length;
                String str1 = str.Substring(2, length - 3);
                String[] temp = str1.Split(new char[] { ':' });

                String[] cor = temp[0].Split(new char[] { ',' });

                int x = Convert.ToInt32(cor[0]);
                int y = Convert.ToInt32(cor[1]);
                int time = Convert.ToInt32(temp[1]);
                life = createLife(x, y, time);

            }

            if (str.StartsWith("G:"))
            {
                int k = 0;
                int length = str.Length;
                String str1 = str.Substring(2, length - 3);
                String[] temp = str1.Split(new char[] { ':' });

                foreach (String tempStr in temp) {
                    if (tempStr.StartsWith("P")) {
                        k++;
                        updatePlayer(tempStr);
                    }
                }

                String[] temp1 = temp[k].Split(new char[] { ';' });
                foreach (String tempStr in temp1)
                {
                    updateBrick(tempStr);
                }

            }
        }