/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); m_FileSystemManager = CentorPivot.This.GetComponent <FileSystemComponent>(); if (m_FileSystemManager == null) { Log.Fatal("File system manager is invalid."); return; } FileSystemHelperBase fileSystemHelper = CreateHelper.Create(m_FileSystemHelperTypeName, m_CustomFileSystemHelper); if (fileSystemHelper == null) { Log.Error("Can not create fileSystem helper."); return; } fileSystemHelper.name = "FileSystem Helper"; Transform transform = fileSystemHelper.transform; transform.SetParent(this.transform); transform.localScale = Vector3.one; m_FileSystemManager.SetFileSystemHelper(fileSystemHelper); }
public void CreateObj() { A a = CreateHelper.Create <A>(1, 2); Assert.AreEqual(a.num1, 1); Assert.AreEqual(a.num2, 2); }
/// <summary> /// 增加声音代理辅助器。 /// </summary> /// <param name="soundGroupName">声音组名称。</param> /// <param name="soundGroupHelper">声音组辅助器。</param> /// <param name="index">声音代理辅助器索引。</param> /// <returns>是否增加声音代理辅助器成功。</returns> private bool AddSoundAgentHelper(string soundGroupName, SoundGroupHelperBase soundGroupHelper, int index) { SoundAgentHelperBase soundAgentHelper = CreateHelper.Create(m_SoundAgentHelperTypeName, default(SoundAgentHelperBase)); if (soundAgentHelper == null) { Log.Error("Can not create sound agent helper."); return(false); } soundAgentHelper.name = Utility.Text.Format("Sound Agent Helper - {0} - {1}", soundGroupName, index.ToString()); Transform transform = soundAgentHelper.transform; transform.SetParent(soundGroupHelper.transform); transform.localScale = Vector3.one; if (m_AudioMixer != null) { AudioMixerGroup[] audioMixerGroups = m_AudioMixer.FindMatchingGroups(Utility.Text.Format("Master/{0}/{1}", soundGroupName, index.ToString())); if (audioMixerGroups.Length > 0) { soundAgentHelper.AudioMixerGroup = audioMixerGroups[0]; } else { soundAgentHelper.AudioMixerGroup = soundGroupHelper.AudioMixerGroup; } } m_SoundMethods.AddSoundAgentHelper(soundGroupName, soundAgentHelper); return(true); }
/// <summary> /// Method to find a view by its name or create a new one /// if nothing was found. /// </summary> #endregion protected IView FindOrCreateView(string viewName) { IView result = views[viewName] as IView; if (result == null) { WinformsViewInfo viewInf = ViewInfos[viewName] as WinformsViewInfo; if (viewInf == null) { throw new ViewInfoNotFoundException(viewName); } result = CreateHelper.Create(ViewInfos[viewName].ViewType) as IView; if (result == null) { throw new ViewCreationException(viewName, ViewInfos[viewName].ViewType); } result.ViewName = viewName; if (result is UserControl) { InitializeUserControlView(result as UserControl); } else if (result is Form) { InitializeFormView(result as Form, viewInf); } } return(result); }
/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); m_DataTableManager = CentorPivot.This.GetComponent <DataTableComponent>(); if (m_DataTableManager == null) { Log.Fatal("Data table manager is invalid."); return; } m_EventComponent = CentorPivot.This.GetComponent <EventComponent>(); if (m_EventComponent == null) { Log.Fatal("Event component is invalid."); return; } m_DataTableManager.SetResourceManager(CentorPivot.This.GetComponent <ResourceComponent>()); DataTableHelperBase dataTableHelper = (DataTableHelperBase)CreateHelper.Create(m_DataTableHelperTypeName); if (dataTableHelper == null) { Log.Error("Can not create data table helper."); return; } m_DataTableManager.SetDataProviderHelper(dataTableHelper); }
public CxGameObject AddObject(BornVO bornVO) { var obj = CreateHelper.Create <CxGameObject>(bornVO.ObjectType, bornVO); //objList.Add(obj); return(obj); }
/// <summary> /// 增加下载代理辅助器。 /// </summary> /// <param name="index">下载代理辅助器索引。</param> private void AddDownloadAgentHelper() { DownloadAgentHelperBase downloadAgentHelper = (DownloadAgentHelperBase)CreateHelper.Create(m_DownloadAgentHelperTypeName); if (downloadAgentHelper == null) { Log.Error("Can not create download agent helper."); return; } m_DownloadComponent.AddDownloadAgentHelper(downloadAgentHelper); }
public LocalizationHelperBase GetLocalizationHelper() { LocalizationHelperBase m_LocalizationHelper = (LocalizationHelperBase)CreateHelper.Create(m_LocalizationHelperTypeName); if (m_LocalizationHelper == null) { Log.Error("Can not create Localization helper."); return(null); } return(m_LocalizationHelper); }
/// <summary> /// 游戏框架组件初始化。 /// </summary> protected override void Awake() { base.Awake(); m_SoundMethods = CentorPivot.This.GetComponent <SoundComponent>(); if (m_SoundMethods == null) { Log.Fatal("Sound manager is invalid."); return; } m_AudioListener = gameObject.GetOrAddComponent <AudioListener>(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; if (EventComponent.This == null) { Log.Fatal("Event component is invalid."); return; } m_SoundMethods.SetResourceManager(CentorPivot.This.GetComponent <ResourceComponent>()); SoundHelperBase soundHelper = (SoundHelperBase)CreateHelper.Create(m_SoundHelperTypeName); if (soundHelper == null) { Log.Error("Can not create sound helper."); return; } m_SoundMethods.SetSoundHelper(soundHelper); if (m_InstanceRoot == null) { m_InstanceRoot = new GameObject("Sound Instances").transform; m_InstanceRoot.SetParent(gameObject.transform); m_InstanceRoot.localScale = Vector3.one; } for (int i = 0; i < m_SoundGroups.Length; i++) { if (!AddSoundGroup(m_SoundGroups[i].Name, m_SoundGroups[i].AvoidBeingReplacedBySamePriority, m_SoundGroups[i].Mute, m_SoundGroups[i].Volume, m_SoundGroups[i].AgentHelperCount)) { Log.Warning("Add sound group '{0}' failure.", m_SoundGroups[i].Name); continue; } } }
/// <summary> /// 增加声音组。 /// </summary> /// <param name="soundGroupName">声音组名称。</param> /// <param name="soundGroupAvoidBeingReplacedBySamePriority">声音组中的声音是否避免被同优先级声音替换。</param> /// <param name="soundGroupMute">声音组是否静音。</param> /// <param name="soundGroupVolume">声音组音量。</param> /// <param name="soundAgentHelperCount">声音代理辅助器数量。</param> /// <returns>是否增加声音组成功。</returns> public bool AddSoundGroup(string soundGroupName, bool soundGroupAvoidBeingReplacedBySamePriority, bool soundGroupMute, float soundGroupVolume, int soundAgentHelperCount) { if (m_SoundMethods.HasSoundGroup(soundGroupName)) { return(false); } SoundGroupHelperBase soundGroupHelper = CreateHelper.Create(m_SoundGroupHelperTypeName, default(SoundGroupHelperBase)); if (soundGroupHelper == null) { Log.Error("Can not create sound group helper."); return(false); } soundGroupHelper.name = Utility.Text.Format("Sound Group - {0}", soundGroupName); Transform transform = soundGroupHelper.transform; transform.SetParent(m_InstanceRoot); transform.localScale = Vector3.one; if (m_AudioMixer != null) { AudioMixerGroup[] audioMixerGroups = m_AudioMixer.FindMatchingGroups(Utility.Text.Format("Master/{0}", soundGroupName)); if (audioMixerGroups.Length > 0) { soundGroupHelper.AudioMixerGroup = audioMixerGroups[0]; } else { soundGroupHelper.AudioMixerGroup = m_AudioMixer.FindMatchingGroups("Master")[0]; } } if (!m_SoundMethods.AddSoundGroup(soundGroupName, soundGroupAvoidBeingReplacedBySamePriority, soundGroupMute, soundGroupVolume, soundGroupHelper)) { return(false); } for (int i = 0; i < soundAgentHelperCount; i++) { if (!AddSoundAgentHelper(soundGroupName, soundGroupHelper, i)) { return(false); } } return(true); }
private Form FindOrCreateView(string viewName) { Form result = null; forms.TryGetValue(viewName, out result); if ((result == null) || result.IsDisposed) { result = CreateHelper.Create(ViewInfos[viewName].ViewType) as Form; result.Activated += new EventHandler(view_Activated); forms[viewName] = result; (result as IView).ViewName = viewName; InitializeView(result as IView); } return(result); }
private Navigator CreateNavigator(TaskInfo ti) { if (ti.NavigatorType != null) { return(CreateHelper.Create(ti.NavigatorType) as Navigator); } else if (Config.NavigatorType != null) { return(CreateHelper.Create(Config.NavigatorType) as Navigator); } else { return(new Navigator()); } }
/// <summary> /// It is the navigator's job to maintain all controllers within a task. /// GetController method returns a controller for a specific view. /// </summary> /// <param name="viewName">The name of the view to return controller for.</param> /// <returns>The desired <see cref="IController"/> instance, or <c>null</c> /// if it cannot be found or created.</returns> /// <remarks>If the controller does not exists yet, it is created with /// a type obtained from the <see cref="TaskInfo"/> object.</remarks> #endregion public IController GetController(string viewName) { IController result = controllers[viewName] as IController; if (result == null) { InteractionPointInfo iPointInf = TaskInfo.InteractionPoints[viewName]; if ((iPointInf == null) || (iPointInf.ControllerType == null)) { return(null); } result = CreateHelper.Create(iPointInf.ControllerType) as IController; result.Task = Task; controllers[viewName] = result; } return(result); }
/// <summary> /// Starts a task passing <c>param</c> to the <see cref="ITask.OnStart"> /// ITask.OnStart</see> operation. Task description (<see cref="TaskInfo"/> /// instance) and views manager type are taken from the /// associated <see cref="TasksManager.Config">TasksManager.Config</see> /// object.</summary> /// <param name="taskType">The type of the task to start.</param> /// <param name="param">Parameter passed to the <see cref="ITask.OnStart"> /// ITask.OnStart</see> method.</param> #endregion public ITask StartTask(Type taskType, object param) { TaskInfo ti = GetTaskInfo(taskType); Navigator n = new Navigator(); IViewsManager vm = CreateHelper.Create(Config.ViewsManagerType) as IViewsManager; ITask t = CreateHelper.Create(taskType) as ITask; n.TaskInfo = ti; n.ViewsManager = vm; n.Task = t; vm.Navigator = n; vm.ViewInfos = ti.ViewInfos; t.TasksManager = this; t.Navigator = n; t.OnStart(param); return(t); }
protected override void Awake() { base.Awake(); if (EventComponent.This == null) { Log.Fatal("Event component is invalid."); return; } if (ResourceComponent.This == null) { Log.Fatal("Resource manager is invalid."); return; } ResourceComponent.This.SetUnloadUnusedAssetsInterval(m_UnloadUnusedAssetsInterval); if (m_ResourceMode == ResourceMode.Unspecified) { m_ResourceMode = ResourceMode.Editor; } ResourceComponent.This.ResourceApplySuccess += OnResourceApplySuccess; ResourceComponent.This.ResourceApplyFailure += OnResourceApplyFailure; ResourceComponent.This.ResourceUpdateStart += OnResourceUpdateStart; ResourceComponent.This.ResourceUpdateChanged += OnResourceUpdateChanged; ResourceComponent.This.ResourceUpdateSuccess += OnResourceUpdateSuccess; ResourceComponent.This.ResourceUpdateFailure += OnResourceUpdateFailure; if (m_ResourceMode == ResourceMode.Updatable) { if (m_ReadWritePathType == ReadWritePathType.TemporaryCache) { ResourceComponent.This.SetReadWritePath(Application.temporaryCachePath); } else { if (m_ReadWritePathType == ReadWritePathType.Unspecified) { m_ReadWritePathType = ReadWritePathType.PersistentData; } ResourceComponent.This.SetReadWritePath(Application.persistentDataPath); } ResourceComponent.This.SetReadOnlyPath(Application.streamingAssetsPath); SetSerializer(); ResourceComponent.This.SetFileSystemManager(CentorPivot.This.GetComponent <FileSystemComponent>()); ResourceComponent.This.SetDownloadManager(CentorPivot.This.GetComponent <DownloadComponent>()); if (m_ResourceMode == ResourceMode.Updatable) { ResourceComponent.This.UpdatePrefixUri = m_UpdatePrefixUri; GenerateReadWriteVersionListLength = m_GenerateReadWriteVersionListLengthX * m_GenerateReadWriteVersionListLengthX; ResourceComponent.This.GenerateReadWriteVersionListLength = m_GenerateReadWriteVersionListLength; ResourceComponent.This.UpdateRetryCount = m_UpdateRetryCount; } m_ResourceHelper = CreateHelper.Create(m_ResourceHelperTypeName, default(ResourceHelperBase)); 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; ResourceComponent.This.SetResourceHelper(m_ResourceHelper); for (int i = 0; i < m_LoadResourceAgentHelperCount; i++) { AddLoadResourceAgentHelper(); } } }
/// <summary> /// 增加 Web 请求代理辅助器。 /// </summary> private void AddWebRequestAgentHelper() { WebRequestAgentHelperBase webRequestAgentHelper = (WebRequestAgentHelperBase)CreateHelper.Create(m_WebRequestAgentHelperTypeName); if (webRequestAgentHelper == null) { Log.Error("Can not create web request agent helper."); return; } m_WebRequestMethods.AddWebRequestAgentHelper(webRequestAgentHelper); }
/// <summary> /// 增加加载资源代理辅助器。 /// </summary> /// <param name="index">加载资源代理辅助器索引。</param> private void AddLoadResourceAgentHelper() { LoadResourceAgentHelperBase loadResourceAgentHelper = (LoadResourceAgentHelperBase)CreateHelper.Create(m_LoadResourceAgentHelperTypeName); if (loadResourceAgentHelper == null) { Log.Error("Can not create load resource agent helper."); return; } ResourceComponent.This.AddLoadResourceAgentHelper(loadResourceAgentHelper); }