コード例 #1
0
ファイル: MainController.cs プロジェクト: arpond/longRoadHome
        /// <summary>
        /// Initialises the game state of a new game
        /// </summary>
        /// <returns>If the game state was sucessfully initialised</returns>
        public void InitialiseNewGame()
        {
            FileReadWriter frw                = new FileReadWriter();
            String         itemCatalogue      = frw.ReadCatalogueFile(FileReadWriter.ITEM_CATALOGUE);
            String         eventCatalogue     = frw.ReadCatalogueFile(FileReadWriter.EVENT_CATALOGUE);
            String         discoveryCatalogue = frw.ReadCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE);
            String         discovered         = frw.ReadSaveDataFile(FileReadWriter.DISCOVERED);

            if (!GameState.AreValidCatalogues(itemCatalogue, eventCatalogue, discoveryCatalogue))
            {
                itemCatalogue      = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.itemCatalogue;
                eventCatalogue     = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.eventCatalogue;
                discoveryCatalogue = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.discoveryCatalogue;
                frw.WriteCatalogueFile(FileReadWriter.ITEM_CATALOGUE, itemCatalogue);
                frw.WriteCatalogueFile(FileReadWriter.EVENT_CATALOGUE, eventCatalogue);
                frw.WriteCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE, discoveryCatalogue);
            }

            gs = new GameState(itemCatalogue, eventCatalogue, discoveryCatalogue, discovered);
            dc = new DifficultyController();
            var worldMap    = mf.GetWorldMap(gs);
            var buttonAreas = mf.GetButtonAreas(gs);

            gameView.InitialiseWorldMap(worldMap, buttonAreas);
            gameView.InitialiseSublocationMap(mf.GetCurrentSublocations(gs), mf.GetCurrentSublocation(gs));
            gameView.InitialiseInventory(mf.GetInventory(gs));
        }
コード例 #2
0
ファイル: MainController.cs プロジェクト: arpond/longRoadHome
        /// <summary>
        /// Initialises Discoveries only
        /// </summary>
        /// <returns></returns>
        public bool IntialiseDiscoveries()
        {
            FileReadWriter frw = new FileReadWriter();
            String         discoveryCatalogue = frw.ReadCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE);
            String         discovered         = frw.ReadSaveDataFile(FileReadWriter.DISCOVERED);

            if (!GameState.IsValidDiscoveries(discoveryCatalogue, discovered))
            {
                discoveryCatalogue = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.discoveryCatalogue;
                frw.WriteCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE, discoveryCatalogue);
                discovered = "Discovered";
            }

            gs = new GameState(discoveryCatalogue, discovered);
            return(true);
        }
