Ejemplo n.º 1
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_DebuggerManager = GameFrameworkEntry.GetModule <IDebuggerManager>();
            if (m_DebuggerManager == null)
            {
                Log.Fatal("Debugger manager is invalid.");
                return;
            }

            if (m_ActiveWindow == DebuggerActiveWindowType.Auto)
            {
                ActiveWindow = Debug.isDebugBuild;
            }
            else
            {
                ActiveWindow = (m_ActiveWindow == DebuggerActiveWindowType.Open);
            }

            m_FpsCounter = new FpsCounter(0.5f);
        }
Ejemplo n.º 2
0
        private IEnumerator Start()
        {
            IFsmManager fsmManager = GameFrameworkEntry.GetModule <IFsmManager>();

            ProcedureBase[] procedures = new ProcedureBase[m_AvailableProcedureTypeNames.Length];
            for (int i = 0; i < m_AvailableProcedureTypeNames.Length; i++)
            {
                Type procedureType = Utility.Assembly.GetTypeWithinLoadedAssemblies(m_AvailableProcedureTypeNames[i]);
                if (procedureType == null)
                {
                    Log.Error("Can not find procedure type '{0}'.", m_AvailableProcedureTypeNames[i]);
                    yield break;
                }

                procedures[i] = Activator.CreateInstance(procedureType) as ProcedureBase;
                if (procedures[i] == null)
                {
                    Log.Error("Can not create procedure instance '{0}'.", m_AvailableProcedureTypeNames[i]);
                    yield break;
                }

                if (m_EntranceProcedureTypeName == m_AvailableProcedureTypeNames[i])
                {
                    m_EntranceProcedure = procedures[i];
                }
            }

            if (m_EntranceProcedure == null)
            {
                Log.Error("Entrance procedure is invalid.");
                yield break;
            }

            m_ProcedureManager.Initialize(fsmManager, procedures);

            yield return(new WaitForEndOfFrame());

            m_ProcedureManager.StartProcedure(m_EntranceProcedure.GetType());
        }
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_LocalizationManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_LocalizationManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            if (m_LocalizationHelper == null)
            {
                m_LocalizationHelper      = (new GameObject()).AddComponent <DefaultLocalizationHelper>();
                m_LocalizationHelper.name = string.Format("Localization Helper");
                Transform transform = m_LocalizationHelper.transform;
                transform.SetParent(this.transform);
                transform.localScale = Vector3.one;
            }

            m_LocalizationManager.SetLocalizationHelper(m_LocalizationHelper);
            m_LocalizationManager.Language = (baseComponent.EditorResourceMode && baseComponent.EditorLanguage != Language.Unspecified ? baseComponent.EditorLanguage : m_LocalizationManager.SystemLanguage);
        }
Ejemplo n.º 4
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_DataTableManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_DataTableManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            if (m_DataTableHelper == null)
            {
                m_DataTableHelper      = (new GameObject()).AddComponent <DefaultDataTableHelper>();
                m_DataTableHelper.name = string.Format("Data Table Helper");
                Transform transform = m_DataTableHelper.transform;
                transform.SetParent(this.transform);
                transform.localScale = Vector3.one;
            }

            m_DataTableManager.SetDataTableHelper(m_DataTableHelper);
        }
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_LocalizationManager = GameFrameworkEntry.GetModule <ILocalizationManager>();
            if (m_LocalizationManager == null)
            {
                Log.Fatal("Localization manager is invalid.");
                return;
            }

            m_LocalizationManager.LoadDictionarySuccess += OnLoadDictionarySuccess;
            m_LocalizationManager.LoadDictionaryFailure += OnLoadDictionaryFailure;

            if (m_EnableLoadDictionaryUpdateEvent)
            {
                m_LocalizationManager.LoadDictionaryUpdate += OnLoadDictionaryUpdate;
            }

            if (m_EnableLoadDictionaryDependencyAssetEvent)
            {
                m_LocalizationManager.LoadDictionaryDependencyAsset += OnLoadDictionaryDependencyAsset;
            }
        }
