//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, October 30, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using EnhancedUI.EnhancedScroller;
|
|
namespace vnxbqy.UI
|
{
|
|
public class FeatureNotice2Win : Window,SecondWindowInterface
|
{
|
[SerializeField] ScrollerController m_ScrollerController;
|
[SerializeField] ScaleTween m_ScaleTween;
|
FeatureNoticeModel featureNoticeModel { get { return ModelCenter.Instance.GetModel<FeatureNoticeModel>(); } }
|
public int Offset = 0;//偏移
|
private bool IsJump = false;
|
|
public Button close { get; set; }
|
#region Built-in
|
protected override void BindController()
|
{
|
if (this is SecondWindowInterface)
|
{
|
var frame = this.GetComponentInChildren<SecondFrameLoader>();
|
frame.Create();
|
close = frame.GetComponentInChildren<Button>();
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
|
close.AddListener(OnClickBtn);
|
}
|
|
protected override void OnPreOpen()
|
{
|
UnopenedFirst();
|
m_ScaleTween.SetStartState();
|
IsJump = WindowJumpMgr.Instance.IsJumpState;
|
OnCreateGridLineCell(m_ScrollerController);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
if (!IsJump)//是否经历跳转打开
|
{
|
m_ScaleTween.Play(false, IsOpen);
|
}
|
else
|
{
|
m_ScaleTween.SetEndState();
|
}
|
featureNoticeModel.UpdateAwarfItem += UpdateAwarfItem;
|
}
|
|
private void UpdateAwarfItem()
|
{
|
m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
featureNoticeModel.UpdateAwarfItem -= UpdateAwarfItem;
|
}
|
protected override void OnActived()
|
{
|
var offset = 0f;
|
m_ScrollerController.JumpIndex(JumpIndex(), ref offset);
|
m_ScrollerController.JumpIndex(Offset + offset, 0, EnhancedScroller.TweenType.immediate);
|
}
|
private void OnClickBtn()
|
{
|
if (!WindowJumpMgr.Instance.IsJumpState)//是否经历跳
|
{
|
m_ScaleTween.Play(true, IsClose);
|
}
|
else
|
{
|
Close();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
void OnCreateGridLineCell(ScrollerController gridCtrl)
|
{
|
gridCtrl.Refresh();
|
for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, featureNoticeModel.FunctionList[i].FuncId);
|
}
|
gridCtrl.Restart();
|
}
|
private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
int funcId = cell.index;
|
Transform Tran = cell.transform;
|
GameObject Tran1 = Tran.Find("FeaturesTypeOne").gameObject;
|
GameObject Tran2 = Tran.Find("FeaturesTypeTwo").gameObject;
|
var configs = FunctionForecastConfig.Get(funcId);
|
if (configs.OpenNumber == featureNoticeModel.FunctionForecastIndex)
|
{
|
|
Tran1.SetActive(false);
|
Tran2.SetActive(true);
|
FeaturesType3 featuresType3 = Tran2.GetComponent<FeaturesType3>();
|
featuresType3.GetTheFeatureID(funcId);
|
return;
|
}
|
else
|
{
|
Tran1.SetActive(true);
|
Tran2.SetActive(false);
|
FeaturesType3 featuresType3 = Tran1.GetComponent<FeaturesType3>();
|
featuresType3.GetTheFeatureID(funcId);
|
return;
|
}
|
|
}
|
|
private void IsOpen()
|
{
|
}
|
|
private void IsClose()
|
{
|
Close();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
List<FunctionForecastConfig> con_fig = new List<FunctionForecastConfig>();
|
private void UnopenedFirst() ///找到第一个不是打开状态的细胞的的openNumber
|
{
|
if (con_fig.Count <= 0)
|
{
|
con_fig = FunctionForecastConfig.GetValues();
|
}
|
// var configs = FunctionForecastConfig.GetValues();
|
foreach (var config in con_fig)
|
{
|
int openTag = config.FuncId;
|
if (!FuncOpen.Instance.IsFuncOpen(openTag))
|
{
|
featureNoticeModel.FunctionForecastIndex = config.OpenNumber;
|
return;
|
}
|
}
|
}
|
|
private int JumpIndex()//Jump选中
|
{
|
int Index = 0;
|
for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
|
{
|
int funcID = featureNoticeModel.FunctionList[i].FuncId;
|
if (featureNoticeModel.DicRedPoint.ContainsKey(funcID) && featureNoticeModel.DicRedPoint[funcID].state==RedPointState.Simple)
|
{
|
Index = i;
|
return Index;
|
}
|
}
|
Index = featureNoticeModel.FunctionList.FindIndex((x) =>
|
{
|
return x.OpenNumber == featureNoticeModel.FunctionForecastIndex;
|
});
|
if (Index == -1)
|
{
|
Index = 0;
|
}
|
return Index;
|
}
|
#endregion
|
|
}
|
|
}
|