コード例 #1
0
 public GraphicsDialog(Profile curProfile)
     : base("Graphics", new string[] { "Save", "Test", "Cancel" }, 0)
 {
     Buttons[0].Pressed += SaveButton;
     Buttons[1].Pressed += TestButton;
     mProfile = curProfile;
 }
コード例 #2
0
 /// <summary>
 /// Constructor fills in the menu contents.
 /// </summary>
 public LevelSelectionScreen(Profile p)
     : base("Level Selection")
 {
     for (int i = 1; i <= p.CurrentLevel + 1; i++)
     {
         MenuEntry entry = new MenuEntry("Level " + i);
         entry.Selected += EntrySelected;
         MenuEntries.Add(entry);
     }
 }
コード例 #3
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public CustomLevelSelectionScreen(Profile p)
            : base("Custom Level Selection")
        {
            foreach(string s in Directory.GetFiles(@"Content\Levels\Custom\", "*.xml", SearchOption.AllDirectories))
            {
                Level curLevel = Level.LoadLevel(s);
                mLevels.Add(curLevel);
                MenuEntry entry = new MenuEntry(curLevel.Name);

                entry.Pressed += EntrySelected;
                MenuEntries.Add(entry);
            }

            MenuEntry backButton = new MenuEntry("Back");
            backButton.Pressed += OnCancel;
            MenuEntries.Add(backButton);
        }
コード例 #4
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public WorldSelectionScreen(Profile p)
            : base("World Selection")
        {
            for (int i = 0; Level.INIT_LID_FOR_WORLD[i] <= p.CurrentLevel && i < Level.WORLD_NAMES.Length; i++)
            {
                MenuEntry entry = new MenuEntry(Level.WORLD_NAMES[i]);
                entry.Pressed += EntrySelected;
                MenuEntries.Add(entry);
            }

            MenuEntry cstmButton = new MenuEntry("Custom Levels");
            cstmButton.Pressed += CustomEntrySelected;
            MenuEntries.Add(cstmButton);

            MenuEntry backButton = new MenuEntry("Back");
            backButton.Pressed += OnCancel;
            MenuEntries.Add(backButton);
        }
コード例 #5
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public LevelSelectionScreen(Profile p, int world)
            : base(Level.WORLD_NAMES[world] +  ": Level Selection")
        {
            int last = (int)MathHelper.Min(Level.INIT_LID_FOR_WORLD[world + 1], p.CurrentLevel + 1);
            int first = Level.INIT_LID_FOR_WORLD[world];

            mLevels = new Level[last-first];

            for (int i = 0; i < last - first; i++)
            {
                mLevels[i] = Level.LoadLevel(i + first);
                MenuEntry entry = new MenuEntry(mLevels[i].Name);
                entry.Pressed += EntrySelected;
                MenuEntries.Add(entry);
            }

            MenuEntry backButton = new MenuEntry("Back");
            backButton.Pressed += OnCancel;
            MenuEntries.Add(backButton);
        }
コード例 #6
0
        public AudioOptionsScreen(Profile curProfile)
            : base("Audio Settings")
        {
            Slider masterVolumeSlider =    new Slider("Master Volume:", 50);
            Slider musicEffectSlider =     new Slider("Music Volume:", 50);
            Slider soundEffectSlider =     new Slider("Sound Effect Volume:", 50);
            Slider narrationVolumeSlider = new Slider("Narration Volume:", 50);
            MenuEntry saveMenuEntry = new MenuEntry("Save");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            saveMenuEntry.Pressed += SaveButton;
            backMenuEntry.Pressed += OnCancel;

            MenuEntries.Add(masterVolumeSlider);
            MenuEntries.Add(musicEffectSlider);
            MenuEntries.Add(soundEffectSlider);
            MenuEntries.Add(narrationVolumeSlider);
            MenuEntries.Add(saveMenuEntry);
            MenuEntries.Add(backMenuEntry);

            mProfile = curProfile;
        }
コード例 #7
0
        public AudioOptionsScreen(Profile curProfile)
            : base("Audio Settings")
        {
            masterVolumeSlider = new Slider("Master Volume:", curProfile.Audio.MasterVolume);
            musicEffectSlider = new Slider("Music Volume:", curProfile.Audio.MusicVolume);
            soundEffectSlider = new Slider("Sound Effect Volume:", curProfile.Audio.SoundEffectsVolume);
            narrationVolumeSlider = new Slider("Narration Volume:", curProfile.Audio.NarrationVolume);
            MenuEntry saveMenuEntry = new MenuEntry("Save");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            saveMenuEntry.Pressed += SaveButton;
            saveMenuEntry.Pressed += OnCancel;
            backMenuEntry.Pressed += OnCancel;

            MenuEntries.Add(masterVolumeSlider);
            MenuEntries.Add(musicEffectSlider);
            MenuEntries.Add(soundEffectSlider);
            MenuEntries.Add(narrationVolumeSlider);

            StackPanel btmPanel = new StackPanel(new UIElement[]{saveMenuEntry, backMenuEntry});
            MenuEntries.Add(btmPanel);

            mProfile = curProfile;
        }
コード例 #8
0
        public GraphicsScreen(Profile curProfile)
            : base("Graphics Settings")
        {
            // Create our menu entries.
            OptionPicker displayModeMenuEntry = new OptionPicker("Display Mode:", new string[3] { "W", "W (NB)", "FS" });
            OptionPicker resolutionMenuEntry = new OptionPicker( "Resolutions:", new string[3] { "A", "B", "C" });
            MenuEntry testMenuEntry = new MenuEntry("Test");
            MenuEntry saveMenuEntry = new MenuEntry("Save");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            // Hook up menu event handlers.
            testMenuEntry.Pressed += TestButton;
            saveMenuEntry.Pressed += SaveButton;
            backMenuEntry.Pressed += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(displayModeMenuEntry);
            MenuEntries.Add(resolutionMenuEntry);
            MenuEntries.Add(testMenuEntry);
            MenuEntries.Add(saveMenuEntry);
            MenuEntries.Add(backMenuEntry);

            mProfile = curProfile;
        }
コード例 #9
0
        EventHandler<PlayerIndexEventArgs> DoneRenaming(InputDialog dialog, Profile prof)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                prof.Name = dialog.Content;
                int index = mProfiles.IndexOf(prof);
                (MenuEntries[index] as ButtonGroup).Label.Text = prof.Name;

                if (mDefault == prof.ProfileNumber)
                    Profile.SaveProfile(prof, "default.sav", mDevice);
                else
                    Profile.SaveProfile(prof, "profile" + prof.ProfileNumber + ".sav", mDevice);
                PositionElements();
            };
        }
