当前位置: 首页>>代码示例>>C#>>正文


C# Storage.StorageDevice类代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Storage.StorageDevice的典型用法代码示例。如果您正苦于以下问题:C# StorageDevice类的具体用法?C# StorageDevice怎么用?C# StorageDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StorageDevice类属于Microsoft.Xna.Framework.Storage命名空间,在下文中一共展示了StorageDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteSave

 public void ExecuteSave(int slot, Action callback = null)
 {
     _slot = slot;
     _saveCallback = callback;
     _storageDevice = null;
     StorageDevice.BeginShowSelector(PlayerIndex.One, Save, null);
 }
开发者ID:rafaelalmeidatk,项目名称:Super-Pete-The-Pirate,代码行数:7,代码来源:SavesManager.cs

示例2: Save

 private void Save(IAsyncResult result)
 {
     _storageDevice = StorageDevice.EndShowSelector(result);
     if (_storageDevice != null && _storageDevice.IsConnected)
     {
         var filename = String.Format("save{0:00}.dat", _slot);
         var player = PlayerManager.Instance;
         GameSave save = new GameSave()
         {
             Ammo = player.Ammo,
             Lives = player.Lives,
             Hearts = player.Hearts,
             Coins = player.Coins,
             StagesCompleted = player.StagesCompleted
         };
         IAsyncResult r = _storageDevice.BeginOpenContainer(_storageContainerName, null, null);
         result.AsyncWaitHandle.WaitOne();
         Thread.Sleep(1500);
         StorageContainer container = _storageDevice.EndOpenContainer(r);
         if (container.FileExists(filename))
             container.DeleteFile(filename);
         Stream stream = container.CreateFile(filename);
         IFormatter formatter = new BinaryFormatter();
         formatter.Serialize(stream, save);
         stream.Close();
         container.Dispose();
         result.AsyncWaitHandle.Close();
         if (_saveCallback != null)
             _saveCallback();
     }
 }
开发者ID:rafaelalmeidatk,项目名称:Super-Pete-The-Pirate,代码行数:31,代码来源:SavesManager.cs

示例3: GameData

        public GameData(StorageDevice device)
        {
            this.device = device;

            // initialize score
            saveGameData.levelCompleted = 0;
            saveGameData.currentlevel = 1;
            saveGameData.score = 0;
            saveGameData.levelData = new LevelData[GameConstants.LEVELS];
            for (int i = 0; i < GameConstants.LEVELS; i++)
            {
                saveGameData.levelData[i].currentlevelNum = i + 1;
                saveGameData.levelData[i].time = TimeSpan.Zero.ToString();
                saveGameData.levelData[i].levelParTime = TimeSpan.Zero.ToString();
                saveGameData.levelData[i].remainingHealth = GameConstants.HEALTH;
            }
            //
            GetDevice();
            GetContainer();
            if (!Load())
            {
                GetContainer();
                Save();
            }
        }
开发者ID:matthewlouis,项目名称:MadScienceLab,代码行数:25,代码来源:GameData.cs

示例4: ProfileSelectionScreen

        public ProfileSelectionScreen(StorageDevice device)
            : base("Choose your active profile:")
        {
            IsPopup = true;
            mDevice = device;

            this.Buttons.Clear();

            var temp = Profile.LoadAll(mDevice);
            mDefault = mSelectedButton = temp.Key;

            if (temp.Key < 0)
            {
                mSelectedButton = 0;
            }

            mProfiles = temp.Value;

            for(int i = 0; i < mProfiles.Length; i++)
            {
                Button btn = new Button(mProfiles[i] != null ? mProfiles[i].Name : "-Empty-");
                btn.Pressed += ProfileSelectedButton;

                Buttons.Add(btn);
            }
        }
开发者ID:bigmatt0211,项目名称:Half-Caked,代码行数:26,代码来源:ProfileSelectionScreen.cs

示例5: saveLevel

        void saveLevel(IAsyncResult result)
        {
            SaveLevelData data = new SaveLevelData();
            data.objectList = level.entityList;
            data.currentPosition = level.currentPosition;
            data.multiSelect = level.multiSelect;
            data.upTime = level.upTime;
            data.holdTime = level.holdTime;
            data.filename = level.levelName;

            device = StorageDevice.EndShowSelector(result);
            if (device != null && device.IsConnected)
            {
                IAsyncResult r = device.BeginOpenContainer("MyGamesStorage", null, null);
                result.AsyncWaitHandle.WaitOne();
                StorageContainer container = device.EndOpenContainer(r);
                if (container.FileExists(level.levelName + ".sav"))
                    container.DeleteFile(level.levelName + ".sav");
                Stream stream = container.CreateFile(level.levelName + ".sav");

                XmlSerializer serializer = new XmlSerializer(typeof(SaveLevelData));
                serializer.Serialize(stream, data);
                stream.Close();
                container.Dispose();
                result.AsyncWaitHandle.Close();
            }
        }