Ejemplo n.º 6
0
        public void InitData()
        {
            state = EPlayerState.None;

            stateController = new PlayerStateController();

            //初始化玩家状态机
            stateController.Init(this, GameFrameworkEntry.GetModule <IFsmManager>(),
                                 new PlayerStateInit(),
                                 new PlayerStateEnterRoom(),
                                 new PlayerStateSeatPre(),
                                 new PlayerStateSeat(),
                                 new PlayerStateGameReady(),
                                 new PlayerStateStart(),
                                 new PlayerStateDeal(),
                                 new PlayerStatePlaying(),
                                 new PlayerStateBanker(),
                                 new PlayerStateBet(),
                                 new PlayerStateEnd(),
                                 new PlayerStateCardStyle(),
                                 new PlayerStateSettle()
                                 );
            stateController.Start <PlayerStateInit>();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_DataTableManager = GameFrameworkEntry.GetModule <IDataTableManager>();
            if (m_DataTableManager == null)
            {
                Log.Fatal("Data table manager is invalid.");
                return;
            }

            m_DataTableManager.LoadDataTableSuccess += OnLoadDataTableSuccess;
            m_DataTableManager.LoadDataTableFailure += OnLoadDataTableFailure;

            if (m_EnableLoadDataTableUpdateEvent)
            {
                m_DataTableManager.LoadDataTableUpdate += OnLoadDataTableUpdate;
            }

            if (m_EnableLoadDataTableDependencyAssetEvent)
            {
                m_DataTableManager.LoadDataTableDependencyAsset += OnLoadDataTableDependencyAsset;
            }
        }