コード例 #10
0
        void ProfileSelectedButton(object sender, PlayerIndexEventArgs e)
        {
            int index = mSelectedButton;

            Profile prof = mProfiles[index];
            Profile currentProf = (ScreenManager.Game as HalfCakedGame).CurrentProfile;

            if (prof == null)
            {
                if (mDefault == -1)
                    prof = currentProf;
                else
                {
                    prof = new Profile();
                }
                mReadingInput = true;
                prof.ProfileNumber = index;

                if(currentProf != null && mDefault != -1)
                    Profile.SaveProfile(prof, "profile" + index + ".sav", mDevice);
                else
                    Profile.SaveProfile(prof, "default.sav", mDevice);
                mProfiles[index] = prof;
                Buttons[index].Text = "";
                CreateDimensions();
                IsExiting = false;
                return;
            }

            if (currentProf != null && mDefault != -1)
            {
                if (currentProf.ProfileNumber == prof.ProfileNumber)
                {
                    ExitScreen();
                    return;
                }
                Profile.ChangeDefault(currentProf.ProfileNumber, prof.ProfileNumber, mDevice);
                (ScreenManager.Game as HalfCakedGame).CurrentProfile = prof;
            }
            if (mDefault == -1)
                Profile.SaveProfile(prof, "default.sav", mDevice);
        }
