//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, May 16, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class TaskFeedbackFuncWin : Window
|
{
|
[SerializeField] RectTransform m_Container;
|
[SerializeField] Text m_Category;
|
[SerializeField] TaskFeedbackFunc[] m_Funcs;
|
|
public static string funcTitle = string.Empty;
|
|
public static event Action<int> onSelectTask;
|
|
TaskFeedbackModel model { get { return ModelCenter.Instance.GetModel<TaskFeedbackModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
for (int i = 0; i < m_Funcs.Length; i++)
|
{
|
var index = i;
|
m_Funcs[i].button.AddListener(() =>
|
{
|
OnFunc(index);
|
});
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
Display();
|
WindowCenter.Instance.windowAfterCloseEvent += WindowAfterCloseEvent;
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
var localpos = transform.InverseTransformPoint(TaskFeedbackModel.s_ClickPosition);
|
m_Container.localPosition = m_Container.localPosition.SetY(localpos.y);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
WindowCenter.Instance.windowAfterCloseEvent -= WindowAfterCloseEvent;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
m_Category.text = funcTitle;
|
for (int i = 0; i < m_Funcs.Length; i++)
|
{
|
m_Funcs[i].button.gameObject.SetActive(i < model.taskFeedbackFuncs.Count);
|
if (i < model.taskFeedbackFuncs.Count)
|
{
|
var config = TaskFeedbackFuncConfig.Get(model.taskFeedbackFuncs[i]);
|
if (config != null)
|
{
|
m_Funcs[i].label.text = config.name;
|
}
|
}
|
}
|
}
|
|
private void OnFunc(int index)
|
{
|
CloseImmediately();
|
if (index < model.taskFeedbackFuncs.Count)
|
{
|
var config = TaskFeedbackFuncConfig.Get(model.taskFeedbackFuncs[index]);
|
if (config != null)
|
{
|
if (config.jump != 0)
|
{
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.jump);
|
}
|
else if (config.guide != 0)
|
{
|
var guideConfig = GuideConfig.Get(config.guide);
|
if (guideConfig == null)
|
{
|
DebugEx.LogFormat("引导<color=#ff0000>{0}</color>未添加", config.guide);
|
return;
|
}
|
if (config.type == 4)
|
{
|
if (onSelectTask != null)
|
{
|
onSelectTask(config.condition);
|
}
|
}
|
switch ((GuideType)guideConfig.Type)
|
{
|
case GuideType.Functional:
|
RemoveExistUnderwayGuides();
|
NewBieCenter.Instance.ResetGuide(config.guide);
|
FunctionalGuideCenter.Instance.StartGuide(config.guide);
|
break;
|
default:
|
NewBieCenter.Instance.StartNewBieGuide(config.guide);
|
break;
|
}
|
}
|
}
|
}
|
}
|
|
void RemoveExistUnderwayGuides()
|
{
|
foreach (var func in model.taskFeedbackFuncs)
|
{
|
var config = TaskFeedbackFuncConfig.Get(func);
|
if (config != null && config.guide != 0)
|
{
|
var guideConfig = GuideConfig.Get(config.guide);
|
if (guideConfig != null && guideConfig.Type == (int)GuideType.Functional)
|
{
|
if (FunctionalGuideCenter.Instance.ExistUnderwayGuide(config.guide))
|
{
|
FunctionalGuideCenter.Instance.RemoveGuide(config.guide);
|
}
|
}
|
}
|
}
|
}
|
|
private void WindowAfterCloseEvent(Window win)
|
{
|
if (win is MainInterfaceWin)
|
{
|
CloseImmediately();
|
}
|
}
|
|
[Serializable]
|
public struct TaskFeedbackFunc
|
{
|
public Button button;
|
public Text label;
|
}
|
}
|
|
}
|
|
|
|
|