private int GetActivityByType(int type) { System.DateTime nowTime = System.DateTime.Now; int time = nowTime.Hour * 100 + nowTime.Minute; //ArrayList skeys = new ArrayList(DataManager.ActivityTable.Keys); ArrayList skeys = DataManager.ActivityTable.GetKeys(); skeys.Sort(); int result = -1; for (int i = 0; i < skeys.Count; ++i) { ActivityTableItem item = DataManager.ActivityTable[skeys[i]] as ActivityTableItem; if (item == null) { continue; } if (item.type != type) { continue; } if (result < 0) { result = item.id; } if (time > item.overtime) { continue; } return(item.id); } // // foreach (int key in skeys) // { // // } return(result); }
private void RefreshUI() { PlayerDataModule ply = ModuleManager.Instance.FindModule <PlayerDataModule>(); if (ply == null) { return; } IDictionaryEnumerator itr = DataManager.ActivityTypeTable.GetEnumerator(); while (itr.MoveNext()) { ActivityTypeTableItem item = itr.Value as ActivityTypeTableItem; if (item == null) { continue; } int resId = GetActivityByType((int)item.type); if (resId < 0) { continue; } ActivityTableItem activityItem = DataManager.ActivityTable[resId] as ActivityTableItem; ActivityItem activity = null; foreach (ActivityItem temp in mActivityItemList) { if (temp.GetType() == (int)item.type) { activity = temp; } } if (activity == null) { GameObject gameObj = WindowManager.Instance.CloneGameObject(mActivityItemUnit); if (gameObj == null) { GameDebug.LogError("instance activityitem error"); return; } gameObj.SetActive(true); gameObj.transform.parent = mGrid.gameObject.transform; gameObj.transform.localScale = Vector3.one; mGrid.Reposition(); if (0 == item.isopen) { activity = new ActivityItem(gameObj); activity.updatezeroInfo((int)item.type, resId, item.name, item.scnenbg); activity.onOkClick = OnJoinActivity; activity.onXiangQingClick = OnActivityXiangQing; } else if (1 == item.isopen) { activity = new ActivityItem(gameObj); activity.UpdateInfo((int)item.type, resId, item.name, item.needlevel, ply.GetLevel(), (int)activityItem.starttime, (int)activityItem.overtime, item.max_time - ply.GetActivityTypeCompleteTime(activityItem.type), ply.IsActivityCompleted(resId), item.award_desc, item.scnenbg); activity.onOkClick = OnJoinActivity; activity.onXiangQingClick = OnActivityXiangQing; } mActivityItemList.Add(activity); } else { if (0 == item.isopen) { activity.updatezeroInfo((int)item.type, resId, item.name, item.scnenbg); } else if (1 == item.isopen) { activity.UpdateInfo((int)item.type, resId, item.name, item.needlevel, ply.GetLevel(), (int)activityItem.starttime, (int)activityItem.overtime, item.max_time - ply.GetActivityTypeCompleteTime(activityItem.type), ply.IsActivityCompleted(resId), item.award_desc, item.scnenbg); } } } // foreach (DictionaryEntry de in DataManager.ActivityTypeTable) // { // // } mGrid.repositionNow = true; }