Beispiel #1
0
        void Start()
        {
            if (!DefaultModuleFactory.TryFindFirstInAll(out _spawnerModule))
            {
                throw new System.Exception("[GameView] Could not find SpawnerModule, was it declared in game manager Awake?");
            }

            if (!DefaultModuleFactory.TryFindFirstInAll(out _moverModule))
            {
                throw new System.Exception("[GameView] Could not find MoverModule, was it declared in game manager Awake?");
            }

            _spawnButton.onClick.AddListener(() => { OnSpawnerClick.Invoke(); });
            _moverButton.onClick.AddListener(() => { OnMoverClick.Invoke(); });
        }
        /// <summary>
        /// We want to use AWAKE so our modules initialize before everything else.
        /// </summary>

        void Awake()
        {
            //Create a new default module factory and pass in the active scene as a reference, so this particular module can be scoped to the scene
            DefaultModuleFactory _factory = new DefaultModuleFactory(gameObject.scene);

            //declare our spawner module for spawning objects in the scene, and set spawn immediately = true
            _spawnerModule = new ConsistentSpawnModule(_spawnPrefab, true);

            //declare our mover module for moving objects around
            _moverModule = new MoverModule(_spawnerModule);

            //add our modules to the factory so they can be accessed outside this scope.
            _factory.AddModule(_spawnerModule);
            _factory.AddModule(_moverModule);

            SetupViewCallbacks();
        }
Beispiel #3
0
        private static void Config()
        {
            var baseType = typeof(IModule);
            var cache    = new DefaultModuleCache();
            var factory  = new DefaultModuleFactory(baseType.Assembly, baseType);

            Container = new ModuleContainer(cache, factory);

            IPoolManager        poolManager        = Container.GetModule <IPoolManager>();
            IPlayerInputManager playerInputManager = Container.GetModule <IPlayerInputManager>();
            IUIManager          uIManager          = Container.GetModule <IUIManager>();
            IMonoManager        monoManager        = Container.GetModule <IMonoManager>();

            IEnumerable <IModule> modules = Container.GetAllModules <IModule>();

            foreach (var module in modules)
            {
                //通过父类接口调用到它的实现类的具体方法
                module.InitModule();
            }
        }
Beispiel #4
0
        private void LoadModules()
        {
            var repData = new List <ModuleUserControl>();

            repModules.ItemDataBound += RepModules_ItemDataBound;

            if (Root)
            {
                var c = new DefaultModuleFactory($"~/Content/templates/{WebSettings.Instance.Settings.Name}/layout/layout.ascx").GetControl(null);
                c.ID = "Layout";
                repData.Add(c);

                var editor = new DefaultModuleFactory("~/Module/Client/ModuleEditor.ascx").GetControl(null);
                Cms.Controls.Add(editor);
                repModules.DataSource = repData;
                repModules.DataBind();

                if (Authentication.IsAdmin)
                {
                    var toggle = (Client.AdminEditToggle) new DefaultModuleFactory("~/Module/Client/AdminEditToggle.ascx").GetControl(null);
                    Cms.Controls.Add(toggle);
                }

                return;
            }

            int menuId;

            int.TryParse(Request.QueryString["menuid"], out menuId);

            if (menuId == 0)
            {
                Cms.Controls.Add(new Literal()
                {
                    Text = "You need to create a menu first!"
                });
                return;
            }

            var manager = new ModulesManager();

            var controls = manager.GetMenuModules(menuId, ModuleId);

            foreach (var control in controls)
            {
                repData.Add(control);
            }



            if (Authentication.Instance.IsAdminEdit)
            {
                var c = (Client.ModuleEditAdd) new DefaultModuleFactory("~/Module/Client/ModuleEditAdd.ascx").GetControl(null);
                c.Data = new Domain.Modules()
                {
                    MenuId = menuId
                };
                Add.Controls.Add(c);
            }

            repModules.DataSource = repData;
            repModules.DataBind();
        }