Ejemplo n.º 1
0
        // #############[  METHODS  ]####################################################



        public void CreateWaveControl()
        {
            Wave newWave = wManager.AddWave();


            ToolStripLabel wc_NameLabel = new ToolStripLabel(newWave.name);

            /*ToolStripButton wc_EditButton = new ToolStripButton("✎");
             *
             * ToolStripSeparator wc_Separator = new ToolStripSeparator();
             *
             * ToolStripButton wc_MoveUpButton = new ToolStripButton("🡅");
             *
             * ToolStripButton wc_MoveDownButton = new ToolStripButton("🡇");*/


            // NOTE: This part was scrapped because it is way too ambitious and I don't have time.

            //ToolStrip newWaveControl = new ToolStrip(
            //    wc_NameLabel,
            //    wc_EditButton,
            //    wc_Separator,
            //    wc_MoveUpButton,
            //    wc_MoveDownButton
            //    );


            // Here is the simplified version:
            ToolStrip newWaveControl = new ToolStrip(wc_NameLabel);


            newWaveControl.Visible = false;

            flowLayoutPanel1.Controls.Add(newWaveControl);


            int relativeHeight = w_Size.Height * wavePanels.Count;

            newWaveControl.Location = new Point(1, 1 + relativeHeight);


            newWaveControl.AutoSize = false;

            newWaveControl.Padding   = w_Padding;
            newWaveControl.Margin    = w_Margin;
            newWaveControl.Size      = w_Size;
            newWaveControl.BackColor = w_BackColor;


            wc_NameLabel.Margin = wLabel_Margin;
            wc_NameLabel.Size   = wLabel_Size;


            /*wc_EditButton.Size = wButton_Size;
             * wc_MoveUpButton.Size = wButton_Size;
             * wc_MoveDownButton.Size = wButton_Size;
             *
             *
             * wc_Separator.Margin = wSeparator_Margin;
             * wc_Separator.Size = wSeparator_Size;*/


            wavePanels.Add(newWaveControl);

            newWaveControl.Visible = true;

            newWaveControl.Click += waveControl_Click;


            SelectWavePanel(newWaveControl);
        }
