Exemplo n.º 1
0
        internal static void Initialize()
        {
            Console.Clear();

            int pos = 0;

            //Clear matrix
            Array.Clear(Dipendences.campoNostro, 0, Dipendences.campoNostro.GetLength(0) * Dipendences.campoNostro.GetLength(1));
            Array.Clear(Dipendences.campoNemico, 0, Dipendences.campoNemico.GetLength(0) * Dipendences.campoNemico.GetLength(1));

            Game_Form.Put p = new Game_Form.Put(); //Chiedi le posizioni
            p.ShowDialog();

            foreach (int n in Dipendences.x) //Inserisci le posizioni dentro la matrice
            {
                Dipendences.campoNostro[n, Dipendences.y[pos]] = Dipendences.defStatus;

                pos++;
            }

            Instruments.GMMessage("Initializing AI.....");

            AI.Intialize();

            Console.Clear();

            Aggiorna();

            //Il primo turno è il mio

            Console.ReadKey();
        }
Exemplo n.º 2
0
        /*
         * Programmers: Leonardo Baldazzi, Tommaso Brandinelli
         * Company: OSS inc.
         * Program summary: Simulating Battleship Online via MYSQL Database
         * SubProgram summary: Log-In/Sign-Up user, download '.conf' files, check for updates
         * Class summary: Check for update, if true show progress bar and download
         *
         * Copyright (c) 2018-20 - All Rights Reserved
         */
        internal static void Check()
        {
            bool isChecked = true;

            /*
             * //Download lastest version file
             * var downloadClient = new WebClient();
             * downloadClient.DownloadFile(Dipendences.lastVersionFile, @"C:\Battleship Online\ver.txt");
             *
             * string[] versionDownloaded = System.IO.File.ReadAllLines(@"C:\Battleship Online\ver.txt");
             *
             * if(versionDownloaded[0] == Dipendences.version) //Check if this is the lastes version
             * {
             *  isChecked = false;
             * }
             *
             */

            if (!isChecked)
            {
                //Show update form
                Changelog ch = new Changelog();
                ch.ShowDialog();
            }
            else
            {
                Instruments.GMMessage("This is the lastest version!");
            }
        }
Exemplo n.º 3
0
        private static void Aspetta(int v) //Aspetta qualcosa
        {
            if (v == 0)                    //Aspetta la posizione delle navi
            {
                int c = 0;

                Instruments.GMMessage("I'm waiting for the ships...");

                while (true)
                {
                    //Conta quante sono le posizioni
                    MySql.Usr.command.CommandText = "SELECT * FROM `Posizioni` WHERE `username` = '" + Dipendences.enemyUsername + "'";
                    MySqlDataReader readPos = MySql.Usr.command.ExecuteReader();

                    MySql.Usr.table.Load(readPos);

                    c = MySql.Usr.table.Rows.Count;

                    readPos.Close();

                    if (c == Dipendences.HOW_MANY_SHIPS)
                    {
                        MySql.Usr.table.Clear();


                        Console.Clear();
                        break;
                    }

                    MySql.Usr.table.Clear();
                }
            }
        }
Exemplo n.º 4
0
        internal static void Intialize()
        {
            //Spawn random pisitions....
            int x, y;

            Random rn = new Random();

            Instruments.GMMessage("Generazione navi random...");

            for (int i = 0; i < Dipendences.HOW_MANY_SHIPS; i++) //Genera le coordinate
            {
rifai:
                x = rn.Next(0, Dipendences.campoNemico.GetLength(0));
                y = rn.Next(0, Dipendences.campoNemico.GetLength(1));

                if (Dipendences.campoNemico[x, y] == Dipendences.defStatus)
                {
                    goto rifai;
                }

                Dipendences.campoNemico[x, y] = Dipendences.defStatus; //Inserisci la posizione dentro il campo nemico
            }
        }