void OnTaskChanged(TaskEventType eventType, ITask task) { TaskShortInfoWidget taskInfo; switch (eventType) { case TaskEventType.Added: taskInfo = CreateTaskWidget(_taskInfos.Count, task); _taskInfos.Add(task, taskInfo); if (_taskWidget == null) { ShowTask(taskInfo.index); } break; case TaskEventType.Changed: taskInfo = UpdateTaskWidget(task); if (_taskWidget != null && taskInfo.index == _selectedIndex) { _taskWidget.TaskUpdate(task); } break; case TaskEventType.Removed: taskInfo = RemoveTaskWidget(task); _taskInfos.Remove(task); if (taskInfo.index == _selectedIndex) { ShowTask(_selectedIndex + ((_selectedIndex > 0) ? -1 : 1)); } break; } }
void OnTaskChanged(TaskEventType eventType, ITask task) { if (task != _task) { return; } switch (eventType) { case TaskEventType.Added: ShowMenu(task); break; case TaskEventType.Changed: _taskWidget.TaskUpdate(task); break; case TaskEventType.Supended: HideMenu(); break; case TaskEventType.Removed: HideMenu(); break; } }
public void ShowTask(ITask task) { HideTask(); if (_taskInfos.TryGetValue(task, out TaskShortInfoWidget shortWidget)) { _selectedIndex = shortWidget.index; } PoolSettingsSO taskWidgetPoolSet = task.GetTaskWidgetPoolSet(); _taskWidget = taskWidgetPoolSet.GetNewObject(_taskWidgetContainer) as BasicTaskWidget; _taskWidget.TaskUpdate(task); _taskWidget.gameObject.SetActive(true); // Todo: run widget show animation }
public void ShowMenu(ITask task) { if (_taskWidget != null) { _taskWidget.ReturnToPool(); } _task = task; PoolSettingsSO taskWidgetPoolSet = task.GetTaskWidgetPoolSet(); _taskWidget = taskWidgetPoolSet.GetNewObject(_taskWidgetContainer) as BasicTaskWidget; _taskWidget.TaskUpdate(task); TaskManager.instance.OnTaskChangedSubscribe(OnTaskChanged); gameObject.SetActive(true); // Todo: run window show animation _taskWidget.gameObject.SetActive(true); // Todo: run widget show animation }