Ejemplo n.º 8
0
        public void Clear()
        {
            Log.Debug("Player Clear name={0}", name);
            if (stateController != null)
            {
                GameFrameworkEntry.GetModule <IFsmManager>().DestroyFsm(stateController.fsm);
                stateController = null;
            }

            if (headUI != null)
            {
                headUI.Reset();
                headUI = null;
            }
            id.Dispose();
            pos.Dispose();
            clubId.Dispose();
            if (this is PlayerOther)
            {
                RoomManager.Instance.rData.roomPlayers.Remove(this as PlayerOther);
            }

            ClearCards();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_ConfigManager = GameFrameworkEntry.GetModule <IConfigManager>();
            if (m_ConfigManager == null)
            {
                Log.Fatal("Config manager is invalid.");
                return;
            }

            m_ConfigManager.LoadConfigSuccess += OnLoadConfigSuccess;
            m_ConfigManager.LoadConfigFailure += OnLoadConfigFailure;

            if (m_EnableLoadConfigUpdateEvent)
            {
                m_ConfigManager.LoadConfigUpdate += OnLoadConfigUpdate;
            }

            if (m_EnableLoadConfigDependencyAssetEvent)
            {
                m_ConfigManager.LoadConfigDependencyAsset += OnLoadConfigDependencyAsset;
            }
        }
        protected override void Awake()
        {
            base.Awake();

            m_SoundManager = GameFrameworkEntry.GetModule <ISoundManager>();
            if (m_SoundManager == null)
            {
                Log.Fatal("[SoundComponent.Awake] Sound manager is invalid.");
                return;
            }
            m_AudioListener = gameObject.GetOrAddComponent <AudioListener>();    //混音器

            //注册事件
            m_SoundManager.PlaySoundSuccess         += OnPlaySoundSuccess;
            m_SoundManager.PlaySoundFailure         += OnPlaySoundFailure;
            m_SoundManager.PlaySoundUpdate          += OnPlaySoundUpdate;
            m_SoundManager.PlaySoundDependencyAsset += OnPlaySoundDependencyAsset;

            //场景加载相关事件
#if UNITY_5_4_OR_NEWER
            SceneManager.sceneLoaded   += OnSceneLoaded;
            SceneManager.sceneUnloaded += OnSceneUnloaded;
#else
            ISceneManager sceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (sceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            sceneManager.EventLoadSceneSuccess   += OnLoadSceneSuccess;
            sceneManager.EventLoadSceneFailure   += OnLoadSceneFailure;
            sceneManager.EventUnloadSceneSuccess += OnUnloadSceneSuccess;
            sceneManager.EventUnloadSceneFailure += OnUnloadSceneFailure;
#endif
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();
            m_SceneManager = GameFrameworkEntry.GetModule <ISceneManager>();
            if (m_SceneManager == null)
            {
                Log.Fatal("Scene manager is invalid.");
                return;
            }

            m_SceneManager.LoadSceneSuccess         += OnLoadSceneSuccess;
            m_SceneManager.LoadSceneFailure         += OnLoadSceneFailure;
            m_SceneManager.LoadSceneUpdate          += OnLoadSceneUpdate;
            m_SceneManager.LoadSceneDependencyAsset += OnLoadSceneDependencyAsset;
            m_SceneManager.UnloadSceneSuccess       += OnUnloadSceneSuccess;
            m_SceneManager.UnloadSceneFailure       += OnUnloadSceneFailure;

            m_GameFrameworkScene = SceneManager.GetSceneAt(GameFrameworkSceneId);
            if (!m_GameFrameworkScene.IsValid())
            {
                Log.Fatal("Game Framework scene is invalid.");
                return;
            }
        }
Ejemplo n.º 12
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            if (baseComponent.EditorResourceMode)
            {
                m_UIManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_UIManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            m_UIManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_UIManager.InstanceAutoReleaseInterval = m_InstanceAutoReleaseInterval;
            m_UIManager.InstanceCapacity            = m_InstanceCapacity;
            m_UIManager.InstanceExpireTime          = m_InstanceExpireTime;
            m_UIManager.InstancePriority            = m_InstancePriority;

            UIFormHelperBase uiFormHelper = Utility.Helper.CreateHelper(m_UIFormHelperTypeName, m_CustomUIFormHelper);

            if (uiFormHelper == null)
            {
                Log.Error("Can not create UI form helper.");
                return;
            }

            uiFormHelper.name = string.Format("UI Form Helper");
            Transform transform = uiFormHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_UIManager.SetUIFormHelper(uiFormHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("UI Form Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
            }

            m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");

            foreach (UIGroup uiGroup in m_UIGroups)
            {
                if (!AddUIGroup(uiGroup.Name, uiGroup.Depth))
                {
                    Log.Warning("Add UI group '{0}' failure.", uiGroup.Name);
                    continue;
                }
            }
        }
Ejemplo n.º 13
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            //Log.Debug(baseComponent.EditorResourceMode);
            if (baseComponent.EditorResourceMode)
            {
                m_EntityManager.SetResourceManager(baseComponent.EditorResourceHelper);
            }
            else
            {
                m_EntityManager.SetResourceManager(GameFrameworkEntry.GetModule <IResourceManager>());
            }

            m_EntityManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());

            EntityHelperBase entityHelper = Helper.CreateHelper(m_EntityHelperTypeName, m_CustomEntityHelper);

            if (entityHelper == null)
            {
                Log.Error("Can not create entity helper.");
                return;
            }

            entityHelper.name = "Entity Helper";
            Transform transform = entityHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_EntityManager.SetEntityHelper(entityHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Entity Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_EntityGroups.Length; i++)
            {
                if (!AddEntityGroup(m_EntityGroups[i].Name, m_EntityGroups[i].InstanceAutoReleaseInterval, m_EntityGroups[i].InstanceCapacity, m_EntityGroups[i].InstanceExpireTime, m_EntityGroups[i].InstancePriority))
                {
                    Log.Warning("Add entity group '{0}' failure.", m_EntityGroups[i].Name);
                    continue;
                }
            }
        }
        protected override void Awake()
        {
            base.Awake();
            InitVersionHelper(); //初始化版本辅助器
            InitLogHelper();     //初始化Log辅助器
            Log.Info("Game Framework Version: {0}", Version.GameFrameworkVersion);
            Log.Info("Game Version: {0} ({1})", Version.GameVersion, Version.InternalGameVersion.ToString());
            Log.Info("Unity Version: {0}", Application.unityVersion);

#if UNITY_5_3_OR_NEWER
            InitZipHelper();      //初始化压缩辅助器
            InitJsonHelper();     //初始化Json辅助器
            InitProfilerHelper(); //初始化调试辅助器

            Utility.Converter.ScreenDpi = Screen.dpi;
            if (Utility.Converter.ScreenDpi <= 0)
            {
                Utility.Converter.ScreenDpi = DefaultDpi;
            }

            m_IsEditorResourceMode &= Application.isEditor;   //进一步判断是否是在Unity编辑器下
            //设置资源管理器
            ResourceManager = m_IsEditorResourceMode ? gameObject.AddComponent <EditorResourceManager>() : GameFrameworkEntry.GetModule <IResourceManager>();

            Application.targetFrameRate = m_FrameRate;         //帧率
            Time.timeScale = m_GameSpeed;                      //设置游戏速度
            Application.runInBackground = m_IsRunInBackground; //后台运行
            Screen.sleepTimeout         = m_NeverSleep ? SleepTimeout.NeverSleep : SleepTimeout.SystemSetting;
#else
            //Unity5.3以前的版本不能用
            Log.Error("Game Framework only applies with Unity 5.3 and above, but current Unity version is {0}.", Application.unityVersion);
            GameEntry.Shutdown(ShutdownType.Quit);
#endif
#if UNITY_5_6_OR_NEWER
            Application.lowMemory += OnLowMemory;
#endif
        }
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            bool useEditorResources = baseComponent.EditorResourceMode;

            m_ResourceManager = useEditorResources ? baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }

            m_ResourceManager.ResourceInitComplete      += OnResourceInitComplete;
            m_ResourceManager.VersionListUpdateSuccess  += OnVersionListUpdateSuccess;
            m_ResourceManager.VersionListUpdateFailure  += OnVersionListUpdateFailure;
            m_ResourceManager.ResourceCheckComplete     += OnResourceCheckComplete;
            m_ResourceManager.ResourceUpdateStart       += OnResourceUpdateStart;
            m_ResourceManager.ResourceUpdateChanged     += OnResourceUpdateChanged;
            m_ResourceManager.ResourceUpdateSuccess     += OnResourceUpdateSuccess;
            m_ResourceManager.ResourceUpdateFailure     += OnResourceUpdateFailure;
            m_ResourceManager.ResourceUpdateAllComplete += OnResourceUpdateAllComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);

            if (!useEditorResources)
            {
                SetResourceMode(m_ResourceMode);
                m_ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());
                m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
                m_ResourceManager.ResourceCapacity = m_ResourceCapacity;
                if (m_ResourceMode == ResourceMode.Updatable)
                {
                    m_ResourceManager.UpdateRetryCount = m_UpdateRetryCount;
                }

                if (m_ResourceHelper == null)
                {
                    m_ResourceHelper      = (new GameObject()).AddComponent <DefaultResourceHelper>();
                    m_ResourceHelper.name = string.Format("Resource Helper");
                    Transform transform = m_ResourceHelper.transform;
                    transform.SetParent(this.transform);
                    transform.localScale = Vector3.one;
                }

                m_ResourceManager.SetResourceHelper(m_ResourceHelper);

                if (m_InstanceRoot == null)
                {
                    m_InstanceRoot = (new GameObject("Load Resource Agent Instances")).transform;
                    m_InstanceRoot.SetParent(gameObject.transform);
                }

                for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
                {
                    LoadResourceAgentHelperBase helper = null;
                    if (m_LoadResourceAgentHelperTemplate != null)
                    {
                        helper = Instantiate(m_LoadResourceAgentHelperTemplate);
                    }
                    else
                    {
                        helper = (new GameObject()).AddComponent <DefaultLoadResourceAgentHelper>();
                    }

                    helper.name = string.Format("Load Resource Agent Helper - {0}", i.ToString());
                    Transform transform = helper.transform;
                    transform.SetParent(m_InstanceRoot);
                    transform.localScale = Vector3.one;
                    m_ResourceManager.AddLoadResourceAgentHelper(helper);
                }
            }
        }
