コード例 #1
0
        //nao sera mais necessario
        public void UpdateBoardInfo()
        {
            string board = Jogo.ExibirTabuleiro(gameId);

            if (board != "" && board != null)
            {
                string[] data = new string[50];
                data          = board.Replace("\r", "").Split('\n');
                ClimbersInUse = 0;
                for (int i = 0; i < 11; i++)
                {
                    for (int j = 0; j < 13; j++)
                    {
                        PlayerBases[i, j, 0] = 0;
                    }
                }
                foreach (string LineData in data)
                {
                    if (LineData != null && LineData != "")
                    {
                        string[] bInfo = new string[4];
                        bInfo = LineData.Split(',');
                        //se eh alpinista
                        if (bInfo[3] == "A")
                        {
                            ClimbersPos[ClimbersInUse, 0] = (Int32.Parse(bInfo[0]) - 2);
                            ClimbersPos[ClimbersInUse, 1] = (Int32.Parse(bInfo[1]) - 1);
                            ClimbersInUse++;
                        }
                        //se eh base
                        else
                        {
                            int col = (Int32.Parse(bInfo[0]) - 2); //a primeira coluna eh o 2.
                            int row = (Int32.Parse(bInfo[1]) - 1); //a primeira linha eh o 1.
                            //atualza a matriz de bases do jogador (usada pelo bot)
                            if (currentPlayer[0] == bInfo[2])
                            {
                                PlayerBases[col, row, 0] = 1;
                            }
                        }
                    }
                }
            }
        }
        static public List <Customer> GetCustomersList()
        {
            string virtualFilePath      = "~/Storage/Customers.txt";
            string physicalFileLocation = HttpContext.Current.Server.MapPath(virtualFilePath);

            string[] FileData = System.IO.File.ReadAllLines(physicalFileLocation);

            List <Customer> list1 = new List <Customer>();

            foreach (string LineData in FileData)
            {
                string[] arrCus      = LineData.Split(',');
                Customer NewCustomer = new Customer();
                NewCustomer.Name         = arrCus[0];
                NewCustomer.Age          = arrCus[2];
                NewCustomer.subscription = arrCus[1];
                list1.Add(NewCustomer);
            }
            return(list1);
        }
コード例 #3
0
        static public List <Movie> GetMoviesList()
        {
            string virtualFilePath      = "~/Storage/Movies.txt";
            string physicalFileLocation = HttpContext.Current.Server.MapPath(virtualFilePath);

            string[] FileData = System.IO.File.ReadAllLines(physicalFileLocation);

            List <Movie> list = new List <Movie>();

            foreach (string LineData in FileData)
            {
                string[] arr      = LineData.Split(',');
                Movie    NewMovie = new Movie();
                NewMovie.Name     = arr[0];
                NewMovie.Category = arr[1];

                list.Add(NewMovie);
            }
            return(list);
        }
        static public bool DoseRentalSucceeded(string RentName)
        {
            string virtualFilePath      = "~/Storage/Rentals.txt";
            string physicalFileLocation = HttpContext.Current.Server.MapPath(virtualFilePath);

            string[] FileData = System.IO.File.ReadAllLines(physicalFileLocation);

            string[] arr;

            bool exist = false;

            foreach (string LineData in FileData)
            {
                arr = LineData.Split(',');
                if (arr[1] == RentName)
                {
                    exist = true;
                    break;
                }
            }
            return(exist);
        }
        static public List <Rental> GetRentalList()
        {
            string virtualFilePath      = "~/Storage/Rentals.txt";
            string physicalFileLocation = HttpContext.Current.Server.MapPath(virtualFilePath);

            string[] FileData = System.IO.File.ReadAllLines(physicalFileLocation);

            List <Rental> list = new List <Rental>();

            foreach (string LineData in FileData)
            {
                if (LineData != "-")
                {
                    string[] arr         = LineData.Split(',');
                    Rental   RentedMovie = new Rental();

                    RentedMovie.NameOfcustomer = arr[0];
                    RentedMovie.NameOfMovie    = arr[1];

                    list.Add(RentedMovie);
                }
            }
            return(list);
        }