开发者ID:oh-team-machine,项目名称:Target-Tapping,代码行数:27,代码来源:saveLevel.cs

示例6: Initialize

        public void Initialize(ContentManager Content, GraphicsDevice Graphics)
        {
            StorageDeviceResult = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDeviceResult.AsyncWaitHandle.WaitOne();
            StorageDevice = StorageDevice.EndShowSelector(StorageDeviceResult);
            StorageDeviceResult.AsyncWaitHandle.Close();
            OpenContainer();
            this.Content = Content;
            this.Graphics = Graphics;
            this.SpriteBatch = new SpriteBatch(Graphics);
            this.SpriteFont = Content.Load<SpriteFont>("DefaultFont");

            ScreenHeight = Graphics.Viewport.Height;
            ScreenWidth = Graphics.Viewport.Width;
            ScreenHeightHalf = ScreenHeight / 2;
            ScreenWidthHalf = ScreenWidth / 2;
            FullScreenRectangle = new Rectangle(0, 0, (int)ScreenWidth, (int)ScreenHeight);

            Random = new Random();
            PixelWhite = new Texture2D(Graphics, 1, 1);
            Color[] data = { Color.White };
            PixelWhite.SetData<Color>(data);
            int GardientSize = 1000;
            Gardient = new Texture2D(Graphics, GardientSize, GardientSize);
            data = new Color[GardientSize * GardientSize];
            for (int x = 0; x < GardientSize; x++)
            {
                for (int y = 0; y < GardientSize; y++)
                {
                    float c = 1.0f - ((float)(x * y)) / (GardientSize * GardientSize);
                    data[x + y * GardientSize] = new Color(c, c, c);
                }
            }
            Gardient.SetData<Color>(data);
        }
开发者ID:KDSBest,项目名称:RPG-Game-XNA,代码行数:35,代码来源:Globals.cs

示例7: SaveToFile

        private void SaveToFile(IAsyncResult result)
        {
            device = StorageDevice.EndShowSelector(result);

            // Open a storage container.
            IAsyncResult r = device.BeginOpenContainer(containerName, null, null);
            result.AsyncWaitHandle.WaitOne();
            StorageContainer container = device.EndOpenContainer(r);
            result.AsyncWaitHandle.Close();

            // Delete old file and create new one.
            if (container.FileExists(fileName))
            {
                container.DeleteFile(fileName);
            }
            Stream fileStream = container.CreateFile(fileName);

            // Write data to file.
            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            serializer.Serialize(fileStream, saveGameData);

            // Close file.
            fileStream.Close();
            container.Dispose();
        }
开发者ID:ProfChaos,项目名称:Immunity,代码行数:25,代码来源:StorageHandler.cs

示例8: LoadSaveData

        public void LoadSaveData(StorageDevice device)
        {
            result = device.BeginOpenContainer("Storage", null, null);
            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.EndOpenContainer(result);

            result.AsyncWaitHandle.Close();
            string filename = "savegame.sav";

            // Check to see whether the save exists.
            if (!container.FileExists(filename))
            {
                // If not, dispose of the container and return.
                container.Dispose();
                return;
            }
            //Open file.
            Stream stream = container.OpenFile(filename, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            loadedData = (SaveGameData)serializer.Deserialize(stream);
            //close file
            stream.Close();
            container.Dispose();
        }
开发者ID:Stanimir-b,项目名称:Youkai,代码行数:25,代码来源:StartMenuScreen.cs

示例9: StorageContainer

        /// <summary>
        /// Initializes a new instance of the <see cref="StorageContainer"/> class.
        /// </summary>
        /// <param name='device'>The attached storage-device.</param>
        /// <param name='name'>The title's filename.</param>
        /// <param name='rootPath'>The path of the storage root folder</param>
        /// <param name='playerIndex'>
        /// The index of the player whose data is being saved, or null if data is for all
        /// players.
        /// </param>
        internal StorageContainer(
			StorageDevice device,
			string name,
			string rootPath,
			PlayerIndex? playerIndex
		)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("A title name has to be provided in parameter name.");
            }

            StorageDevice = device;
            DisplayName = name;

            // Generate the path of the game's savefolder
            storagePath = Path.Combine(
                rootPath,
                Path.GetFileNameWithoutExtension(
                    AppDomain.CurrentDomain.FriendlyName
                )
            );

            // Create the root folder for all titles, if needed.
            if (!Directory.Exists(storagePath))
            {
                Directory.CreateDirectory(storagePath);
            }

            storagePath = Path.Combine(storagePath, name);

            // Create the sub-folder for this container/title's files, if needed.
            if (!Directory.Exists(storagePath))
            {
                Directory.CreateDirectory(storagePath);
            }

            /* There are two types of subfolders within a StorageContainer.
             * The first is a PlayerX folder, X being a specified PlayerIndex.
             * The second is AllPlayers, when PlayerIndex is NOT specified.
             * Basically, you should NEVER expect to have ANY file in the root
             * game save folder.
             * -flibit
             */
            if (playerIndex.HasValue)
            {
                storagePath = Path.Combine(storagePath, "Player" + ((int) playerIndex.Value + 1).ToString());
            }
            else
            {
                storagePath = Path.Combine(storagePath, "AllPlayers");
            }

            // Create the player folder, if needed.
            if (!Directory.Exists(storagePath))
            {
                Directory.CreateDirectory(storagePath);
            }
        }