Ejemplo n.º 16
0
        private void Start()
        {
            //基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[UIComponent.Start] Base component is invalid.");
                return;
            }
            m_UIManager.SetResourceManager(baseComponent.ResourceManager);  //设置资源管理器

            //事件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[UIComponent.Start] Event component is invalid.");
                return;
            }

            //设置对象池
            m_UIManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_UIManager.InstanceAutoReleaseInterval = m_InstanceAutoReleaseInterval;
            m_UIManager.InstanceCapacity            = m_InstanceCapacity;
            m_UIManager.InstanceExpireTime          = m_InstanceExpireTime;
            m_UIManager.InstancePriority            = m_InstancePriority;

            //界面辅助器
            UIFormHelperBase uiFormHelper = Helper.CreateHelper(m_UIFormHelperTypeName, m_CustomUIFormHelper);

            if (uiFormHelper == null)
            {
                Log.Error("[UIComponent.Start] Can not create UI form helper.");
                return;
            }
            uiFormHelper.name = "UI Form Helper";
            Transform trans = uiFormHelper.transform;

            trans.SetParent(this.transform);
            trans.localScale = Vector3.one;
            m_UIManager.SetUIFormHelper(uiFormHelper);  //设置界面辅助器

            //根对象
            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("UI Form Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            m_InstanceRoot.gameObject.layer = LayerMask.NameToLayer("UI");  //设置层

            //添加配置的界面组
            for (int i = 0; i < m_UIGroups.Length; i++)
            {
                if (!AddUIGroup(m_UIGroups[i].Name, m_UIGroups[i].Depth))
                {
                    Log.Warning("[UIComponent.Start] Add UI group '{0}' failure.", m_UIGroups[i].Name);
                    continue;
                }
            }

            UICamera = GetComponentInChildren <Camera>();    //获取UI相机
        }
        private void Start()
        {
            //基础组件
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("[ResourceComponent.Start] Base component is invalid -> baseComponent == null.");
                return;
            }
            //事件组件
            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("[ResourceComponent.Start] Event component is invalid -> m_EventComponent == null.");
                return;
            }
            //资源管理器

            ResourceManager = baseComponent.ResourceManager;
            if (ResourceManager == null)
            {
                Log.Fatal("[ResourceComponent.Start] Resource manager is invalid -> m_ResourceManager == null.");
                return;
            }

            //绑定事件
            ResourceManager.ResourceUpdateStart   += OnResourceUpdateStart;
            ResourceManager.ResourceUpdateChanged += OnResourceUpdateChanged;
            ResourceManager.ResourceUpdateSuccess += OnResourceUpdateSuccess;
            ResourceManager.ResourceUpdateFailure += OnResourceUpdateFailure;

            ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath); //设置只读路径
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = ReadWritePathType.PersistentData;
                }
                ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