コード例 #3
0
ファイル: MainController.cs プロジェクト: arpond/longRoadHome
        public bool CheckIfSaveExists()
        {
            FileReadWriter frw                = new FileReadWriter();
            String         itemCatalogue      = frw.ReadCatalogueFile(FileReadWriter.ITEM_CATALOGUE);
            String         eventCatalogue     = frw.ReadCatalogueFile(FileReadWriter.EVENT_CATALOGUE);
            String         discoveryCatalogue = frw.ReadCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE);
            String         discovered         = frw.ReadSaveDataFile(FileReadWriter.DISCOVERED);
            String         pc           = frw.ReadSaveDataFile(FileReadWriter.PLAYER_CHARACTER);
            String         inventory    = frw.ReadSaveDataFile(FileReadWriter.INVENTORY);
            String         usedEvents   = frw.ReadSaveDataFile(FileReadWriter.USED_EVENTS);
            String         currentEvent = frw.ReadSaveDataFile(FileReadWriter.CURRENT_EVENT);

            String visitedLocs          = frw.ReadSaveDataFile(FileReadWriter.VISITED);
            String unvisitedLocs        = frw.ReadSaveDataFile(FileReadWriter.UNVISISTED);
            String currLoc              = frw.ReadSaveDataFile(FileReadWriter.CURRENT_LOCATION);
            String currSLoc             = frw.ReadSaveDataFile(FileReadWriter.CURRENT_SUBLOCATION);
            String buttonAreas          = frw.ReadSaveDataFile(FileReadWriter.BUTTONS_AREA);
            String difficultyController = frw.ReadSaveDataFile(FileReadWriter.DIFFICULTY_CONTROLLER);

            System.Drawing.Bitmap worldMap = frw.ReadBitmap(FileReadWriter.WORLD_MAP);

            if (GameState.IsValidGameState(pc, inventory, itemCatalogue, usedEvents, currentEvent, eventCatalogue, discovered,
                                           discoveryCatalogue, visitedLocs, unvisitedLocs, currLoc, currSLoc) && DifficultyController.IsValidDifficultyController(difficultyController))
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: MainController.cs プロジェクト: arpond/longRoadHome
        /// <summary>
        /// Initialises the game state from a save
        /// </summary>
        /// <returns>If the game state was sucessfully initialised</returns>
        public bool InitialiseGameFromSave()
        {
            FileReadWriter frw                = new FileReadWriter();
            String         itemCatalogue      = frw.ReadCatalogueFile(FileReadWriter.ITEM_CATALOGUE);
            String         eventCatalogue     = frw.ReadCatalogueFile(FileReadWriter.EVENT_CATALOGUE);
            String         discoveryCatalogue = frw.ReadCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE);

            if (!GameState.AreValidCatalogues(itemCatalogue, eventCatalogue, discoveryCatalogue))
            {
                itemCatalogue      = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.itemCatalogue;
                eventCatalogue     = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.eventCatalogue;
                discoveryCatalogue = uk.ac.dundee.arpond.longRoadHome.Properties.Resources.discoveryCatalogue;
                frw.WriteCatalogueFile(FileReadWriter.ITEM_CATALOGUE, itemCatalogue);
                frw.WriteCatalogueFile(FileReadWriter.EVENT_CATALOGUE, eventCatalogue);
                frw.WriteCatalogueFile(FileReadWriter.DISCOVERY_CATALOGUE, discoveryCatalogue);
            }

            String discovered   = frw.ReadSaveDataFile(FileReadWriter.DISCOVERED);
            String pc           = frw.ReadSaveDataFile(FileReadWriter.PLAYER_CHARACTER);
            String inventory    = frw.ReadSaveDataFile(FileReadWriter.INVENTORY);
            String usedEvents   = frw.ReadSaveDataFile(FileReadWriter.USED_EVENTS);
            String currentEvent = frw.ReadSaveDataFile(FileReadWriter.CURRENT_EVENT);

            String visitedLocs          = frw.ReadSaveDataFile(FileReadWriter.VISITED);
            String unvisitedLocs        = frw.ReadSaveDataFile(FileReadWriter.UNVISISTED);
            String currLoc              = frw.ReadSaveDataFile(FileReadWriter.CURRENT_LOCATION);
            String currSLoc             = frw.ReadSaveDataFile(FileReadWriter.CURRENT_SUBLOCATION);
            String buttonAreas          = frw.ReadSaveDataFile(FileReadWriter.BUTTONS_AREA);
            String difficultyController = frw.ReadSaveDataFile(FileReadWriter.DIFFICULTY_CONTROLLER);

            System.Drawing.Bitmap worldMap = frw.ReadBitmap(FileReadWriter.WORLD_MAP);

            if (GameState.IsValidGameState(pc, inventory, itemCatalogue, usedEvents, currentEvent, eventCatalogue, discovered,
                                           discoveryCatalogue, visitedLocs, unvisitedLocs, currLoc, currSLoc) && DifficultyController.IsValidDifficultyController(difficultyController))
            {
                gs = new GameState(pc, inventory, itemCatalogue,
                                   usedEvents, currentEvent, eventCatalogue,
                                   discovered, discoveryCatalogue,
                                   visitedLocs, unvisitedLocs, currLoc, currSLoc, buttonAreas, worldMap);
                dc = new DifficultyController(difficultyController);

                gameView.InitialiseWorldMap(mf.GetWorldMap(gs), mf.GetButtonAreas(gs));

                List <Location> visited = mf.GetVisitedLocations(gs);
                List <int>      ids     = new List <int>();
                foreach (var loc in visited)
                {
                    ids.Add(loc.GetLocationID());
                }
                gameView.UpdateFromSave(mf.GetCurrentLocation(gs), ids);
                gameView.InitialiseSublocationMap(mf.GetCurrentSublocations(gs), mf.GetCurrentSublocation(gs));
                gameView.InitialiseInventory(mf.GetInventory(gs));
                return(true);
            }
            return(false);
        }