コード例 #1
0
        //Public Master Function to Save Data
        public static void SaveFileInfo(SavedDataFile sdf)
        {
            // Writing data:
            string[] POtoken = new string[3];
            POtoken[0] = sdf.GetSaveFileNumber().ToString();    //Set Save File Number to index 0
            POtoken[1] = sdf.GetWhichCharacter().ToString();    //Set whichCharcter to index 1
            POtoken[2] = sdf.GetLevelsUnlocked().ToString();    //Set levelsUnlocked to index 2

            //Rewrite all lines with new data
            File.WriteAllLines(GetSaveFilePlayerInfoFilePath(sdf.GetSaveFileNumber()), POtoken);

            //Create a list names LevelObtainedKeys
            List <string> LevelObtainedKeys = new List <string>();

            //Create string arrays to hold keys
            string[] PKGoldToken   = new string[sdf.GetObtainedGoldenKeys().Count];
            string[] PKSilverToken = new string[sdf.GetObtainedGoldenKeys().Count];

            //Get the levelNames of all obtained keys in Golden Key List
            for (int i = 0; i < sdf.GetObtainedGoldenKeys().Count; i++)
            {
                if (sdf.GetObtainedGoldenKeys()[i].GetObtained() == true)
                {
                    LevelObtainedKeys.Add(sdf.GetObtainedGoldenKeys()[i].GetKeyLevelName());
                }
            }

            PKGoldToken = LevelObtainedKeys.ToArray();      //Change from list to array

            //Reset LevelObtainedKeys
            LevelObtainedKeys = new List <string>();

            //Get the levelNames of all obtained keys in Silver Key List
            for (int i = 0; i < sdf.GetObtainedSilverKeys().Count; i++)
            {
                if (sdf.GetObtainedSilverKeys()[i].GetObtained() == true)
                {
                    LevelObtainedKeys.Add(sdf.GetObtainedSilverKeys()[i].GetKeyLevelName());
                }
            }

            PKSilverToken = LevelObtainedKeys.ToArray();  //Change from list to array

            //Rewrite all lines with new data
            File.WriteAllLines(GetSaveFilePlayerObtainedGoldenKeysFilePath(sdf.GetSaveFileNumber()), PKGoldToken);      //Golden Key Info
            File.WriteAllLines(GetSaveFilePlayerObtainedSilverKeysFilePath(sdf.GetSaveFileNumber()), PKSilverToken);    //Silver Key Info
        }
コード例 #2
0
        private LevelEntrance LevelThirtyFour;   // 3-12
        #endregion
        #endregion

        #endregion

        //Constructor
        public WorldMapScreen(IGameScreenManager gameScreenManager)
        {
            //Set Manage and Command
            m_ScreenManager = gameScreenManager;
            m_command       = new Command(m_ScreenManager);

            //Set To True
            Game1.isOnWorldMap = true;

            #region Load Saved Data
            //Load Game Data based on Game1.opener
            switch (Game1.opener)
            {
            case 1:
                SaveFile1            = LoadInformation.LoadSavedInformation(new SavedDataFile(1), 1);
                Game1.levelsUnlocked = SaveFile1.GetLevelsUnlocked();
                GetPlayerTextures(SaveFile1.GetWhichCharacter());
                if (SaveFile1.GetObtainedGoldenKeys().Count != 0)
                {
                    keyInventory.SetGoldKeyList(SaveFile1.GetObtainedGoldenKeys());
                }
                if (SaveFile1.GetObtainedSilverKeys().Count != 0)
                {
                    keyInventory.SetSilverKeyList(SaveFile1.GetObtainedSilverKeys());
                }
                break;

            case 2:
                SaveFile2            = LoadInformation.LoadSavedInformation(new SavedDataFile(2), 2);
                Game1.levelsUnlocked = SaveFile2.GetLevelsUnlocked();
                GetPlayerTextures(SaveFile2.GetWhichCharacter());
                if (SaveFile2.GetObtainedGoldenKeys().Count != 0)
                {
                    keyInventory.SetGoldKeyList(SaveFile2.GetObtainedGoldenKeys());
                }
                if (SaveFile2.GetObtainedSilverKeys().Count != 0)
                {
                    keyInventory.SetSilverKeyList(SaveFile2.GetObtainedSilverKeys());
                }
                break;

            case 3:
                SaveFile3            = LoadInformation.LoadSavedInformation(new SavedDataFile(3), 3);
                Game1.levelsUnlocked = SaveFile3.GetLevelsUnlocked();
                GetPlayerTextures(SaveFile3.GetWhichCharacter());
                if (SaveFile3.GetObtainedGoldenKeys().Count != 0)
                {
                    keyInventory.SetGoldKeyList(SaveFile3.GetObtainedGoldenKeys());
                }
                if (SaveFile3.GetObtainedSilverKeys().Count != 0)
                {
                    keyInventory.SetSilverKeyList(SaveFile3.GetObtainedSilverKeys());
                }
                break;

            default:
                break;
            }
            #endregion

            #region Timer Stuff
            //Set interval
            moveToNextLevel.Interval = 500;
            #endregion
        }