Exemple #1
0
        //获取模块
        private static GameFrameworkModule GetModule(Type type)
        {
            int hashCode = type.GetHashCode();
            GameFrameworkModule module = null;

            if (_allGameModules.TryGetValue(hashCode, out module))
            {
                return(module);
            }
            module = CreateModule(type);
            return(module);
        }
Exemple #2
0
        //创建模块
        private static GameFrameworkModule CreateModule(Type type)
        {
            int hashCode = type.GetHashCode();
            GameFrameworkModule module = (GameFrameworkModule)Activator.CreateInstance(type);

            _allGameModules[hashCode] = module;
            //整理含IUpdate的模块
            var update = module as IUpdate;

            if (update != null)
            {
                _allUpdates.Add(update);
            }
            //整理含IFixed的模块
            var fixedUpdate = module as IFixedUpdate;

            if (fixedUpdate != null)
            {
                _allFixedUpdates.Add(fixedUpdate);
            }
            return(module);
        }