开发者ID:AesteroidBlues,项目名称:FNA,代码行数:69,代码来源:StorageContainer.cs

示例10: SaveOperationAsyncResult

		internal SaveOperationAsyncResult(StorageDevice device, string container, string file, FileAction action, FileMode mode)
		{
			this.storageDevice = device;
			this.containerName = container;
			this.fileName = file;
			this.fileAction = action;
			this.fileMode = mode;
		}
开发者ID:NotYours180,项目名称:EasyStorage,代码行数:8,代码来源:SaveOperationAsyncResult.cs

示例11: loadLevel

 // Avaa leveli nimen mukaan
 public void loadLevel(string nimi)
 {
     device = StorageDevice.EndShowSelector(result);
     if (device != null && device.IsConnected)
     {
         DoLoadGame( device );
     }
 }
开发者ID:Kauko,项目名称:fallingGGJ12,代码行数:9,代码来源:LevelLoader.cs

示例12: LoadGame

        /// <summary>
        /// This method gets the filenames from the universal storage file LbKTileData.sav
        /// </summary>
        /// <param name="device"></param>
        /// <param name="gamer"></param>
        /// <param name="fileNamesOnly"></param>
        public static void LoadGame(StorageDevice device, SignedInGamer gamer, bool fileNamesOnly)
        {
            // Open a storage container.
            // name of container is LbK Storage Device
            IAsyncResult result =
                device.BeginOpenContainer(gamer.Gamertag, null, null);

            // Wait for the WaitHandle to become signaled.
            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.EndOpenContainer(result);

            // Close the wait handle.
            result.AsyncWaitHandle.Close();

            string filename = "LbKTileData.sav";

            // Check to see whether the save exists.
            if (!container.FileExists(filename))
            {
                // If not, dispose of the container and return.
                container.Dispose();
                return;
            }

            // Open the file.
            Stream file = container.OpenFile(filename, FileMode.Open);

            // Read the data from the file.
            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            SaveGameData data = (SaveGameData)serializer.Deserialize(file);

            // Close the file.
            file.Close();

            // Dispose the container.
            container.Dispose();

            // Report the data to the console.
            if (fileNamesOnly)
            {
                fileNames = data.Names;
            }
            else
            {
                position = data.TilePosition;
                type = data.TileType;
                objectNumber = data.TileObjectNumber;
                count = data.TileCount;
                fileNames = data.Names;
            }

            GamePlayScreen.storageDevice = device;
            // load up game with respective device
        }
开发者ID:Harmonickey,项目名称:AlexCSPortfolio,代码行数:61,代码来源:LbKStorageLevelCreation.cs

示例13: StorageContainer

 public StorageContainer(StorageDevice device, string name)
 {
     _device = device;
     _name = name;
     _path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+System.IO.Path.DirectorySeparatorChar+name;
     // Creathe the "device" if need
     if (!Directory.Exists(_path))
     {
         Directory.CreateDirectory(_path);
     }
 }
开发者ID:QHebert,项目名称:monogame,代码行数:11,代码来源:StorageContainer.cs

示例14: LevelNames

 public LevelNames()
 {
     device = null;
     if(check)
     {
         StorageDevice.BeginShowSelector(PlayerIndex.One, this.loadLevelName, null);
     }
     if(check == false)
     {
         filenames = new List<string>();
         StorageDevice.BeginShowSelector(PlayerIndex.One, this.saveLevelName, null);
     }
 }
开发者ID:oh-team-machine,项目名称:Target-Tapping,代码行数:13,代码来源:LevelNames.cs

示例15: Update

 public void Update()
 {
     if (pendingDevice)
     {
         if (deviceResult.IsCompleted)
         {
             //device = Guide.EndShowStorageDeviceSelector(deviceResult);
             device = StorageDevice.EndShowSelector(deviceResult);
             pendingDevice = false;
             Read(STORE_SETTINGS);
         }
     }
 }
开发者ID:o3a,项目名称:ZombieSmashersXNA4,代码行数:13,代码来源:Store.cs


注:本文中的Microsoft.Xna.Framework.Storage.StorageDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。