示例#1
0
 public FormController(IView theView, Game theGame, FileHandler thefiler, LevelBuilder thebuilder)
 {
     view = theView;
     game = theGame;
     filer = thefiler;
     builder = thebuilder;
 }
示例#2
0
        public void SetText(string newText)
        {
            theFile = newText;

            if (filer == null)
            {
                filer = new FileHandler();
                filer.Init();
            }

            mapTested = false;
            mapValid = false;
            tbxPreview.Location = new Point(15, 15);
            tbxPreview.Text = filer.LoadTextFile(theFile);
            //tbxPreview.Font = new Font("Courier", 15);
            tbxPreview.ScrollBars = ScrollBars.Both;
            SetTbxDimensions();
            tbxPreview.WordWrap = false;
            tbxPreview.ReadOnly = true;

            lblResult.Text = "";
            lblResult.Location = new Point(tbxPreview.Location.X, tbxPreview.Location.Y + tbxPreview.Size.Height + 20);

            btnTestMap.Location = new Point(tbxPreview.Location.X, lblResult.Location.Y + lblResult.Size.Height + 60);
        }
示例#3
0
        public void Init(int theList, string newMap)
        {
            currentMap = newMap;
            currentList = theList;
            filer = new FileHandler();
            game = new Game();
            mediaPath = @"H:\2015\semester 2\PR 283 C#\Theseus\TheseusFormed - Test\media";

            filer.Init();
            filer.SetMap(theList, newMap);
            game.SetFiler(filer);
            LoadMap();
        }
示例#4
0
        public void Init(int theList, string newMap)
        {
            currentMap = newMap;
            currentList = theList;
            filer = new FileHandler();
            game = new Game();
            mediaPath = Painter.SetMediaPath();

            filer.Init();
            filer.SetMap(theList, newMap);
            game.SetFiler(filer);
            LoadMap();
        }
        public void LoadList()
        {
            if (filer == null)
            {
                filer = new FileHandler();
            }

            filer.Init();

            foreach (string str in filer.GetMapListArray(1))
            {
                lbxUserCreated.Items.Add(str);
            }
        }
示例#6
0
        private void btnTestMap_Click(object sender, EventArgs e)
        {
            if (filer == null)
            {
                filer = new FileHandler();
                filer.Init();
            }

            if (!filer.TestImportedMap(theFile))
            {
                lblResult.Text = "Sorry, the text file was not in one of the correct formats.\nPress 'N' to select a different file to import\nPress Enter to return to the main menu";
                mapTested = true;
            }
            else
            {
                lblResult.Text = "The map was successfully validated.\nPress Spacebar to open the map in the Editor,\nPress 'N' to select a different file to import\nPress Enter to return to the main menu";
                mapTested = true;
                mapValid = true;
            }
        }
示例#7
0
        protected bool IsValid()
        {
            if (!builder.IsValid())
            {
                MessageBox.Show("Your map is not valid, you need a Theseus, Minotaur and an Exit");
                return false;
            }
            if (filer == null)
            {
                filer = new FileHandler();
            }
            filer.Init();

            if (tbxMapName.Text == "")
            {
                MessageBox.Show("Please enter a name for your map");
                return false;
            }
            if (filer.MapNameUsed(tbxMapName.Text))
            {
                MessageBox.Show("This map name is already used");
                DialogResult dialogResult = MessageBox.Show("Do you want to overwrite the existing map?", "Overwrite", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    filer.ConfirmOverwrite(true);
                    return true;
                }
                else if (dialogResult == DialogResult.No)
                {
                    filer.ConfirmOverwrite(false);
                    return false;
                }

            }
            return true;
        }
