示例#1
0
        /// <summary>
        /// Create a new instance of the game engine. A user
        /// is required to know how to run the engine.
        /// </summary>
        /// <param name="context">The executing context of the engine.</param>
        /// <param name="serviceLocator">The dependency locator.</param>
        protected GameEngine(IContext context, ServiceLocator serviceLocator)
        {
            if (instance != null)
            {
                throw new Exception("Two or more instances of the game engine exist!");
            }

            this.Context        = context;
            this.serviceLocator = serviceLocator;

            LogModule     = new LogModule(this);
            ConfigModule  = new ConfigModule(this);
            UserModule    = new UserModule(this);
            CommandModule = new CommandConsoleModule(this);
            UIModule      = new UIModule(this);
            NetModule     = new NetModule(this);
            InputModule   = new InputModule(this);

            this.Context.EngineTicker.OnInit   += OnTickerInit;
            this.Context.EngineTicker.OnStart  += OnTickerStart;
            this.Context.EngineTicker.OnUpdate += OnTickerUpdate;
            this.Context.EngineTicker.OnEnd    += OnTickerEnd;

            SceneManager.sceneLoaded += SceneManagerSceneLoaded;
            instance = this;
            Core.Context.SetContext(context);
        }
示例#2
0
        static void Main(string[] args)
        {
            ServiceProvider iocProvider = CommandConsoleModule.ConfigureIocContainer();
            ICommand        command     = iocProvider.GetService <ICommand>();

            Start(command);
        }