Ejemplo n.º 2
0
        public void SaveWaveFile()
        {
            bool validGameExe = false;

            if (File.Exists("BuzzBattle.exe"))
            {
                gameExeFilePath = Path.GetFullPath("BuzzBattle.exe");
                validGameExe    = true;
            }
            else
            {
                if (gameExeFilePath == "" || File.Exists(gameExeFilePath) == false)
                {
                    OpenFileDialog findGameExeFileDialog = new OpenFileDialog();

                    findGameExeFileDialog.Title  = "Please locate the game's executable file (BuzzBattle.exe)";
                    findGameExeFileDialog.Filter = "Executable Files|*.exe";

                    findGameExeFileDialog.InitialDirectory = Directory.GetCurrentDirectory();

                    findGameExeFileDialog.CheckFileExists = true;
                    findGameExeFileDialog.CheckPathExists = true;

                    findGameExeFileDialog.DereferenceLinks = true;


                    if (findGameExeFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        if (File.Exists(findGameExeFileDialog.FileName))
                        {
                            if (findGameExeFileDialog.SafeFileName == "BuzzBattle.exe")
                            {
                                gameExeFilePath = findGameExeFileDialog.FileName;
                                validGameExe    = true;
                            }
                        }
                    }
                }
                else
                {
                    validGameExe = true;
                }
            }

            if (validGameExe)
            {
                DirectoryInfo newDirectoryInfo = Directory.GetParent(gameExeFilePath);

                string newDirPath = newDirectoryInfo.FullName;

                string currentDirectory = Directory.GetCurrentDirectory();

                if (currentDirectory != newDirPath)
                {
                    Directory.SetCurrentDirectory(newDirPath);
                }

                if (File.Exists("waves.txt"))
                {
                    File.Delete("waves.txt");
                }

                FileStream   outStream = File.OpenWrite("waves.txt");
                StreamWriter output    = new StreamWriter(outStream);

                int totalWaves = waveList.Count;

                output.WriteLine(totalWaves);

                Wave finalWave = waveList[totalWaves - 1];

                int finalWaveEnemyCount = 0;

                finalWaveEnemyCount += finalWave.top;
                finalWaveEnemyCount += finalWave.left;
                finalWaveEnemyCount += finalWave.right;
                finalWaveEnemyCount += finalWave.bottom;

                output.WriteLine(finalWaveEnemyCount);

                for (int i = 0; i < totalWaves; i++)
                {
                    Wave waveToSave = waveList[i];

                    string waveData = "";

                    if (waveToSave.name == null)
                    {
                        waveData += "null";
                    }
                    else
                    {
                        waveData += waveToSave.name;
                    }

                    waveData += ',';
                    waveData += waveToSave.top;
                    waveData += ',';
                    waveData += waveToSave.left;
                    waveData += ',';
                    waveData += waveToSave.right;
                    waveData += ',';
                    waveData += waveToSave.bottom;

                    output.WriteLine(waveData);
                }

                output.Close();
                outStream.Close();

                MessageBox.Show("The wave file has saved successfully!",
                                "File saved.",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 3
0
        public void LoadWaveFile()
        {
            bool   validWaveFile = false;
            string waveFilePath  = "";

            if (File.Exists("waves.txt"))
            {
                waveFilePath  = "waves.txt";
                validWaveFile = true;
            }
            else
            {
                OpenFileDialog findGameExeFileDialog = new OpenFileDialog();

                findGameExeFileDialog.Title  = "Please locate the save file (waves.txt)";
                findGameExeFileDialog.Filter = "Text Files|*.txt";

                findGameExeFileDialog.InitialDirectory = Directory.GetCurrentDirectory();

                findGameExeFileDialog.CheckFileExists = true;
                findGameExeFileDialog.CheckPathExists = true;

                findGameExeFileDialog.DereferenceLinks = true;


                if (findGameExeFileDialog.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(findGameExeFileDialog.FileName))
                    {
                        if (findGameExeFileDialog.SafeFileName == "waves.txt")
                        {
                            waveFilePath  = findGameExeFileDialog.FileName;
                            validWaveFile = true;
                        }
                    }
                }
            }

            if (validWaveFile)
            {
                DirectoryInfo newDirectoryInfo = Directory.GetParent(waveFilePath);

                string newDirPath = newDirectoryInfo.FullName;

                string currentDirectory = Directory.GetCurrentDirectory();

                if (currentDirectory != newDirPath)
                {
                    Directory.SetCurrentDirectory(newDirPath);
                }

                FileStream   inStream = File.OpenRead("waves.txt");
                StreamReader input    = new StreamReader(inStream);

                int totalWaves = int.Parse(input.ReadLine());

                int finalWaveEnemyCount = int.Parse(input.ReadLine());

                List <string[]> wavesAsStringArrays = new List <string[]>();

                string line = "";

                int totalWavesRead = 0;

                do
                {
                    line = input.ReadLine();

                    if (line != null && line != "")
                    {
                        string[] waveData = line.Split(',');
                        wavesAsStringArrays.Add(waveData);
                        totalWavesRead++;
                    }
                }while (line != null && line != "");

                input.Close();
                inStream.Close();

                if (totalWaves != totalWavesRead)
                {
                    throw new Exception("Discrepancy in wave quantities.");
                }

                int wpCount = mainWindow.wavePanels.Count;
                for (int w = 0; w < wpCount; w++)
                {
                    mainWindow.DeleteWave();
                }

                wavesAdded = 0;
                mainWindow.wavePanels.Clear();

                for (int i = 0; i < totalWaves; i++)
                {
                    mainWindow.AddWave();
                }

                for (int i = 0; i < totalWaves; i++)
                {
                    string[] waveArray = wavesAsStringArrays[i];

                    Wave newWave = waveList[i];

                    newWave.name = waveArray[0];

                    newWave.top    = int.Parse(waveArray[1]);
                    newWave.left   = int.Parse(waveArray[2]);
                    newWave.right  = int.Parse(waveArray[3]);
                    newWave.bottom = int.Parse(waveArray[4]);
                }

                selectedIndex = waveList.Count - 1;

                mainWindow.RefreshWaveNumText();

                MessageBox.Show("The wave file has loaded successfully!",
                                "File loaded.",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the 'name' of a specified wave.
        /// </summary>
        /// <param name="index">The wave's index</param>
        /// <returns>The wave's name (as a string)</returns>
        public string GetWaveName(int index)
        {
            Wave wave = waveList[index];

            return(wave.name);
        }