示例#8
0
        static void Main(string[] args)
        {
            /*Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form_Splash());*/
            //new Controller(new ConsoleView(), new Game(), new FileHandler(), new LevelBuilder()).Init();

            FileHandler filer = new FileHandler();
            LevelBuilder builder = new LevelBuilder();
            /*Game theGame = new Game();
            filer.Init();
            filer.SetMap(0, "Map 1.");

            theGame.SetFiler(filer);
            theGame.SetMap();

            foreach (Tile tile in theGame.GetMap())
            {
                Console.WriteLine(tile.Coordinate);
            }

            Tile theTile = theGame.GetMap()[3, 2];
            Console.WriteLine(theTile.Coordinate);
            Console.WriteLine(theGame.GetMap().GetLength(0));
            Console.WriteLine(theTile.IsOuter(Direction.Left));

            int i = 105;

            Console.WriteLine(i / 50);*/
            /*
            Point p = new Point(4, 4);
            builder.Init(p);
            p = new Point(3, 0);
            builder.SelectTile(p);
            builder.Exit();
            builder.EastWall();

            p = new Point(0, 3);
            builder.SelectTile(p);
            builder.SetTheseus();
            p = new Point(0, 2);
            builder.SelectTile(p);
            builder.SetMinotaur();

            Console.WriteLine(builder.Test());

            builder.Clear();

            Console.WriteLine(builder.Test());

            /*filer.Init();
            filer.SetMap(0, "Map 6");
            filer.GetNextMap();*/

            //Console.WriteLine(MapCreator.ObjectsToString(filer.GetMap().Tiles, filer.GetMap().TheTheseus, filer.GetMap().TheMinotaur));
            Loader loader = new Loader();
            Compressor compressor = new Compressor();
            Decompressor decompressor;

            /*string str = filer.LoadTextFile(@"H:\2015\semester 2\PR 283 C#\Theseus\level1.txt");
            Console.WriteLine(str);

            string[] stra = loader.ToStringArray(str);
            compressor.LoadMap(stra);
            compressor.FindSpecialCharacters();
            compressor.CompressLevel1();
            compressor.SetTheResult();
            Console.WriteLine(compressor.GetLvl1());
            Saver saver = new Saver();
            saver.SetFileName("lvl1c1");
            saver.SaveSingle(@"H:\2015\semester 2\PR 283 C#\Theseus", compressor.GetLvl1());*/

            string newFile = filer.LoadTextFile(@"H:\2015\semester 2\PR 283 C#\Theseus\lvl1c1.txt");
            decompressor = new Decompressor();

            decompressor.SetCompressed(newFile);

            //try
            //{
                decompressor.SeparateToArrays();
            //}

                decompressor.DecompressLevel1();
                decompressor.SetCharacters();

            /*int x = 0;
            foreach (string st in stra)
            {
                Console.WriteLine(x.ToString() + st);
                Console.WriteLine(st.Length);
                x++;
            }

            Bridger bridger = new Bridger();

            AMap newMap = new AMap();
            newMap.Map = stra;

            newMap = bridger.Convert(newMap);

            Console.WriteLine(newMap.TheMinotaur.Coordinate);
            Console.WriteLine(newMap.TheTheseus.Coordinate);*/

            //filer.IsValid(@"H:\2015\semester 2\PR 283 C#\Theseus\level1.txt");

            Console.ReadKey();
        }
示例#9
0
 //int currentMap;
 /*string mapOne = ".___.___.___.   .\n|     M     |    \n.   .___.   .___.\n|       |     X  \n.   .___.   .___.\n|     T     |    \n.___.___.___.   .";
 string mapTwo = ".___.___.___.___.___.___.___.\n|                           |\n.   .   .   .   .   .   .   .\n| M |   | T                 |\n.   .___.   .   .   .   .   .\n|                   |   |   |\n.   .   .   .   .   .___.   .\n|                           |\n.___.   .___.___.___.___.___.\n    | X |                    \n.   .   .   .   .   .   .   .";
 string mapThree = ".___.___.___.   .\n|     M     |    \n.   .___.   .___.\n|     T       X  \n.   .   .   .___.\n|   |       |    \n.___.   .   .   .\n|           |    \n.___.___.___.   .";
 string mapFour = ".   .   .   .   .   .\n            | X |    \n.___.___.___.   .___.\n|   | T             |\n.   .   .   .___.   .\n|       |       | M |\n.   .___.   .   .   .\n|           |       |\n.   .___.___.   .   .\n|           |   |   |\n.   .   .   .___.   .\n|                   |\n.___.___.___.___.___.\n";
 */
 /**** Import Map from Filer */
 public void Init(IView newView, FileHandler newFiler)
 {
     SetFiler(newFiler);
     SetView(newView);
 }
示例#10
0
 /*public void Restart()
 {
     theMap = theFiler.GetMap(currentMap);
     //SetTheseus(theFiler.GetTheseus());
     //SetMinotaur(theFiler.GetMinotaur());m,
     Run();
 }*/
 /*public void NextMap()
 {
     currentMap += 1;
     theMap = theFiler.GetMap(currentMap);
     //SetTheseus(theFiler.GetTheseus());
     //SetMinotaur(theFiler.GetMinotaur());
     Run();
 }
 */
 public void SetFiler(FileHandler newFiler)
 {
     theFiler = newFiler;
 }
示例#11
0
        public Controller(IView theView, Game theGame, FileHandler theFiler, LevelBuilder theBuilder)
        {
            view = theView;
            game = theGame;
            filer = theFiler;
            builder = theBuilder;

            filer.Init();
            game.Init(view, filer);
        }