#if UNITY_EDITOR
            m_IsEditorResourceMode = baseComponent.IsEditorResourceMode;
            if (m_IsEditorResourceMode) //编辑器模式直接返回即可
            {
                return;
            }
#endif

            SetResourceMode(m_ResourceMode);
            ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());     //设置下载管理器
            ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>()); //设置对象池管理器
            ResourceManager.AssetAutoReleaseInterval    = m_AssetAutoReleaseInterval;
            ResourceManager.AssetCapacity               = m_AssetCapacity;
            ResourceManager.AssetExpireTime             = m_AssetExpireTime;
            ResourceManager.AssetPriority               = m_AssetPriority;
            ResourceManager.ResourceAutoReleaseInterval = m_ResourceAutoReleaseInterval;
            ResourceManager.ResourceCapacity            = m_ResourceCapacity;
            ResourceManager.ResourceExpireTime          = m_ResourceExpireTime;
            ResourceManager.ResourcePriority            = m_ResourcePriority;

            if (m_ResourceMode == ResourceMode.Updatable)
            {
                ResourceManager.UpdatePrefixUri             = m_UpdatePrefixUri;
                ResourceManager.UpdateFileCacheLength       = m_UpdateFileCacheLength;
                ResourceManager.GenerateReadWriteListLength = m_GenerateReadWriteListLength;
                ResourceManager.UpdateRetryCount            = m_UpdateRetryCount;
            }

            //资源辅助器
            m_ResourceHelper = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("[ResourceComponent.Start] Can not create resource helper -> m_ResourceHelper == null.");
                return;
            }
            m_ResourceHelper.name = "Resource Helper";
            Transform trans = m_ResourceHelper.transform;
            trans.SetParent(transform);
            transform.localScale = Vector3.one;
            ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = new GameObject("Load Resource Agent Instances").transform;
                m_InstanceRoot.SetParent(transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }
Ejemplo n.º 18
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent)
            {
                Log.Fatal();
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();

            m_ResourceManager = m_EditorResourceMode ? baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();

            m_ResourceManager.ResourceInitComplete      += OnResourceInitComplete;
            m_ResourceManager.VersionListUpdateSuccess  += OnVersionListUpdateSuccess;
            m_ResourceManager.ResouceCheckComplete      += OnResourceCheckComplete;
            m_ResourceManager.ResourceUpdaterStart      += OnResourceUpdateStart;
            m_ResourceManager.ResourceUpdateSuccess     += OnResourceUpdateSuccess;
            m_ResourceManager.ResourceUpdateAllComplete += OnresourceUpdateAllComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == m_ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = m_ReadWritePathType.PersistentData;
                }
                m_ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

            SetResourceMode(m_ResourceMode);
            m_ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());
            m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_ResourceManager.AssetAutoReleaseInterval = m_AssetAutoReleaseInterval;
            m_ResourceManager.AssetCapacity            = m_AssetCapacity;
            m_ResourceManager.AssetPriority            = m_AssetPriority;
            m_ResourceManager.ResourceCapacity         = m_ResourceCapacity;
            m_ResourceManager.ResourceExpireTime       = m_ResourceExpireTime;
            if (m_ResourceMode == ResourceMode.Updateable)
            {
                m_ResourceManager.UpdatePrefixUri  = m_UpdatePrefixUri;
                m_ResourceManager.UpdateRetryCount = m_UpdateRetryCount;
            }

            m_ResourceHelper      = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            m_ResourceHelper.name = string.Format("Resource Helper");
            Transform transform = m_ResourceHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Load resource Agent Instance")).transform;
                m_InstanceRoot.SetParent(GameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }
Ejemplo n.º 19
0
        private void Start()
        {
            _baseComponent = GameEntry.GetComponent <BaseComponent>();
            if (_baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }
            _eventComponent = GameEntry.GetComponent <EventComponent>();
            if (_eventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            m_EditorResourceMode = _baseComponent.EditorResourceMode;
            m_ResourceManager    = m_EditorResourceMode ? _baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }
            m_ResourceManager.ResourceInitComplete += OnResourceInitComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = ReadWritePathType.PersistentData;
                }

                m_ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

            m_ResourceManager.LoadAssetsComplete += _loadAssetsComplete;

            if (m_EditorResourceMode)
            {
                return;
            }

            m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_ResourceManager.AssetAutoReleaseInterval    = m_AssetAutoReleaseInterval;
            m_ResourceManager.AssetCapacity               = m_AssetCapacity;
            m_ResourceManager.AssetExpireTime             = m_AssetExpireTime;
            m_ResourceManager.AssetPriority               = m_AssetPriority;
            m_ResourceManager.ResourceAutoReleaseInterval = m_ResourceAutoReleaseInterval;
            m_ResourceManager.ResourceCapacity            = m_ResourceCapacity;
            m_ResourceManager.ResourceExpireTime          = m_ResourceExpireTime;
            m_ResourceManager.ResourcePriority            = m_ResourcePriority;
            m_ResourceHelper = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("Can not create resource helper.");
                return;
            }

            m_ResourceHelper.name = string.Format("Resource Helper");
            Transform transform = m_ResourceHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Load Resource Agent Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }
Ejemplo n.º 20
0
 public void TestInitialize()
 {
     m_DataTableManager = GameFrameworkEntry.GetModule <IDataTableManager>();
     Assert.IsNotNull(m_DataTableManager);
 }