コード例 #11
0
 public AudioOptionsDialog(Profile curProfile)
     : base("mAudio", new string[] { "Save", "Cancel" }, 0)
 {
     Buttons[0].Pressed += SaveButton;
     mProfile = curProfile;
 }
コード例 #12
0
ファイル: Profile.cs プロジェクト: CrimsonChris/Half-Caked
        public static void SaveProfile(Profile prof, string filename, StorageDevice device)
        {
            IAsyncResult result = device.BeginOpenContainer("Profiles", null, null);
            result.AsyncWaitHandle.WaitOne();
            StorageContainer container = device.EndOpenContainer(result);
            result.AsyncWaitHandle.Close();

            if (container.FileExists(filename))
                container.DeleteFile(filename);

            Stream stream = container.CreateFile(filename);
            XmlSerializer serializer = new XmlSerializer(typeof(Profile));
            serializer.Serialize(stream, prof);

            stream.Close();
            container.Dispose();
        }
コード例 #13
0
        void ConfirmExitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
        {
            mProfiles[mSelectedButton].Delete(mDevice);
            mProfiles[mSelectedButton] = null;
            Buttons[mSelectedButton].Text = "-Empty-";

            if (mSelectedButton == mDefault)
            {
                Profile prof = new Profile();
                prof.ProfileNumber = mDefault;
                (ScreenManager.Game as HalfCakedGame).CurrentProfile = prof;
                mDefault = -1;
            }

            mSelectedButton = -1;
            for (int i = 0; i < mProfiles.Length; i++)
            {
                if (mProfiles[i] != null)
                    mSelectedButton = i;
            }

            CreateDimensions();

            if (mSelectedButton == -1)
                mSelectedButton = 0;
        }
コード例 #14
0
        public GraphicsScreen(Profile curProfile)
            : base("Graphics Settings")
        {
            // Create our menu entries.
            //get an array of resolutions;
            mDisplayModePicker = new OptionPicker("Display Mode:", new string[3] { "Full Screen", "Windowed", "Windowed (No Borders)" });
            mDisplayModePicker.SelectedChoice = (int)curProfile.Graphics.PresentationMode;
            mPrevMode = mDisplayModePicker.SelectedChoice;

            mResolutions = GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Select<DisplayMode, Vector2>(x => new Vector2(x.Width, x.Height)).ToList();
            mResolutionPicker = new OptionPicker( "Resolutions:", mResolutions.Select<Vector2,String>(x => "" + x.X + " x " + x.Y).ToArray() );
            mResolutionPicker.SelectedChoice = mResolutions.IndexOf( curProfile.Graphics.Resolution );
            mPrevRes = mResolutionPicker.SelectedChoice;

            MenuEntry testMenuEntry = new MenuEntry("Test");
            MenuEntry saveMenuEntry = new MenuEntry("Save");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            // Hook up menu event handlers.
            testMenuEntry.Pressed += TestButton;
            saveMenuEntry.Pressed += SaveButton;
            saveMenuEntry.Pressed += OnCancel;
            backMenuEntry.Pressed += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(mDisplayModePicker);
            MenuEntries.Add(mResolutionPicker);

            StackPanel btmPanel = new StackPanel(new UIElement[] {testMenuEntry, saveMenuEntry, backMenuEntry });
            MenuEntries.Add(btmPanel);

            mProfile = curProfile;
        }
コード例 #15
0
ファイル: Profile.cs プロジェクト: bigmatt0211/Half-Caked
        public static KeyValuePair<int, Profile[]> LoadAll(StorageDevice device)
        {
            Profile[] profArray = new Profile[PROFILE_COUNT];
            Profile defProf = Load(-1, device);
            int index = -1;

            if(defProf != null && !defProf.Name.Equals(""))
            {
                for (int i = 0; i < PROFILE_COUNT; i++)
                {
                    profArray[i] = Load(i, device);
                    if (profArray[i] != null && profArray[i].Name.Equals(""))
                    {
                        profArray[i] = null;
                    }
                }
                profArray[defProf.ProfileNumber] = defProf;
                index = defProf.ProfileNumber;
            }

            return new KeyValuePair<int, Profile[]> (index, profArray);
        }
