private void InternalShowItem(int itemId, string itemAssetName, ItemGroup itemGroup, object itemInstance, bool isNewInstance, float duration, object userData) { try { IItem item = m_ItemHelper.CreateItem(itemInstance, itemGroup, userData); if (item == null) { throw new GameFrameworkException("Can not create item in helper."); } ItemInfo itemInfo = ItemInfo.Create(item); m_ItemInfos.Add(itemId, itemInfo); itemInfo.Status = ItemStatus.WillInit; item.OnInit(itemId, itemAssetName, itemGroup, isNewInstance, userData); itemInfo.Status = ItemStatus.Inited; itemGroup.AddItem(item); itemInfo.Status = ItemStatus.WillShow; item.OnShow(userData); itemInfo.Status = ItemStatus.Showed; if (m_ShowItemSuccessEventHandler != null) { ShowItemSuccessEventArgs showItemSuccessEventArgs = ShowItemSuccessEventArgs.Create(item, duration, userData); m_ShowItemSuccessEventHandler(this, showItemSuccessEventArgs); ReferencePool.Release(showItemSuccessEventArgs); } } catch (Exception exception) { if (m_ShowItemFailureEventHandler != null) { ShowItemFailureEventArgs showItemFailureEventArgs = ShowItemFailureEventArgs.Create(itemId, itemAssetName, itemGroup.Name, exception.ToString(), userData); m_ShowItemFailureEventHandler(this, showItemFailureEventArgs); ReferencePool.Release(showItemFailureEventArgs); return; } throw; } }
private void OnShowItemSuccess(object sender, GameFramework.Item.ShowItemSuccessEventArgs e) { m_EventComponent.Fire(this, ShowItemSuccessEventArgs.Create(e)); }