Beispiel #1
0
 public override ILevelLoader GetLoaderForPlaying(PlayerSpecification players,
                                                  LevelLogicCustomSettings customSettings,
                                                  IProgressEventWatcher parentProgress = null,
                                                  double subsectionSize = 100)
 {
     throw new InvalidOperationException("Cannot load level in play mode");
 }
Beispiel #2
0
            public Screen(LevelSettingsScreen proxy, out string errorMessage)
                : base(proxy)
            {
                this.proxy = proxy;
                Game.UI.LoadLayoutToElement(MenuUIManager.MenuRoot, Game.ResourceCache, "UI/LevelSettingsScreenLayout.xml");

                window = (Window)MenuUIManager.MenuRoot.GetChild("LevelSettingsWindow");

                customSettingsWindow = (Window)window.GetChild("CustomSettings", true);

                UIElement descriptionTextElement = Game.UI.LoadLayout(Game.PackageManager.GetXmlFile("UI/DescriptionTextLayout.xml", true),
                                                                      MenuUIManager.MenuRoot.GetDefaultStyle());

                descriptionText       = (Text)descriptionTextElement.GetChild("DescriptionText");
                descriptionText.Value = Level.Description;
                descriptionScrollView = (ScrollView)window.GetChild("DescriptionScrollView", true);

                descriptionScrollView.ContentElement = descriptionTextElement;

                mapImage           = (BorderImage)window.GetChild("MapImage");
                mapImage.Texture   = Level.Thumbnail;
                mapImage.ImageRect = new Urho.IntRect(0, 0, Level.Thumbnail.Width, Level.Thumbnail.Height);

                playerList = (ListView)window.GetChild("PlayerListView");

                ((Button)window.GetChild("PlayButton", true)).Released += PlayButtonReleased;
                ((Button)window.GetChild("BackButton", true)).Released += BackButtonReleased;

                InsigniaGetter insigniaGetter = new InsigniaGetter();

                PlayerItem.CreateAndAddToList(playerList,
                                              this,
                                              insigniaGetter.MarkUsed(PlayerInsignia.NeutralPlayerInsignia),
                                              0,
                                              PlayerTypeCategory.Neutral);

                PlayerItem.CreateAndAddToList(playerList,
                                              this,
                                              insigniaGetter.GetNextUnusedInsignia(),
                                              1,
                                              PlayerTypeCategory.Human);

                for (int i = 0; i < Level.MaxNumberOfPlayers - 1; i++)
                {
                    PlayerItem.CreateAndAddToList(playerList, this, insigniaGetter.GetNextUnusedInsignia(), i + 2, PlayerTypeCategory.AI);
                }

                try {
                    pluginCustomSettings = Level.LevelLogicType.GetCustomSettings(customSettingsWindow, Game);
                    errorMessage         = null;
                }
                catch (Exception e) {
                    string message =
                        $"Level plugin threw an exception when getting the Custom settings window contents: {e.Message}";
                    Urho.IO.Log.Write(Urho.LogLevel.Error, message);
                    pluginCustomSettings = null;
                    errorMessage         = message;
                }
            }
Beispiel #3
0
 public ILevelLoader GetLevelLoaderForPlaying(LevelRep level,
                                              PlayerSpecification players,
                                              LevelLogicCustomSettings customSettings,
                                              IProgressEventWatcher parentProgress = null,
                                              double subsectionSize = 100)
 {
     throw new NotImplementedException();
 }
Beispiel #4
0
 /// <summary>
 /// Returns loader that can load the level into playing mode.
 /// </summary>
 /// <param name="levelRep">Presentation of the level for the user.</param>
 /// <param name="storedLevel">Stored serialized state of the level.</param>
 /// <param name="players">Data to initialize the players.</param>
 /// <param name="customSettings">Data to initialize the level logic instance plugin.</param>
 /// <param name="parentProgress">Progress watcher for the parent process.</param>
 /// <param name="loadingSubsectionSize">Size of this loading process as a part of the parent process.</param>
 /// <returns>Loader that can load the level into playing mode.</returns>
 public static ILevelLoader GetLoaderForPlaying(LevelRep levelRep,
                                                StLevel storedLevel,
                                                PlayerSpecification players,
                                                LevelLogicCustomSettings customSettings,
                                                IProgressEventWatcher parentProgress = null,
                                                double loadingSubsectionSize         = 100)
 {
     return(new SavedLevelPlayingLoader(levelRep, storedLevel, players, customSettings, parentProgress, loadingSubsectionSize));
 }