Ejemplo n.º 21
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            m_EditorResourceMode = baseComponent.EditorResourceMode;
            m_ResourceManager    = m_EditorResourceMode ? baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }

            m_ResourceManager.ResourceUpdateStart   += OnResourceUpdateStart;
            m_ResourceManager.ResourceUpdateChanged += OnResourceUpdateChanged;
            m_ResourceManager.ResourceUpdateSuccess += OnResourceUpdateSuccess;
            m_ResourceManager.ResourceUpdateFailure += OnResourceUpdateFailure;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            if (m_ReadWritePathType == ReadWritePathType.TemporaryCache)
            {
                m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);
            }
            else
            {
                if (m_ReadWritePathType == ReadWritePathType.Unspecified)
                {
                    m_ReadWritePathType = ReadWritePathType.PersistentData;
                }

                m_ResourceManager.SetReadWritePath(Application.persistentDataPath);
            }

            if (m_EditorResourceMode)
            {
                return;
            }

            SetResourceMode(m_ResourceMode);
            m_ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());
            m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_ResourceManager.AssetAutoReleaseInterval    = m_AssetAutoReleaseInterval;
            m_ResourceManager.AssetCapacity               = m_AssetCapacity;
            m_ResourceManager.AssetExpireTime             = m_AssetExpireTime;
            m_ResourceManager.AssetPriority               = m_AssetPriority;
            m_ResourceManager.ResourceAutoReleaseInterval = m_ResourceAutoReleaseInterval;
            m_ResourceManager.ResourceCapacity            = m_ResourceCapacity;
            m_ResourceManager.ResourceExpireTime          = m_ResourceExpireTime;
            m_ResourceManager.ResourcePriority            = m_ResourcePriority;
            if (m_ResourceMode == ResourceMode.Updatable)
            {
                m_ResourceManager.UpdatePrefixUri             = m_UpdatePrefixUri;
                m_ResourceManager.GenerateReadWriteListLength = m_GenerateReadWriteListLength;
                m_ResourceManager.UpdateRetryCount            = m_UpdateRetryCount;
            }

            m_ResourceHelper = Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("Can not create resource helper.");
                return;
            }

            m_ResourceHelper.name = "Resource Helper";
            Transform transform = m_ResourceHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Load Resource Agent Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
                m_InstanceRoot.localScale = Vector3.one;
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }
Ejemplo n.º 22
0
        private void Start()
        {
            BaseComponent baseComponent = GameEntry.GetComponent <BaseComponent>();

            if (baseComponent == null)
            {
                Log.Fatal("Base component is invalid.");
                return;
            }

            m_EventComponent = GameEntry.GetComponent <EventComponent>();
            if (m_EventComponent == null)
            {
                Log.Fatal("Event component is invalid.");
                return;
            }

            m_EditorResourceMode = baseComponent.EditorResourceMode;
            m_ResourceManager    = m_EditorResourceMode ? baseComponent.EditorResourceHelper : GameFrameworkEntry.GetModule <IResourceManager>();
            if (m_ResourceManager == null)
            {
                Log.Fatal("Resource manager is invalid.");
                return;
            }

            m_ResourceManager.ResourceInitComplete      += OnResourceInitComplete;
            m_ResourceManager.VersionListUpdateSuccess  += OnVersionListUpdateSuccess;
            m_ResourceManager.VersionListUpdateFailure  += OnVersionListUpdateFailure;
            m_ResourceManager.ResourceCheckComplete     += OnResourceCheckComplete;
            m_ResourceManager.ResourceUpdateStart       += OnResourceUpdateStart;
            m_ResourceManager.ResourceUpdateChanged     += OnResourceUpdateChanged;
            m_ResourceManager.ResourceUpdateSuccess     += OnResourceUpdateSuccess;
            m_ResourceManager.ResourceUpdateFailure     += OnResourceUpdateFailure;
            m_ResourceManager.ResourceUpdateAllComplete += OnResourceUpdateAllComplete;

            m_ResourceManager.SetReadOnlyPath(Application.streamingAssetsPath);
            m_ResourceManager.SetReadWritePath(Application.temporaryCachePath);

            if (m_EditorResourceMode)
            {
                return;
            }

            SetResourceMode(m_ResourceMode);
            m_ResourceManager.SetDownloadManager(GameFrameworkEntry.GetModule <IDownloadManager>());
            m_ResourceManager.SetObjectPoolManager(GameFrameworkEntry.GetModule <IObjectPoolManager>());
            m_ResourceManager.AssetCapacity    = m_AssetCapacity;
            m_ResourceManager.ResourceCapacity = m_ResourceCapacity;
            if (m_ResourceMode == ResourceMode.Updatable)
            {
                m_ResourceManager.UpdatePrefixUri  = m_UpdatePrefixUri;
                m_ResourceManager.UpdateRetryCount = m_UpdateRetryCount;
            }

            m_ResourceHelper = Utility.Helper.CreateHelper(m_ResourceHelperTypeName, m_CustomResourceHelper);
            if (m_ResourceHelper == null)
            {
                Log.Error("Can not create resource helper.");
                return;
            }

            m_ResourceHelper.name = string.Format("Resource Helper");
            Transform transform = m_ResourceHelper.transform;

            transform.SetParent(this.transform);
            transform.localScale = Vector3.one;

            m_ResourceManager.SetResourceHelper(m_ResourceHelper);

            if (m_InstanceRoot == null)
            {
                m_InstanceRoot = (new GameObject("Load Resource Agent Instances")).transform;
                m_InstanceRoot.SetParent(gameObject.transform);
            }

            for (int i = 0; i < m_LoadResourceAgentHelperCount; i++)
            {
                AddLoadResourceAgentHelper(i);
            }
        }