Ejemplo n.º 1
0
        public static ICommandManager CreateManager()
        {
            if (CommandManagerFactory.factoryDelegate == null)
            {
                // TODO: Fetch a collection of security roles to pass in to our internal manager
                return(new CommandManager(Enumerable.Empty <ISecurityRole>(), Enumerable.Empty <IInputCommand>(), new NotificationManager()));
            }

            return(CommandManagerFactory.factoryDelegate());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new player instance.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <returns></returns>
        public static IPlayer CreatePlayer(IGame game)
        {
            IPlayer player = null;

            if (factoryDelegate == null)
            {
                ICommandManager commandManager = CommandManagerFactory.CreateManager();
                player = new DefaultPlayer(game, commandManager);
            }
            else
            {
                player = factoryDelegate(game);
            }

            // This is a fail-safe. The DefaultPlayer assigns the owner for us, but we
            // force ownership of the command manager on the player regardless. In the event
            // a different IPlayer implementation is used that forgets to do this, the engine is still usable.
            player.CommandManager.SetOwner(player);
            return(player);
        }