Beispiel #5
0
        /// <summary>
        /// If there is a paused running level, ends it and then creates a loader for loading <paramref name="level"/>
        /// for playing.
        /// Initializes players based on <paramref name="players"/>.
        /// Initializes level logic based on <paramref name="customSettings"/>.
        /// Can send loading updates if given <paramref name="parentProgress"/>.
        /// Scales the percentage updates by <paramref name="subsectionSize"/>, to enable us and the parent to go from 0 to 100.
        /// </summary>
        /// <param name="level">The level to create the loader for.</param>
        /// <param name="players">Data to use for player initialization.</param>
        /// <param name="customSettings">Settings to use for level logic plugin initialization.</param>
        /// <param name="parentProgress">The progress watcher for the parent.</param>
        /// <param name="subsectionSize">The precentage size of the level loading in the whole loading process.</param>
        /// <returns>A loader for the <paramref name="level"/> that can be used to load the <paramref name="level"/> for editing.</returns>
        public ILevelLoader GetLevelLoaderForPlaying(LevelRep level,
                                                     PlayerSpecification players,
                                                     LevelLogicCustomSettings customSettings,
                                                     IProgressEventWatcher parentProgress = null,
                                                     double subsectionSize = 100)
        {
            if (pausedLevelController != null)
            {
                EndPausedLevel();
            }

            return(level.GetLoaderForPlaying(players, customSettings, parentProgress, subsectionSize));
        }
Beispiel #6
0
            /// <summary>
            /// Creates a loader that loads saved level into a playing mode.
            /// </summary>
            /// <param name="levelRep">Presentation part of the level.</param>
            /// <param name="storedLevel">Saved level.</param>
            /// <param name="players">Data for player initialization.</param>
            /// <param name="customSettings">Data for level logic initialization.</param>
            /// <param name="parentProgress">Progress watcher for the parent process.</param>
            /// <param name="loadingSubsectionSize">Size of this loading process as a part of the parent process.</param>
            public SavedLevelPlayingLoader(LevelRep levelRep,
                                           StLevel storedLevel,
                                           PlayerSpecification players,
                                           LevelLogicCustomSettings customSettings,
                                           IProgressEventWatcher parentProgress = null,
                                           double loadingSubsectionSize         = 100)
                : base(levelRep, storedLevel, false, parentProgress, loadingSubsectionSize)
            {
                this.players        = players;
                this.customSettings = customSettings;

                if ((players == PlayerSpecification.LoadFromSavedGame) !=
                    (customSettings == LevelLogicCustomSettings.LoadFromSavedGame))
                {
                    throw new
                          ArgumentException("Argument mismatch, one argument is loaded from save and the other is not");
                }
            }
Beispiel #7
0
 /// <summary>
 /// Gets level logic instance plugin for level that is loaded for playing from a level prototype,
 /// so it has never been loaded for playing before.
 /// </summary>
 /// <param name="levelSettings">The GUI encapsulation given to the plugin so it can get input from user.</param>
 /// <param name="level">The loaded level.</param>
 /// <returns>Instance plugin for level loaded for playing for the first time.</returns>
 public LevelLogicInstancePlugin CreateInstancePluginForNewPlaying(LevelLogicCustomSettings levelSettings, ILevelManager level)
 {
     return(Plugin.CreateInstanceForNewPlaying(levelSettings, level));
 }
Beispiel #8
0
 public static FourPlayerLogic CreatePlayingNew(LevelLogicCustomSettings levelSettings, ILevelManager level, FourPlayerLogicType myType)
 {
     return(new FourPlayerLogic(level, myType));
 }
Beispiel #9
0
 public override LevelLogicInstancePlugin CreateInstanceForNewPlaying(LevelLogicCustomSettings levelSettings, ILevelManager level)
 {
     return(FourPlayerLogic.CreatePlayingNew(levelSettings, level, this));
 }
Beispiel #10
0
            public override ILevelLoader GetLoaderForPlaying(PlayerSpecification players, LevelLogicCustomSettings customSettings, IProgressEventWatcher parentProgress = null, double subsectionSize = 100)
            {
                if (savedLevel == null)
                {
                    savedLevel = GetSaveFromDynamicPath(savedLevelPath, GamePack.App.Files);
                }
                var loader = LevelManager.GetLoaderForPlaying(Context, savedLevel, players, customSettings, parentProgress, subsectionSize);

                loader.Finished += (notifier) => {
                    savedLevel    = null;
                    Context.state = new Playing(Context, this, loader.Level);
                };

                return(loader);
            }
Beispiel #11
0
 public override LevelLogicInstancePlugin CreateInstanceForNewPlaying(LevelLogicCustomSettings levelSettings, ILevelManager level)
 {
     return(TwoPlayerLogic.CreatePlayingNew((ResourceCreationWindow)levelSettings, level, this));
 }