示例#1
0
        public ArenaController(SaveData data)
        {
            instance = this;
            playerMoved = false;
            score = data.score;
            level = data.level;

            generator = new Random(data.seed);
        }
示例#2
0
        /// <summary>
        /// Saves the save data to the Xbox360
        /// </summary>
        /// <param name="data">SaveData struct to save.</param>
        private void saveXbox(SaveData data)
        {
            if (storageDevice != null && storageDevice.IsConnected)
            {
                IAsyncResult result = storageDevice.BeginOpenContainer(CONTAINER_NAME, null, null);
                result.AsyncWaitHandle.WaitOne();
                StorageContainer container = storageDevice.EndOpenContainer(result);

                if(container.FileExists(SAVE_FILE))//if that file already exists
                {
                    container.DeleteFile(SAVE_FILE);//delete existing file
                }

                Stream stream = container.CreateFile(SAVE_FILE);//create file

                XmlSerializer serializer = new XmlSerializer(typeof(SaveData));
                serializer.Serialize(stream, data);

                stream.Close();//close the file
                container.Dispose();//disposing container commits changes to device
            }
        }
示例#3
0
 /// <summary>
 /// Saves the save data.
 /// </summary>
 /// <param name="data">SaveData struct to save.</param>
 public void saveGame(SaveData data)
 {
     #if WINDOWS
     saveWindows(data);
     #else
     saveXbox(data);
     #endif
 }
示例#4
0
 /// <summary>
 /// Saves the save data to the PC
 /// </summary>
 /// <param name="data">SaveData struct to save.</param>
 private void saveWindows(SaveData data)
 {
     //if the path isn't null
     if(completePath != null)
     {
         using (var stream = new FileStream(completePath, FileMode.Create))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(SaveData));
             serializer.Serialize(stream, data);
         }
     }
 }
示例#5
0
        public ArenaScene(SaveData data)
            : base()
        {
            instance = this;
            loaded = true;

            // Create the arena controller
            controller = new ArenaController(data);

            // Set the player hp
            List<PlayerSprite> party = PartyUtils.getParty();
            party[0].setHealth(data.partyHealth[0]);
            party[1].setHealth(data.partyHealth[1]);
            party[2].setHealth(data.partyHealth[2]);

            // Define the user actions
            menu = InputAction.Y;
            pause = InputAction.START;

            rotateDown = new InputAction(
                new Buttons[] { Buttons.RightThumbstickDown },
                new Keys[] { Keys.NumPad2 },
                false
                );
            rotateUp = new InputAction(
                new Buttons[] { Buttons.RightThumbstickUp },
                new Keys[] { Keys.NumPad8 },
                false
                );

            bgm = SoundUtils.Music.ArenaTheme;
            pauseMenu = new MenuPanel("Pause Menu", new List<MenuItem>() {
                new MenuItem("Resume Game", pause),
                new MenuItem("Main Menu", menu)
            });
        }