Example #1
0
        public void preencherCentro(string txt)
        {
            this.centro = new Centro();
            txt         = txt.Replace("\r", ""); //corta o caracter /r do retorno
            string[] cent = txt.Split('\n');     //Separa as linhas do retorno

            this.centro.azulejos = new List <Azulejo>();

            cent = cent.Take(cent.Count() - 1).ToArray();//Remove o elemento fantasma

            string[] checa1 = cent[0].Split(',');

            if (Convert.ToBoolean(Convert.ToInt16(checa1[3])))
            {
                Azulejo a = new Azulejo();
                a.id         = 0;
                a.quantidade = 1;
                //this.centro.marca1 = Convert.ToBoolean(Convert.ToInt16(itens[3]));
                a.DefinirCor();
                this.centro.azulejos.Add(a);
            }

            for (int i = 0; i < 5; i++)
            {
                string[] itens = cent[i].Split(',');
                Azulejo  a     = new Azulejo();
                a.id         = Convert.ToInt32(itens[0]);
                a.quantidade = Convert.ToInt32(itens[2]);
                //this.centro.marca1 = Convert.ToBoolean(Convert.ToInt16(itens[3]));
                a.DefinirCor();
                this.centro.azulejos.Add(a);
            }
        }
Example #2
0
        public void preencherFabricas(string txt)
        {
            this.fabricas = new List <Fabrica>();
            txt           = txt.Replace("\r", "");        //corta o caracter /r do retorno
            string[] fabs = txt.Split('\n');              //Separa as linhas do retorno

            fabs = fabs.Take(fabs.Count() - 1).ToArray(); //Remove o elemento fantasma

            int p = 0;

            for (int i = 1; i <= this.qtdFabricas; i++)    //Controla as fábricas
            {
                Fabrica fabrica = new Fabrica();
                fabrica.azulejos = new List <Azulejo>();
                fabrica.id       = i;

                while (p != fabs.Length && i == Convert.ToInt32(fabs[p].Substring(0, 1)))    //Controla o azulejo
                {
                    Azulejo azul = new Azulejo();
                    azul.id         = Convert.ToInt32(fabs[p].Substring(2, 1));
                    azul.quantidade = Convert.ToInt32(fabs[p].Substring(fabs[p].Length - 1, 1)); //Lê o último caractere e pega a quantidade

                    azul.DefinirCor();                                                           //Define a imagem do Azulejo

                    p++;

                    fabrica.azulejos.Add(azul);
                }

                //Definir o x y das fábricas aqui

                this.fabricas.Add(fabrica);
            }
        }
Example #3
0
        public void preencherTabuleiro(int id, string senha)
        {
            this.tabuleiro        = new Tabuleiro();
            this.tabuleiro.modelo = new Azulejo[5];
            this.tabuleiro.chao   = new List <Azulejo>();
            this.tabuleiro.parede = new bool[5, 5];


            string txt = Jogo.LerTabuleiro(id, senha, this.id);

            Console.WriteLine("li tabuleiro");

            txt = txt.Replace("\r", "");             //corta o caracter /r do retorno
            string[] txtTabuleiro = txt.Split('\n'); //Separa as linhas do retorno

            int l = 1;                               //Começa em 1 pra pular o texto modelo

            while (txtTabuleiro[l].Substring(0, 1) != "p")
            {
                string[] linha = txtTabuleiro[l].Split(',');
                Azulejo  a     = new Azulejo();
                a.id = Convert.ToInt32(linha[1]);
                a.DefinirCor();
                a.quantidade = Convert.ToInt32(linha[2]);

                this.tabuleiro.modelo[Convert.ToInt32(linha[0]) - 1] = a;
                l++;
            }

            l++; //Pula o texto parede

            while (txtTabuleiro[l].Substring(0, 1) != "c")
            {
                string[] linha = txtTabuleiro[l].Split(',');

                this.tabuleiro.parede[Convert.ToInt32(linha[0]) - 1, Convert.ToInt32(linha[1]) - 1] = true;
                l++;
            }

            l++; //Pula o texto chão

            while (!txtTabuleiro[l].Equals(""))
            {
                string[] linha = txtTabuleiro[l].Split(',');
                Azulejo  a     = new Azulejo();
                a.id = Convert.ToInt32(linha[1]);
                a.DefinirCor();

                this.tabuleiro.chao.Add(a);
                l++;
            }
        }