コード例 #16
0
        public KeybindingsScreen(Profile curProfile)
            : base("Keybindings")
        {
            mProfile = curProfile;
            originalBindings = curProfile.KeyBindings.Clone();

            // Creates the keybindings menu...
            menuList = new List<KeybindingKV>() {
                new KeybindingKV("Move Forward",        curProfile.KeyBindings.MoveForward){},
                new KeybindingKV("Move Backwards",      curProfile.KeyBindings.MoveBackwards){},
                new KeybindingKV("Crouch",              curProfile.KeyBindings.Crouch){},
                new KeybindingKV("Jump",                curProfile.KeyBindings.Jump){},
                new KeybindingKV("Interact",            curProfile.KeyBindings.Interact){},
                new KeybindingKV("Pause",               curProfile.KeyBindings.Pause){},
                new KeybindingKV("Portal 1 (Pink) Fire", curProfile.KeyBindings.Portal1){},
                new KeybindingKV("Portal 2 (Red) Fire",  curProfile.KeyBindings.Portal2){},
            };

            foreach (KeybindingKV keyItem in menuList)
            {
                string title = keyItem.Key;
                string[] choices = new string[2];
                choices[0] = keyItem.Value[0].ToString();
                choices[1] = keyItem.Value[1].ToString();
                ButtonGroup buttonRow = new ButtonGroup(title, choices);
                buttonRow.Buttons[0].Pressed += OpenKeybindingDialog(keyItem, buttonRow, 0);
                buttonRow.Buttons[1].Pressed += OpenKeybindingDialog(keyItem, buttonRow, 1);
                MenuEntries.Add(buttonRow);
            }

            // Menu Items that are special
            MenuEntry acceptMenuEntry = new MenuEntry("Accept");
            MenuEntry cancelMenuEntry = new MenuEntry("Cancel");

            // Event bindings
            acceptMenuEntry.Pressed += SaveButton;
            acceptMenuEntry.Pressed += OnCancel;
            cancelMenuEntry.Pressed += CancelButton;

            // Menu entries on our list
            StackPanel btmPanel = new StackPanel(new UIElement[] { acceptMenuEntry, cancelMenuEntry });
            MenuEntries.Add(btmPanel);
        }
コード例 #17
0
 public KeybindingsDialog(Profile curProfile)
     : base("Keybindings", new string[] { "Save", "Cancel" }, 0)
 {
     Buttons[0].Pressed += SaveButton;
     mProfile = curProfile;
 }
コード例 #18
0
        EventHandler<PlayerIndexEventArgs> DeleteProfile(Profile prof)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                int index = mProfiles.IndexOf(prof);
                prof.Delete(mDevice);
                if (prof.ProfileNumber == mDefault)
                {
                    Default = -1;
                    (this.ScreenManager.Game as HalfCakedGame).CurrentProfile = new Profile();
                }

                mProfiles.RemoveAt(index);
                MenuEntries.RemoveAt(index);
                PositionElements();
            };
        }
コード例 #19
0
        EventHandler<PlayerIndexEventArgs> ConfirmDeleteProfile(Profile prof)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                ContentBoxScreen confirmDeleteMessageBox = new ContentBoxScreen("Are you sure you want to delete Profile:", prof.Name);

                confirmDeleteMessageBox.Buttons[0].Pressed += DeleteProfile(prof);
                ScreenManager.AddScreen(confirmDeleteMessageBox, e.PlayerIndex);
            };
        }
