Exemplo n.º 1
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;
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Creates a loader that loads one of the <paramref name="storedPlayers"/> that corresponds to the data in
            /// <paramref name="newInfo"/>.
            /// </summary>
            /// <param name="level">The level to load the player into.</param>
            /// <param name="storedPlayers">The stored data of all players.</param>
            /// <param name="insigniaGetter">The source of graphical representations of the players.</param>
            /// <param name="newInfo">Info of the player to load.</param>
            public Loader(LevelManager level, IList <StPlayer> storedPlayers, InsigniaGetter insigniaGetter, PlayerInfo newInfo)
            {
                this.level        = level;
                this.storedPlayer = (from stPlayer in storedPlayers
                                     where stPlayer.InsigniaID == newInfo.Insignia.Index
                                     select stPlayer).FirstOrDefault();

                if (storedPlayer == null)
                {
                    throw new
                          ArgumentException("StoredPlayers did not contain player entry for player with provided playerInfo", nameof(storedPlayers));
                }

                this.type     = newInfo.PlayerType;
                this.teamID   = newInfo.TeamID;
                this.insignia = insigniaGetter.MarkUsed(newInfo.Insignia);

                //Clear the stored player plugin data
                storedPlayer.UserPlugin = new PluginData();
            }
Exemplo n.º 3
0
            public void SimulatePlayButton(LevelSettingsScreenAction screenAction)
            {
                InsigniaGetter insigniaGetter = new InsigniaGetter();

                insigniaGetter.MarkUsed(PlayerInsignia.NeutralPlayerInsignia);
                PlayerType neutralPlayerType = Level.GamePack.GetPlayerType(screenAction.NeutralPlayerTypeName);

                Tuple <PlayerType, int, PlayerInsignia> humanPlayer =
                    Tuple.Create(Level.GamePack.GetPlayerType(screenAction.HumanPlayer.Item1),
                                 screenAction.HumanPlayer.Item2,
                                 insigniaGetter.GetNextUnusedInsignia());


                //Has to be last statement in the method, this instance will be released during the execution
                proxy.Play(neutralPlayerType,
                           humanPlayer,
                           from aiPlayer in screenAction.AIPlayers
                           select Tuple.Create(Level.GamePack.GetPlayerType(aiPlayer.Item1),
                                               aiPlayer.Item2,
                                               insigniaGetter.GetNextUnusedInsignia()),
                           pluginCustomSettings);
            }