void OnStorageEventHandler(int event_id, CSEntity entity, object arg) { switch (event_id) { case CSConst.eetStorage_HistoryEnqueue: { HistoryStruct hs = arg as HistoryStruct; CSUI_SubStorageHistory ssh = _addHistoryItem(hs); if (ssh != null) { ssh.AddHistory(hs.m_Value); } } break; case CSConst.eetStorage_HistoryDequeue: { // HistoryStruct hs = arg as HistoryStruct; if (m_SubHistorys.Count != 0) { m_SubHistorys[0].PopImmediate(); if (m_SubHistorys[0].IsEmpty) { Destroy(m_SubHistorys[0].gameObject); m_SubHistorys.RemoveAt(0); } } } break; case CSConst.eetStorage_PackageRemoveItem: { StorageMainUI.RestItems(); } break; } }
private CSUI_SubStorageHistory _addHistoryItem(HistoryStruct history) { if (m_SubHistorys.Count != 0) { CSUI_SubStorageHistory curSub = m_SubHistorys[m_SubHistorys.Count - 1]; if (curSub.Day == history.m_Day) { return(curSub); } } CSUI_SubStorageHistory curSubHistory = Instantiate(m_SubHistoryPrefab) as CSUI_SubStorageHistory; curSubHistory.transform.parent = m_HistoryRootUI.transform; curSubHistory.transform.localPosition = Vector3.zero; curSubHistory.transform.localRotation = Quaternion.identity; curSubHistory.transform.localScale = Vector3.one; curSubHistory.Day = history.m_Day; curSubHistory.onReposition = OnSubHistoryReposition; m_SubHistorys.Add(curSubHistory); return(curSubHistory); }