Ejemplo n.º 1
0
            /// <summary>
            /// Creates placeholder players in the generated level.
            /// </summary>
            void CreatePlayers()
            {
                InsigniaGetter insignias = new InsigniaGetter();

                Level.HumanPlayer = CreatePlaceholderPlayer(insignias.GetNextUnusedInsignia());
                //human player gets the input and is the first one selected
                Level.Input =
                    Game.ControllerFactory.CreateGameController(Level.Camera, Level, Level.Scene.GetComponent <Octree>(), Level.HumanPlayer);

                //Neutral player placeholder
                Level.NeutralPlayer = CreatePlaceholderPlayer(insignias.GetUnusedInsignia(insignias.NeutralPlayerIndex));

                //AI player placeholders
                for (int i = 1; i < LevelRep.MaxNumberOfPlayers; i++)
                {
                    CreatePlaceholderPlayer(insignias.GetNextUnusedInsignia());
                }

                RegisterPlayersToUI();
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Creates a loader that loads the given <paramref name="storedPlayer"/> into the <paramref name="level"/>.
            /// </summary>
            /// <param name="level">The level to load the player into.</param>
            /// <param name="storedPlayer">Stored data of the player.</param>
            /// <param name="insigniaGetter">The source of graphical representations of the players.</param>
            /// <param name="loadPlaceholder">If the player should be loaded as a placeholder player, or if it should be loaded with it's
            /// actual type and plugin.</param>
            public Loader(LevelManager level, StPlayer storedPlayer, InsigniaGetter insigniaGetter, bool loadPlaceholder)
            {
                this.level        = level;
                this.storedPlayer = storedPlayer;
                this.insignia     = insigniaGetter.GetUnusedInsignia(storedPlayer.InsigniaID);
                if (loadPlaceholder)
                {
                    this.type = PlayerType.Placeholder;
                    teamID    = 0;
                }
                else
                {
                    if (storedPlayer.TypeID == 0)
                    {
                        throw new ArgumentException("StoredPlayer had no type", nameof(storedPlayer));
                    }

                    type   = level.Package.GetPlayerType(storedPlayer.TypeID);
                    teamID = storedPlayer.TeamID;
                }
            }