コード例 #6
0
        public void SpawnBases(string boardData)
        {
            //evitar crash caso a string venha vazia.
            if (boardData != "" && boardData != null)
            {
                // bases[coluna, linha, cores + numero de jogadores na base]
                string[,,] c_bases = new string[11, 13, 5];
                // 11*4 + 3 = 47 bases possiveis.
                string[] data = new string[50];
                data = boardData.Replace("\r", "").Split('\n');
                //reseta para nao perder a contagem correta!
                climbers = 3;
                //reseta variaveis do jogador.
                for (int i = 0; i < 11; i++)
                {
                    for (int j = 0; j < 13; j++)
                    {
                        playerBases[i, j, 0] = 0;
                    }
                }
                //reseta variaveis dos inimigos.
                for (int i = 0; i < 11; i++)
                {
                    for (int j = 0; j < 13; j++)
                    {
                        enemyBases[i, j, 0] = 0;
                    }
                }

                foreach (string LineData in data)
                {
                    if (LineData != null && LineData != "")
                    {
                        string[] bInfo = new string[4];
                        bInfo = LineData.Split(',');
                        //se eh alpinista
                        if (bInfo[3] == "A")
                        {
                            MoveClimber(bInfo);
                        }
                        else
                        {
                            int col = (Int32.Parse(bInfo[0]) - 2); //a primeira coluna eh o 2.
                            int row = (Int32.Parse(bInfo[1]) - 1); //a primeira linha eh o 1.
                            //atualiza a matriz de bases do jogador (usada pelo bot)
                            if (currentPlayer[0] == bInfo[2])
                            {
                                playerBases[col, row, 0] = 1;
                            }
                            else
                            {
                                enemyBases[col, row, 0] = 1;
                            }


                            //se ja tiver jogadores naquela base
                            if (c_bases[col, row, 4] != "" && c_bases[col, row, 4] != null)
                            {
                                string[] p_colors = new string[4];
                                switch (Int32.Parse(c_bases[col, row, 4]))
                                {
                                case 1:
                                    //divide o circulo ao meio, segundo a ordem de prioridade
                                    if (ColorRank[c_bases[col, row, 0]] > ColorRank[PlayersColor[Int32.Parse(bInfo[2])]])
                                    {
                                        p_colors[0] = c_bases[col, row, 0];
                                        p_colors[1] = PlayersColor[Int32.Parse(bInfo[2])];
                                    }
                                    else
                                    {
                                        p_colors[0] = PlayersColor[Int32.Parse(bInfo[2])];
                                        p_colors[1] = c_bases[col, row, 0];
                                    }
                                    //refazer essas repeticoes com for?
                                    bases[col, row, 0].Image = Image.FromFile(res_path + p_colors[0] + "_tl.png");
                                    bases[col, row, 1].Image = Image.FromFile(res_path + p_colors[0] + "_tr.png");
                                    bases[col, row, 2].Image = Image.FromFile(res_path + p_colors[1] + "_bl.png");
                                    bases[col, row, 3].Image = Image.FromFile(res_path + p_colors[1] + "_br.png");

                                    bases[col, row, 0].Show();
                                    bases[col, row, 1].Show();
                                    bases[col, row, 2].Show();
                                    bases[col, row, 3].Show();

                                    //Atualiza informacoes sobre as casas (cores e numero de bases)
                                    c_bases[col, row, 4] = (Int32.Parse(c_bases[col, row, 4]) + 1).ToString();
                                    c_bases[col, row, 0] = p_colors[0];
                                    c_bases[col, row, 1] = p_colors[1];

                                    break;

                                case 2:
                                    //se a cor nova tiver valor de prioridade maior que a mais alta.
                                    if (ColorRank[c_bases[col, row, 0]] < ColorRank[PlayersColor[Int32.Parse(bInfo[2])]])
                                    {
                                        p_colors[0] = PlayersColor[Int32.Parse(bInfo[2])];
                                        p_colors[1] = c_bases[col, row, 0];
                                        p_colors[2] = c_bases[col, row, 1];
                                    }
                                    else
                                    {
                                        //se a cor nova tiver valor de prioridade mais alta que a segunda.
                                        if (ColorRank[c_bases[col, row, 1]] < ColorRank[PlayersColor[Int32.Parse(bInfo[2])]])
                                        {
                                            p_colors[0] = c_bases[col, row, 0];
                                            p_colors[1] = PlayersColor[Int32.Parse(bInfo[2])];
                                            p_colors[2] = c_bases[col, row, 1];
                                        }
                                        else
                                        {
                                            p_colors[0] = c_bases[col, row, 0];
                                            p_colors[1] = c_bases[col, row, 1];
                                            p_colors[2] = PlayersColor[Int32.Parse(bInfo[2])];
                                        }
                                    }
                                    bases[col, row, 0].Image = Image.FromFile(res_path + p_colors[0] + "_tl.png");
                                    bases[col, row, 1].Image = Image.FromFile(res_path + p_colors[0] + "_tr.png");
                                    bases[col, row, 2].Image = Image.FromFile(res_path + p_colors[1] + "_bl.png");
                                    bases[col, row, 3].Image = Image.FromFile(res_path + p_colors[2] + "_br.png");

                                    bases[col, row, 0].Show();
                                    bases[col, row, 1].Show();
                                    bases[col, row, 2].Show();
                                    bases[col, row, 3].Show();
                                    //atualiza o numero de bases na casa
                                    c_bases[col, row, 4] = (Int32.Parse(c_bases[col, row, 4]) + 1).ToString();
                                    break;

                                case 3:
                                    //segundo a ordem de prioridade da pra prever a forma que ficaria com 4 bases.
                                    bases[col, row, 0].Image = Image.FromFile(res_path + "red_tl.png");
                                    bases[col, row, 1].Image = Image.FromFile(res_path + "blue_tr.png");
                                    bases[col, row, 2].Image = Image.FromFile(res_path + "green_bl.png");
                                    bases[col, row, 3].Image = Image.FromFile(res_path + "yellow_br.png");

                                    bases[col, row, 0].Show();
                                    bases[col, row, 1].Show();
                                    bases[col, row, 2].Show();
                                    bases[col, row, 3].Show();
                                    break;
                                }
                            }
                            else
                            {
                                //adicionar a primeira base normalmente
                                string[] sprite_pos = new string[] { "tl", "tr", "bl", "br" };
                                for (int i = 0; i < 4; i++)
                                {
                                    bases[col, row, i].Image = Image.FromFile(res_path + PlayersColor[Int32.Parse(bInfo[2])] + "_" + sprite_pos[i] + ".png");
                                    bases[col, row, i].Show();
                                }
                                c_bases[col, row, 4] = "1";
                                c_bases[col, row, 0] = PlayersColor[Int32.Parse(bInfo[2])];
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                //atualiza as bases para o botAI
                if (bot == "pc")
                {
                    botAI.EnemyBases  = enemyBases;
                    botAI.PlayerBases = playerBases;
                }
            }
        }