コード例 #20
0
        EventHandler<PlayerIndexEventArgs> AddProfile(InputDialog dialog)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                Profile prof = new Profile();
                prof.Name = dialog.Content;
                prof.ProfileNumber = mNextProfile++;

                string[] profileOptions = { "Delete", "Rename", "Make Active" };
                ButtonGroup profileGroup = new ButtonGroup(prof.Name, profileOptions);
                profileGroup.HideInactive = true;
                profileGroup.LoadContent(this);

                profileGroup.Buttons[0].Pressed += ConfirmDeleteProfile(prof);
                profileGroup.Buttons[1].Pressed += RenameProfile(prof);
                profileGroup.Buttons[2].Pressed += SetDefaultProfile(prof);

                MenuEntries.Insert(MenuEntries.Count - 2, profileGroup);
                mProfiles.Add(prof);
                PositionElements();
                prof.Register();

                if (mProfiles.Count == 1)
                {
                    Default = prof.ProfileNumber;
                    Profile.SaveProfile(prof, "default.sav", mDevice);
                    (this.ScreenManager.Game as HalfCakedGame).CurrentProfile = prof;

                    if (ProfileSelected != null)
                        ProfileSelected.Invoke(this, e);
                }
                else
                    Profile.SaveProfile(prof, "profile" + prof.ProfileNumber + ".sav", mDevice);
            };
        }
コード例 #21
0
ファイル: Level.cs プロジェクト: CrimsonChris/Half-Caked
        public void LoadContent(ScreenManager screenManager, Profile activeProfile)
        {
            if (mLoaded)
                return;

            var theContentManager = screenManager.Game.Content;

            string backgroundMusicName = "Sounds\\" + AssetName;

            if (LevelIdentifier == -1)
            {
                string filepath = "Content\\Levels\\Custom\\" + AssetName;
                base.LoadContent(screenManager.GraphicsDevice, filepath + ".png");

                try
                {
                    mBackground.LoadContent(screenManager.GraphicsDevice, filepath + "b.png");
                    mBackground.Position = Position;
                }
                catch
                {
                    mBackground = null;
                }
            }
            else
            {
                string filepath = "Levels\\" + AssetName;
                base.LoadContent(theContentManager, filepath);

                try
                {
                    mBackground.LoadContent(theContentManager, filepath + "b");
                    mBackground.Position = Position;
                }
                catch
                {
                    mBackground = null;
                }
            }

            mCakeSprite.LoadContent(theContentManager, "Sprites\\Cake\\Cake");
            mCakeSprite.Scale = 1f;
            mCakeSprite.Position = Checkpoints[Checkpoints.Count - 1].Location - Vector2.UnitY * mCakeSprite.Size.Height;

            poofAnimation = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Poof"), 0.1f, 7, false);
            idleCake = new Animation(theContentManager.Load<Texture2D>("Sprites\\Cake\\Cake"), 0.1f, 1, true);
            mCakeAnimator.PlayAnimation(idleCake);

            mDimensions = activeProfile.Graphics.Resolution;
            mCenterVector = new Vector2(mDimensions.X / 2 - 100, mDimensions.Y * 3 / 4 - 100);

            mAudio = activeProfile.Audio;
            SoundEffect.MasterVolume = mAudio.MasterVolume / 100f;
            MediaPlayer.Volume = mAudio.MasterVolume * mAudio.MusicVolume / 10000f;

            mExitReached = theContentManager.Load<SoundEffect>("Sounds\\ExitReached");
            try
            {
                mBackgroundMusic = theContentManager.Load<Song>(backgroundMusicName);
            }
            catch
            {
                mBackgroundMusic = theContentManager.Load<Song>("Sounds\\Level");
            }
            mCheckpointSound = theContentManager.Load<SoundEffect>("Sounds\\Checkpoint");

            Portals.LoadContent(theContentManager);

            Player = new Character();
            Player.LoadContent(theContentManager);
            Player.Position = Player.InitialPosition = Checkpoints[0].Location;

            foreach (Obstacle spr in Obstacles)
                spr.LoadContent(theContentManager, spr.AssetName);

            foreach (Actor spr in Actors)
                spr.LoadContent(theContentManager, spr.AssetName);

            mGameFont = theContentManager.Load<SpriteFont>("Fonts\\gamefont");

            mLoaded = true;
        }
