/// <summary> /// 设置声音绑定的实体。 /// </summary> /// <param name="bindingEntity">声音绑定的实体。</param> public override void SetBindingEntity(GEntity bindingEntity) { m_BindingEntityLogic = bindingEntity.Logic; if (m_BindingEntityLogic != null) { UpdateAgentPosition(); return; } if (m_ResetSoundAgentEventHandler != null) { ResetSoundAgentEventArgs resetSoundAgentEventArgs = ResetSoundAgentEventArgs.Create(); m_ResetSoundAgentEventHandler(this, resetSoundAgentEventArgs); ReferencePool.Release(resetSoundAgentEventArgs); } }
private void LoadUIFormUpdateCallback(string uiFormAssetName, float progress, object userData) { OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData; if (openUIFormInfo == null) { throw new GameFrameworkException("Open UI form info is invalid."); } if (m_OpenUIFormUpdateEventHandler != null) { OpenUIFormUpdateEventArgs openUIFormUpdateEventArgs = OpenUIFormUpdateEventArgs.Create(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup.Name, openUIFormInfo.PauseCoveredUIForm, progress, openUIFormInfo.UserData); m_OpenUIFormUpdateEventHandler(this, openUIFormUpdateEventArgs); ReferencePool.Release(openUIFormUpdateEventArgs); } }
private void LoadAssetUpdateCallback(string entityAssetName, float progress, object userData) { ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData; if (showEntityInfo == null) { throw new GameFrameworkException("Show entity info is invalid."); } if (m_ShowEntityUpdateEventHandler != null) { ShowEntityUpdateEventArgs showEntityUpdateEventArgs = ShowEntityUpdateEventArgs.Create(showEntityInfo.EntityId, entityAssetName, showEntityInfo.EntityGroup.Name, progress, showEntityInfo.UserData); m_ShowEntityUpdateEventHandler(this, showEntityUpdateEventArgs); ReferencePool.Release(showEntityUpdateEventArgs); } }
private void LoadAssetDependencyAssetCallback(string entityAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { ShowEntityInfo showEntityInfo = (ShowEntityInfo)userData; if (showEntityInfo == null) { throw new GameFrameworkException("Show entity info is invalid."); } if (m_ShowEntityDependencyAssetEventHandler != null) { ShowEntityDependencyAssetEventArgs showEntityDependencyAssetEventArgs = ShowEntityDependencyAssetEventArgs.Create(showEntityInfo.EntityId, entityAssetName, showEntityInfo.EntityGroup.Name, dependencyAssetName, loadedCount, totalCount, showEntityInfo.UserData); m_ShowEntityDependencyAssetEventHandler(this, showEntityDependencyAssetEventArgs); ReferencePool.Release(showEntityDependencyAssetEventArgs); } }
private void LoadAssetDependencyAssetCallback(string soundAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)userData; if (playSoundInfo == null) { throw new GameFrameworkException("Play sound info is invalid."); } if (m_PlaySoundDependencyAssetEventHandler != null) { PlaySoundDependencyAssetEventArgs playSoundDependencyAssetEventArgs = PlaySoundDependencyAssetEventArgs.Create(playSoundInfo.SerialId, soundAssetName, playSoundInfo.SoundGroup.Name, playSoundInfo.PlaySoundParams, dependencyAssetName, loadedCount, totalCount, playSoundInfo.UserData); m_PlaySoundDependencyAssetEventHandler(this, playSoundDependencyAssetEventArgs); ReferencePool.Release(playSoundDependencyAssetEventArgs); } }
/// <summary> /// 创建播放声音失败事件。 /// </summary> /// <param name="e">内部事件。</param> /// <returns>创建的播放声音失败事件。</returns> public static PlaySoundFailureEventArgs Create(GameFramework.Sound.PlaySoundFailureEventArgs e) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)e.UserData; PlaySoundFailureEventArgs playSoundFailureEventArgs = ReferencePool.Acquire <PlaySoundFailureEventArgs>(); playSoundFailureEventArgs.SerialId = e.SerialId; playSoundFailureEventArgs.SoundAssetName = e.SoundAssetName; playSoundFailureEventArgs.SoundGroupName = e.SoundGroupName; playSoundFailureEventArgs.PlaySoundParams = e.PlaySoundParams; playSoundFailureEventArgs.BindingEntity = playSoundInfo.BindingEntity; playSoundFailureEventArgs.ErrorCode = e.ErrorCode; playSoundFailureEventArgs.ErrorMessage = e.ErrorMessage; playSoundFailureEventArgs.UserData = playSoundInfo.UserData; ReferencePool.Release(playSoundInfo); return(playSoundFailureEventArgs); }
protected override void OnUnload() { GameEntry.DataTable.DestroyDataTable <DRLevel>(); dtLevel = null; dicLevelData = null; if (CurrentLevel != null) { ReferencePool.Release(CurrentLevel); CurrentLevel = null; } LevelState = EnumLevelState.None; CurrentLevelIndex = NONE_LEVEL_INDEX; }
private void LoadAssetUpdateCallback(string soundAssetName, float progress, object userData) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)userData; if (playSoundInfo == null) { throw new GameFrameworkException("Play sound info is invalid."); } if (m_PlaySoundUpdateEventHandler != null) { PlaySoundUpdateEventArgs playSoundUpdateEventArgs = PlaySoundUpdateEventArgs.Create(playSoundInfo.SerialId, soundAssetName, playSoundInfo.SoundGroup.Name, playSoundInfo.PlaySoundParams, progress, playSoundInfo.UserData); m_PlaySoundUpdateEventHandler(this, playSoundUpdateEventArgs); ReferencePool.Release(playSoundUpdateEventArgs); } }
private void LoadAssetDependencyAssetCallback(string dataTableAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { LoadDataTableInfo loadDataTableInfo = (LoadDataTableInfo)userData; if (loadDataTableInfo == null) { throw new GameFrameworkException("Load data table info is invalid."); } if (m_LoadDataTableDependencyAssetEventHandler != null) { LoadDataTableDependencyAssetEventArgs loadDataTableDependencyAssetEventArgs = LoadDataTableDependencyAssetEventArgs.Create(dataTableAssetName, dependencyAssetName, loadedCount, totalCount, loadDataTableInfo.UserData); m_LoadDataTableDependencyAssetEventHandler(this, loadDataTableDependencyAssetEventArgs); ReferencePool.Release(loadDataTableDependencyAssetEventArgs); } }
private void OnLoadBinaryFailure(string fileUri, string errorMessage, object userData) { LoadBinaryInfo loadBinaryInfo = (LoadBinaryInfo)userData; if (loadBinaryInfo == null) { throw new GameFrameworkException("Load binary info is invalid."); } if (loadBinaryInfo.LoadBinaryCallbacks.LoadBinaryFailureCallback != null) { loadBinaryInfo.LoadBinaryCallbacks.LoadBinaryFailureCallback(loadBinaryInfo.BinaryAssetName, LoadResourceStatus.AssetError, errorMessage, loadBinaryInfo.UserData); } ReferencePool.Release(loadBinaryInfo); }
private void LoadUIFormDependencyAssetCallback(string uiFormAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData) { OpenUIFormInfo openUIFormInfo = (OpenUIFormInfo)userData; if (openUIFormInfo == null) { throw new GameFrameworkException("Open UI form info is invalid."); } if (m_OpenUIFormDependencyAssetEventHandler != null) { OpenUIFormDependencyAssetEventArgs openUIFormDependencyAssetEventArgs = OpenUIFormDependencyAssetEventArgs.Create(openUIFormInfo.SerialId, uiFormAssetName, openUIFormInfo.UIGroup.Name, openUIFormInfo.PauseCoveredUIForm, dependencyAssetName, loadedCount, totalCount, openUIFormInfo.UserData); m_OpenUIFormDependencyAssetEventHandler(this, openUIFormDependencyAssetEventArgs); ReferencePool.Release(openUIFormDependencyAssetEventArgs); } }
private void LoadAssetUpdateCallback(string configAssetName, float progress, object userData) { LoadConfigInfo loadConfigInfo = (LoadConfigInfo)userData; if (loadConfigInfo == null) { throw new GameFrameworkException("Load config info is invalid."); } if (m_LoadConfigUpdateEventHandler != null) { LoadConfigUpdateEventArgs loadConfigUpdateEventArgs = LoadConfigUpdateEventArgs.Create(configAssetName, loadConfigInfo.LoadType, progress, loadConfigInfo.UserData); m_LoadConfigUpdateEventHandler(this, loadConfigUpdateEventArgs); ReferencePool.Release(loadConfigUpdateEventArgs); } }
private void LoadSoundSuccessCallback(string soundAssetName, object soundAsset, float duration, object userData) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)userData; if (playSoundInfo == null) { throw new GameFrameworkException("Play sound info is invalid."); } if (m_SoundsToReleaseOnLoad.Contains(playSoundInfo.SerialId)) { m_SoundsToReleaseOnLoad.Remove(playSoundInfo.SerialId); ReferencePool.Release(playSoundInfo); m_SoundHelper.ReleaseSoundAsset(soundAsset); return; } m_SoundsBeingLoaded.Remove(playSoundInfo.SerialId); PlaySoundErrorCode?errorCode = null; ISoundAgent soundAgent = playSoundInfo.SoundGroup.PlaySound(playSoundInfo.SerialId, soundAsset, playSoundInfo.PlaySoundParams, out errorCode); if (soundAgent != null) { if (m_PlaySoundSuccessEventHandler != null) { m_PlaySoundSuccessEventHandler(this, new PlaySoundSuccessEventArgs(playSoundInfo.SerialId, soundAssetName, soundAgent, duration, playSoundInfo.UserData)); } ReferencePool.Release(playSoundInfo); return; } m_SoundsToReleaseOnLoad.Remove(playSoundInfo.SerialId); m_SoundHelper.ReleaseSoundAsset(soundAsset); string errorMessage = Utility.Text.Format("Sound group '{0}' play sound '{1}' failure.", playSoundInfo.SoundGroup.Name, soundAssetName); if (m_PlaySoundFailureEventHandler != null) { m_PlaySoundFailureEventHandler(this, new PlaySoundFailureEventArgs(playSoundInfo.SerialId, soundAssetName, playSoundInfo.SoundGroup.Name, playSoundInfo.PlaySoundParams, errorCode.Value, errorMessage, playSoundInfo.UserData)); ReferencePool.Release(playSoundInfo); return; } ReferencePool.Release(playSoundInfo); throw new GameFrameworkException(errorMessage); }
public void GetDeviceBindList(PlatformDeviceBindRequest request, Action <PlatformDeviceBindResponse> response) { Request(WebUtility.GetUFUrl("device/bind-list"), request, (res) => { ReferencePool.Release(request); PlatformDeviceBindResponse deviceBind = Utility.Json.ToObject <PlatformDeviceBindResponse>(res); if (deviceBind == null) { Log.Error("Parse PlatformDeviceBindResponse failure."); return; } if (response != null) { response(deviceBind); } }); }
public void LoadAssetSync() { var assetPath = AssetDatabase.GetAssetPathsFromAssetBundle(AssetBundleName); if (assetPath.Length != 0) { BundleInfo = CreateAssetDatabaseInfo(AssetBundleName, assetPath); BundleInfo.UpdateLastUsedTime(); } LoadState = enLoadState.SelfComplete; OnLoadSelfBundleAction?.Invoke(this); LoadState = enLoadState.AllComplete; BundleInfo.IsReady = true; OnLoadAllBundleAction?.Invoke(BundleInfo, UserData); OnLoadAllBundleAction = null; ReferencePool.Release <AssetDatabaseLoader>(this); }
private void UnLoadAssetBundle(string name) { AssetBundleItem item = null; uint crc = Crc32.GetCrc32(name); if (m_AssetBundleItemDic.TryGetValue(crc, out item) && item != null) { item.RefCount--; if (item.RefCount <= 0 && item.AssetBundle != null) { Log.Debug("release " + name); item.AssetBundle.Unload(true); ReferencePool.Release(item); m_AssetBundleItemDic.Remove(crc); } } }
private void Update() { if (m_WWW == null) { return; } int deltaLength = m_WWW.bytesDownloaded - m_LastDownloadedSize; if (deltaLength > 0) { m_LastDownloadedSize = m_WWW.bytesDownloaded; DownloadAgentHelperUpdateLengthEventArgs downloadAgentHelperUpdateLengthEventArgs = DownloadAgentHelperUpdateLengthEventArgs.Create(deltaLength); m_DownloadAgentHelperUpdateLengthEventHandler(this, downloadAgentHelperUpdateLengthEventArgs); ReferencePool.Release(downloadAgentHelperUpdateLengthEventArgs); } if (m_WWW == null) { return; } if (!m_WWW.isDone) { return; } if (!string.IsNullOrEmpty(m_WWW.error)) { DownloadAgentHelperErrorEventArgs dodwnloadAgentHelperErrorEventArgs = DownloadAgentHelperErrorEventArgs.Create(m_WWW.error.StartsWith(RangeNotSatisfiableErrorCode.ToString()), m_WWW.error); m_DownloadAgentHelperErrorEventHandler(this, dodwnloadAgentHelperErrorEventArgs); ReferencePool.Release(dodwnloadAgentHelperErrorEventArgs); } else { byte[] bytes = m_WWW.bytes; DownloadAgentHelperUpdateBytesEventArgs downloadAgentHelperUpdateBytesEventArgs = DownloadAgentHelperUpdateBytesEventArgs.Create(bytes, 0, bytes.Length); m_DownloadAgentHelperUpdateBytesEventHandler(this, downloadAgentHelperUpdateBytesEventArgs); ReferencePool.Release(downloadAgentHelperUpdateBytesEventArgs); DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = DownloadAgentHelperCompleteEventArgs.Create(bytes.Length); m_DownloadAgentHelperCompleteEventHandler(this, downloadAgentHelperCompleteEventArgs); ReferencePool.Release(downloadAgentHelperCompleteEventArgs); } }
protected override void OnOpen(object userData) { base.OnOpen(userData); UIGameOverFormOpenParam uIGameOverFormOpenParam = userData as UIGameOverFormOpenParam; if (uIGameOverFormOpenParam == null) { Log.Error("UIGameOverForm open param tyoe invaild"); return; } switch (uIGameOverFormOpenParam.EnumGameOverType) { case EnumGameOverType.Success: title.text = string.Format(GameEntry.Localization.GetString("Level Complete"), uIGameOverFormOpenParam.LevelData.Name); GameEntry.Sound.PlaySound(EnumSound.TDVictory); break; case EnumGameOverType.Fail: title.text = string.Format(GameEntry.Localization.GetString("Level Failed"), uIGameOverFormOpenParam.LevelData.Name); GameEntry.Sound.PlaySound(EnumSound.TDDefeat); break; } for (int i = 0; i < starImages.Length; i++) { if (i < uIGameOverFormOpenParam.StarCount) { starImages[i].sprite = starSprite; } else { starImages[i].sprite = starBgSprite; } } nextLevelButton.gameObject.SetActive(uIGameOverFormOpenParam.EnumGameOverType == EnumGameOverType.Success); DataLevel dataLevel = GameEntry.Data.GetData <DataLevel>(); int nextLevel = dataLevel.CurrentLevelIndex + 1; nextLevelButton.interactable = nextLevel <= dataLevel.MaxLevel; ReferencePool.Release(uIGameOverFormOpenParam); }
public Packet DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData) { customErrorData = null; SCPacketHeader scPacketHeader = packetHeader as SCPacketHeader; if (scPacketHeader == null) { Log.Warning("Packet header is invalid."); return(null); } Packet packet = null; if (scPacketHeader.IsValid) { if (scPacketHeader.Id == 4) { //BinaryReader r = new BinaryReader(source); //byte[] message = r.ReadBytes((int)(source.Length - source.Position)); //string returnStr = string.Empty; //for (int i = 0; i < message.Length; i++) //{ // returnStr += message[i].ToString("X2"); //} SCData scData = SCData.Create(); ((DataResponse)scData.GetExtensionObject()).MergeFrom(source); //Log.Info("data response {0}", scData); packet = scData; } else { packet = SCHeartBeat.Create(); Log.Info("heart response "); } } else { Log.Warning("Packet header is invalid."); } ReferencePool.Release(scPacketHeader); return(packet); }
private void OnLoadBinarySuccess(string fileUri, byte[] bytes, float duration, object userData) { LoadBinaryInfo loadBinaryInfo = (LoadBinaryInfo)userData; if (loadBinaryInfo == null) { throw new GameFrameworkException("Load binary info is invalid."); } if (loadBinaryInfo.ResourceInfo.LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || loadBinaryInfo.ResourceInfo.LoadType == LoadType.LoadFromBinaryAndDecrypt) { DecryptResourceCallback decryptResourceCallback = m_ResourceManager.m_DecryptResourceCallback ?? DefaultDecryptResourceCallback; bytes = decryptResourceCallback(loadBinaryInfo.ResourceInfo.ResourceName.Name, loadBinaryInfo.ResourceInfo.ResourceName.Variant, (byte)loadBinaryInfo.ResourceInfo.LoadType, loadBinaryInfo.ResourceInfo.Length, loadBinaryInfo.ResourceInfo.HashCode, loadBinaryInfo.ResourceInfo.StorageInReadOnly, bytes); } loadBinaryInfo.LoadBinaryCallbacks.LoadBinarySuccessCallback(loadBinaryInfo.BinaryAssetName, bytes, duration, loadBinaryInfo.UserData); ReferencePool.Release(loadBinaryInfo); }
private void HandleEvent(object sender, T e) { int eventId = e.Id; EventHandler <T> handlers = null; if (m_EventHandlers.TryGetValue(eventId, out handlers)) { if (handlers != null) { handlers(sender, e); } else { Debug.LogError("Event don't have handle method" + eventId); } } ReferencePool.Release(e); }
/// <summary> /// 寻路到某个点然后做某事,如果当前距离小于目标距离则直接进入状态,否则就寻路到适合的地点再进行寻路 /// </summary> /// <param name="self"></param> /// <param name="target">目标地点</param> /// <param name="targetRange">目标距离</param> /// <param name="targetState">目标状态</param> public static void NavigateTodoSomething(this UnitPathComponent self, Vector3 target, float targetRange, AFsmStateBase targetState) { if (Vector3.Distance((self.Entity as Unit).Position, target) >= targetRange) { if (!self.Entity.GetComponent <StackFsmComponent>().ChangeState <NavigateState>(StateTypes.Run, "Navigate", 1)) { ReferencePool.Release(targetState); return; } self.MoveTodoSomething(target, self.Entity.GetComponent <StackFsmComponent>().GetCurrentFsmState(), targetState, targetRange) .Coroutine(); } else { self.Entity.GetComponent <StackFsmComponent>().ChangeState(targetState); } }
protected override void OnClose(bool isShutdown, object userData) { base.OnClose(isShutdown, userData); UnSubscribeAll(); if (eventSubscriber != null) { ReferencePool.Release(eventSubscriber); eventSubscriber = null; } HideAllItem(); if (itemLoader != null) { ReferencePool.Release(itemLoader); itemLoader = null; } }
public void Clear() { if (m_Data != null) { ReferencePool.Release(m_Data); m_Data = null; } if (m_Childs != null) { foreach (DataNode child in m_Childs) { ReferencePool.Release(child); } m_Childs.Clear(); } }
private void TimerUpdate(int detalTime, enTimerType timerType) { var list = timers[timerType]; int i = 0; while (i < list.Count) { if (list[i].IsFinish) { ReferencePool.Release(list[i]); list.RemoveAt(i); } else { list[i].OnUpdate(detalTime); i++; } } }
protected override void OnUnload() { GameEntry.DataTable.DestroyDataTable <DRTower>(); GameEntry.DataTable.DestroyDataTable <DRTowerLevel>(); dicTowerData = null; dicTowerLevelData = null; if (dicTower != null) { foreach (var item in dicTower.Values) { ReferencePool.Release(item); } dicTower.Clear(); } serialId = 0; }
/// <summary> /// 序列化消息包 /// </summary> /// <typeparam name="T">消息包类型</typeparam> /// <param name="packet">消息包对象</param> /// <returns></returns> public byte[] Serialize <T>(T packet) where T : Packet { PacketBase packetImpl = packet as PacketBase; if (packetImpl == null) { Log.Warning("Packet is null."); return(null); } if (packetImpl.PacketType != PacketType.ClientToServer) { Log.Warning("Packet type is invalid."); return(null); } // 恐怖的 GCAlloc,这里是例子,不做优化 using (MemoryStream stream = new MemoryStream()) { //跳过消息头长度(8)的位置开始序列化消息内容 stream.Position = PacketHeaderLength; Serializer.SerializeWithLengthPrefix <T>(stream, packet, PrefixStyle.Fixed32); //回头再来序列化消息包头 stream.Position = 0; CSPacketHeader header = ReferencePool.Acquire <CSPacketHeader>(); header.Id = packet.Id; header.PacketLength = (int)stream.Length - PacketHeaderLength; //Log.Info("序列化的id:" + header.Id); //Log.Info("序列化的包体长度:" + header.PacketLength); //方式1:直接写入字节数据id+packetLen stream.Write(BitConverter.GetBytes(header.Id), 0, 4); stream.Write(BitConverter.GetBytes(header.PacketLength), 0, 4); //方式2:用头部结构体序列化进去(暂时没测通过) //Serializer.SerializeWithLengthPrefix(stream, header, PrefixStyle.Fixed32); ReferencePool.Release <CSPacketHeader>(header); return(stream.ToArray()); } }
private void InternalHideEntity(EntityInfo entityInfo, object userData) { IEntity entity = entityInfo.Entity; IEntity[] childEntities = entityInfo.GetChildEntities(); foreach (IEntity childEntity in childEntities) { HideEntity(childEntity.Id, userData); } if (entityInfo.Status == EntityStatus.Hidden) { return; } DetachEntity(entity.Id, userData); entityInfo.Status = EntityStatus.WillHide; entity.OnHide(m_IsShutdown, userData); entityInfo.Status = EntityStatus.Hidden; EntityGroup entityGroup = (EntityGroup)entity.EntityGroup; if (entityGroup == null) { throw new GameFrameworkException("Entity group is invalid."); } entityGroup.RemoveEntity(entity); if (!m_EntityInfos.Remove(entity.Id)) { throw new GameFrameworkException("Entity info is unmanaged."); } if (m_HideEntityCompleteEventHandler != null) { HideEntityCompleteEventArgs hideEntityCompleteEventArgs = HideEntityCompleteEventArgs.Create(entity.Id, entity.EntityAssetName, entityGroup, userData); m_HideEntityCompleteEventHandler(this, hideEntityCompleteEventArgs); ReferencePool.Release(hideEntityCompleteEventArgs); } m_RecycleQueue.Enqueue(entityInfo); }
public void Update(float elapseSeconds, float realElapseSeconds) { if (m_DownloadCounterNodes.Count <= 0) { return; } m_Accumulator += realElapseSeconds; if (m_Accumulator > m_RecordInterval) { m_Accumulator = m_RecordInterval; } m_TimeLeft -= realElapseSeconds; foreach (DownloadCounterNode downloadCounterNode in m_DownloadCounterNodes) { downloadCounterNode.Update(elapseSeconds, realElapseSeconds); } while (m_DownloadCounterNodes.Count > 0 && m_DownloadCounterNodes.Peek().ElapseSeconds >= m_RecordInterval) { ReferencePool.Release(m_DownloadCounterNodes.Dequeue()); } if (m_DownloadCounterNodes.Count <= 0) { Reset(); return; } if (m_TimeLeft <= 0f) { int totalDownloadLength = 0; foreach (DownloadCounterNode downloadCounterNode in m_DownloadCounterNodes) { totalDownloadLength += downloadCounterNode.DownloadedLength; } m_CurrentSpeed = m_Accumulator > 0f ? totalDownloadLength / m_Accumulator : 0f; m_TimeLeft += m_UpdateInterval; } }
private void LoadSoundFailureCallback(string soundAssetName, LoadResourceStatus status, string errorMessage, object userData) { PlaySoundInfo playSoundInfo = (PlaySoundInfo)userData; if (playSoundInfo == null) { throw new GameFrameworkException("Play sound info is invalid."); } if (m_SoundsToReleaseOnLoad.Contains(playSoundInfo.SerialId)) { m_SoundsToReleaseOnLoad.Remove(playSoundInfo.SerialId); if (playSoundInfo.PlaySoundParams.Referenced) { ReferencePool.Release(playSoundInfo.PlaySoundParams); } ReferencePool.Release(playSoundInfo); return; } m_SoundsBeingLoaded.Remove(playSoundInfo.SerialId); string appendErrorMessage = Utility.Text.Format("Load sound failure, asset name '{0}', status '{1}', error message '{2}'.", soundAssetName, status.ToString(), errorMessage); if (m_PlaySoundFailureEventHandler != null) { PlaySoundFailureEventArgs playSoundFailureEventArgs = PlaySoundFailureEventArgs.Create(playSoundInfo.SerialId, soundAssetName, playSoundInfo.SoundGroup.Name, playSoundInfo.PlaySoundParams, PlaySoundErrorCode.LoadAssetFailure, appendErrorMessage, playSoundInfo.UserData); m_PlaySoundFailureEventHandler(this, playSoundFailureEventArgs); ReferencePool.Release(playSoundFailureEventArgs); if (playSoundInfo.PlaySoundParams.Referenced) { ReferencePool.Release(playSoundInfo.PlaySoundParams); } ReferencePool.Release(playSoundInfo); return; } ReferencePool.Release(playSoundInfo); throw new GameFrameworkException(appendErrorMessage); }