コード例 #22
0
ファイル: HalfCakedGame.cs プロジェクト: dweinberg/Half-Caked
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            base.Initialize();

            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            result.AsyncWaitHandle.WaitOne();
            Device = StorageDevice.EndShowSelector(result);
            CurrentProfile = Profile.Load(-1, Device);

            if (CurrentProfile == null)
                CurrentProfile = new Profile();//screenManager.AddScreen(new ProfileSelectionScreen(Device), null);

            UpdateGraphics();
            //LevelCreator.CreateAndSaveLevel(0);
            //LevelCreator.CreateAndSaveLevel(1);
        }
コード例 #23
0
 EventHandler<PlayerIndexEventArgs> RenameProfile(Profile prof)
 {
     return (object sender, PlayerIndexEventArgs e) =>
     {
         InputDialog dialog = new InputDialog("Please rename the profile:", prof.Name);
         dialog.Buttons[0].Pressed += DoneRenaming(dialog, prof);
         ScreenManager.AddScreen(dialog, ControllingPlayer);
     };
 }
コード例 #24
0
        public KeybindingsScreen(Profile curProfile)
            : base("Keybindings")
        {
            ButtonGroup bg1 = new ButtonGroup("A", new string[2] { "1", "3332" });
            ButtonGroup bg2 = new ButtonGroup("BC", new string[2] { "1", "3332" });
            ButtonGroup bg3 = new ButtonGroup("CAC", new string[2] { "---1", "2" });
            ButtonGroup bg4 = new ButtonGroup("DCAB", new string[2] { "12", "23333" });
            ButtonGroup bg5 = new ButtonGroup("EFGBA", new string[2] { "321", "23" });

            MenuEntry backMenuEntry = new MenuEntry("Back");

            backMenuEntry.Pressed += OnCancel;

            MenuEntries.Add(bg1);
            MenuEntries.Add(bg2);
            MenuEntries.Add(bg3);
            MenuEntries.Add(bg4);
            MenuEntries.Add(bg5);
            MenuEntries.Add(backMenuEntry);

            mProfile = curProfile;
        }
コード例 #25
0
ファイル: Level.cs プロジェクト: dweinberg/Half-Caked
        public virtual void LoadContent(ContentManager theContentManager, Profile activeProfile)
        {
            AssetName = "Levels\\" + AssetName;
            base.LoadContent(theContentManager, AssetName);
            mBackground.LoadContent(theContentManager, AssetName + "b");

            mDimensions = activeProfile.Graphics.Resolution;
            mCenterVector = new Vector2(mDimensions.X / 2 - 100, mDimensions.Y * 3 / 4 - 100);

            mAudio = activeProfile.Audio;
            SoundEffect.MasterVolume = mAudio.MasterVolume / 100f;
            MediaPlayer.Volume = mAudio.MasterVolume * mAudio.MusicVolume / 10000f;
            mExitReached = theContentManager.Load<Song>("Sounds\\ExitReached");
            mBackgroundMusic = theContentManager.Load<Song>("Sounds\\Level");
            mCheckpointSound = theContentManager.Load<SoundEffect>("Sounds\\Checkpoint");

            Portals.LoadContent(theContentManager);

            Player = new Character();
            Player.LoadContent(theContentManager);
            Player.Position = Player.InitialPosition = Checkpoints[0].Location;

            foreach (Obstacle spr in Obstacles)
                spr.LoadContent(theContentManager, spr.AssetName);

            foreach (Actor spr in Actors)
                spr.LoadContent(theContentManager, spr.AssetName);

            mGameFont = theContentManager.Load<SpriteFont>("Fonts\\gamefont");
        }
コード例 #26
0
        EventHandler<PlayerIndexEventArgs> SetDefaultProfile(Profile prof)
        {
            return (object sender, PlayerIndexEventArgs e) =>
            {
                Profile.ChangeDefault(mDefault, prof.ProfileNumber, mDevice);
                Default = prof.ProfileNumber;

                if(ProfileSelected != null)
                    ProfileSelected.Invoke(this, e);

                (this.ScreenManager.Game as HalfCakedGame).CurrentProfile = prof;
            };
        }