| | |
| | | using TableConfig; |
| | | using EnhancedUI.EnhancedScroller; |
| | | |
| | | namespace Snxxz.UI { |
| | | namespace Snxxz.UI
|
| | | { |
| | | |
| | | public class SpringFestivalWin : Window |
| | | {
|
| | |
| | | [SerializeField] GameObject m_One;
|
| | | [SerializeField] GameObject m_Two;
|
| | |
|
| | | [SerializeField] OpenServiceItem m_OpenServiceItemA;
|
| | | [SerializeField] OpenServiceItem m_OpenServiceItemA1;
|
| | | [SerializeField] OpenServiceItem m_OpenServiceItemB1;
|
| | | [SerializeField] SpringFestivalItem m_SpringFestivalItemA;
|
| | | [SerializeField] SpringFestivalItem m_SpringFestivalItemA1;
|
| | | [SerializeField] SpringFestivalItem m_SpringFestivalItemB1;
|
| | | DailyQuestModel dailymodel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
| | | List<int> SortList = new List<int>(); |
| | | OpenServiceAchievementModel OpenServicemodel { get { return ModelCenter.Instance.GetModel<OpenServiceAchievementModel>(); } }
|
| | | SpringFestivalModel model { get { return ModelCenter.Instance.GetModel<SpringFestivalModel>(); } }
|
| | | List<int> SortList = new List<int>();
|
| | | List<WeekPartyItemClass> ItemDayList = new List<WeekPartyItemClass>(); |
| | | protected override void BindController() |
| | | {
|
| | | //m_ScrollerController1.OnRefreshCell += OnRefreshGridCell_1; |
| | | //m_ScrollerController2.OnRefreshCell += OnRefreshGridCell_2; |
| | | m_ScrollerController1.OnRefreshCell += OnRefreshGridCell_1; |
| | | m_ScrollerController2.OnRefreshCell += OnRefreshGridCell_2; |
| | | } |
| | | |
| | | protected override void AddListeners() |
| | |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | {
|
| | | ChooseDay();
|
| | | SetTextIntegral();
|
| | | OnCreateGridLineCell1(m_ScrollerController1);
|
| | | OnCreateGridLineCell2(m_ScrollerController2); |
| | | if (model.SelectedNow >= 5)
|
| | | {
|
| | | m_ScrollerController1.JumpIndex(5);
|
| | | } |
| | | } |
| | | |
| | | protected override void OnAfterOpen() |
| | | { |
| | | model.SpringFestivalRewardUpdate += SpringFestivalRewardUpdate; |
| | | } |
| | | |
| | | protected override void OnPreClose() |
| | | { |
| | | } |
| | | |
| | | {
|
| | | model.SpringFestivalRewardUpdate -= SpringFestivalRewardUpdate; |
| | | }
|
| | |
|
| | |
|
| | | protected override void OnAfterClose() |
| | | { |
| | | } |
| | | }
|
| | | #endregion |
| | | |
| | | private void SpringFestivalRewardUpdate()
|
| | | {
|
| | | GetPointRewardObj();//获取积分领奖信息
|
| | | m_ScrollerController1.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | m_ScrollerController2.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | }
|
| | | |
| | | void OnCreateGridLineCell1(ScrollerController gridCtrl)
|
| | | {
|
| | | gridCtrl.Refresh();
|
| | | foreach (var key in model.SpringFestivalDayDic.Keys)
|
| | | {
|
| | | gridCtrl.AddCell(ScrollerDataType.Header, key);
|
| | | }
|
| | | gridCtrl.Restart();
|
| | | } |
| | | private void OnRefreshGridCell_1(ScrollerDataType type, CellView cell)
|
| | | {
|
| | | int Index = cell.index;
|
| | | ButtonEx Btn = cell.GetComponent<ButtonEx>();
|
| | | GameObject SelectedObj = cell.transform.Find("Image_XZ").gameObject;//选中
|
| | | GameObject SelectedObj1 = cell.transform.Find("Image_XZ1").gameObject;//选中
|
| | | ImageEx SelectedImageEx = SelectedObj.GetComponent<ImageEx>();
|
| | |
|
| | |
|
| | | GameObject Unselected = cell.transform.Find("Image_WXZ").gameObject;//未选中
|
| | | ImageEx UnselectedIm = Unselected.GetComponent<ImageEx>();
|
| | | GameObject Lock = cell.transform.Find("Lock").gameObject;//锁
|
| | |
|
| | | GameObject IsNotGary = cell.transform.Find("Obj1").gameObject;
|
| | | Text IsNotGary_text = IsNotGary.transform.Find("DayText").GetComponent<Text>();
|
| | | GameObject Gary = cell.transform.Find("Obj2").gameObject;
|
| | | Text Gary_text = Gary.transform.Find("DayText").GetComponent<Text>();
|
| | |
|
| | | RedpointBehaviour redPoint = cell.transform.Find("RedPoint").GetComponent<RedpointBehaviour>();//红点
|
| | | if (model.RedPointDic.ContainsKey(Index))
|
| | | {
|
| | | redPoint.redpointId = model.RedPointDic[Index].id;
|
| | | }
|
| | | if (Index <= model.DayNow)
|
| | | {
|
| | | SelectedImageEx.gray = false;
|
| | | Unselected.SetActive(true);
|
| | | UnselectedIm.gray = false;
|
| | | SelectedObj.SetActive(false);
|
| | | SelectedObj1.SetActive(false);
|
| | | Lock.SetActive(false);
|
| | | IsNotGary.SetActive(true);
|
| | | Gary.SetActive(false);
|
| | | IsNotGary_text.text = (Index + 1).ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | Unselected.SetActive(true);
|
| | | UnselectedIm.gray = true;
|
| | | SelectedObj.SetActive(false);
|
| | | SelectedObj1.SetActive(false);
|
| | | Lock.SetActive(true);
|
| | | IsNotGary.SetActive(false);
|
| | | Gary.SetActive(true);
|
| | | Gary_text.text = (Index + 1).ToString();
|
| | | }
|
| | |
|
| | | if (Index == model.SelectedNow)
|
| | | {
|
| | | if (Index > model.DayNow)
|
| | | {
|
| | | SelectedImageEx.gray = true;
|
| | | IsNotGary.SetActive(false);
|
| | | Gary.SetActive(true);
|
| | | Lock.SetActive(true);
|
| | | }
|
| | | else
|
| | | {
|
| | | SelectedImageEx.gray = false;
|
| | | IsNotGary.SetActive(true);
|
| | | Gary.SetActive(false);
|
| | | Lock.SetActive(false);
|
| | | }
|
| | | SelectedObj.SetActive(true);
|
| | | SelectedObj1.SetActive(true);
|
| | | Unselected.SetActive(false);
|
| | |
|
| | | IsNotGary_text.text = (Index + 1).ToString();
|
| | | }
|
| | | Btn.SetListener(() =>
|
| | | {
|
| | | if (Index != model.SelectedNow)
|
| | | {
|
| | | model.SelectedNow = Index;//选中天
|
| | | SetTextIntegral();
|
| | | OnCreateGridLineCell2(m_ScrollerController2);
|
| | | m_ScrollerController1.m_Scorller.RefreshActiveCellViews();//刷新可见
|
| | | }
|
| | | });
|
| | |
|
| | | } |
| | | private string InDayStr(int Day)
|
| | | {
|
| | | string DaySte = string.Empty;
|
| | | DaySte = Language.Get("SignIn_4", Day);
|
| | | return DaySte;
|
| | | }
|
| | | void OnCreateGridLineCell2(ScrollerController gridCtrl)
|
| | | {
|
| | | ToAddSorting();//排序
|
| | | GetPointRewardObj();//获取积分领奖信息
|
| | | gridCtrl.Refresh();
|
| | | for (int i = 0; i < SortList.Count; i++)
|
| | | {
|
| | | gridCtrl.AddCell(ScrollerDataType.Header, SortList[i]);
|
| | | }
|
| | | gridCtrl.Restart();
|
| | | }
|
| | | private void OnRefreshGridCell_2(ScrollerDataType type, CellView cell)
|
| | | {
|
| | |
|
| | | }
|
| | | private void ToAddSorting()
|
| | | {
|
| | | SortList.Clear();
|
| | | int Weekday = OpenServicemodel.GetWeekDay(model.SelectedNow);
|
| | | var quests = dailymodel.GetQuestByWeekTime(Weekday);
|
| | | List<int> dailyIdlist = new List<int>();
|
| | | foreach (var key in quests.Keys)
|
| | | {
|
| | | var _list = quests[key];
|
| | | for (int i = 0; i < _list.Count; i++)
|
| | | {
|
| | | dailyIdlist.Add(_list[i]);
|
| | | }
|
| | | }
|
| | |
|
| | | foreach (var key in model.SpringFestivalDayDic.Keys)
|
| | | {
|
| | | if (key == model.SelectedNow)
|
| | | {
|
| | | for (int i = 0; i < model.SpringFestivalDayDic[key].TemplateList.Length; i++)
|
| | | {
|
| | | var TemplateId = model.SpringFestivalDayDic[key].TemplateList[i];
|
| | | var config = Config.Instance.Get<WeekPartyConfig>(TemplateId);
|
| | | if (config == null)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (config.DailyQusetId != 0)
|
| | | {
|
| | | if (dailyIdlist.Contains(config.DailyQusetId))
|
| | | {
|
| | | SortList.Add(TemplateId);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | SortList.Add(TemplateId);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | SortList.Sort(Compare);
|
| | | }
|
| | | int Compare(int x, int y)//数组排列
|
| | | {
|
| | | bool havex1 = IsReceive(x);
|
| | | bool havey1 = IsReceive(y);
|
| | | if (havex1.CompareTo(havey1) != 0)
|
| | | {
|
| | | return -havex1.CompareTo(havey1);
|
| | | }
|
| | | bool havex2 = Undone(x);
|
| | | bool havey2 = Undone(y);
|
| | | if (havex2.CompareTo(havey2) != 0)
|
| | | {
|
| | | return -havex2.CompareTo(havey2);
|
| | | }
|
| | | bool havex3 = Completed(x);
|
| | | bool havey3 = Completed(y);
|
| | | if (havex3.CompareTo(havey3) != 0)
|
| | | {
|
| | | return -havex3.CompareTo(havey3);
|
| | | }
|
| | | int havex4 = SizeId(x);
|
| | | int havey4 = SizeId(y);
|
| | | if (havex4.CompareTo(havey4) != 0)
|
| | | {
|
| | | return havex4.CompareTo(havey4);
|
| | | }
|
| | | return 1;
|
| | | }
|
| | | private bool IsReceive(int ID)//可领取
|
| | | {
|
| | | bool Bool = false;
|
| | | if (model.SpringFestivalDic.ContainsKey(ID))
|
| | | {
|
| | | var SpringFestival = model.SpringFestivalDic[ID];
|
| | | int number = SpringFestival.TotalTimes / SpringFestival.SingleTimes;
|
| | | int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//已领奖次数
|
| | | int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//已完成次数
|
| | | int TaypeNumber = 0;
|
| | | if (carryOutNum - rewardNum > 0)
|
| | | {
|
| | | TaypeNumber = (carryOutNum - rewardNum) / SpringFestival.SingleTimes;
|
| | | }
|
| | | if (TaypeNumber > 0)
|
| | | {
|
| | | Bool = true;
|
| | | }
|
| | | }
|
| | | return Bool;
|
| | | }
|
| | | private bool Undone(int ID)//未完成
|
| | | {
|
| | | bool Bool = false;
|
| | | if (model.SpringFestivalDic.ContainsKey(ID))
|
| | | {
|
| | | var SpringFestival = model.SpringFestivalDic[ID];
|
| | | int number = SpringFestival.TotalTimes / SpringFestival.SingleTimes;
|
| | | int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//已领奖次数
|
| | | int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//已完成次数
|
| | | if (SpringFestival.TotalTimes > rewardNum)
|
| | | {
|
| | | Bool = true;
|
| | | }
|
| | | }
|
| | | return Bool;
|
| | | }
|
| | | private bool Completed(int ID)//已领取
|
| | | {
|
| | | bool Bool = false;
|
| | | if (model.SpringFestivalDic.ContainsKey(ID))
|
| | | {
|
| | | var SpringFestival = model.SpringFestivalDic[ID];
|
| | | int rewardNum = model.GetRewardNumber(model.SelectedNow, ID);//已领奖次数
|
| | | int carryOutNum = model.GetCarryOutNum(model.SelectedNow, ID);//已完成次数
|
| | | if (rewardNum >= SpringFestival.TotalTimes)
|
| | | {
|
| | | Bool = true;
|
| | | }
|
| | | }
|
| | | return Bool;
|
| | | }
|
| | | private int SizeId(int ID)
|
| | | {
|
| | | int index = 1;
|
| | | var config = Config.Instance.Get<WeekPartyConfig>(ID);
|
| | | if (config != null)
|
| | | {
|
| | | index = config.order;
|
| | | }
|
| | | return index;
|
| | | }
|
| | | private void SetTextIntegral()//获取当前积分
|
| | | {
|
| | | int Point = model.GetPoint(model.SelectedNow);
|
| | | m_TextIntegral.text = Point.ToString();
|
| | | }
|
| | | private void GetPointRewardObj()
|
| | | {
|
| | | ItemDayList.Clear();
|
| | | foreach (var key in model.SpringFestivalDayDic.Keys)
|
| | | {
|
| | | if (key == model.SelectedNow)
|
| | | {
|
| | | for (int i = 0; i < model.SpringFestivalDayDic[key].WeekPartyItem.Length; i++)
|
| | | {
|
| | | ItemDayList.Add(model.SpringFestivalDayDic[key].WeekPartyItem[i]);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (ItemDayList.Count > 1)
|
| | | {
|
| | | m_One.SetActive(false);
|
| | | m_Two.SetActive(true);
|
| | | m_SpringFestivalItemA1.SetReward(model.SelectedNow, ItemDayList[0], 0, 2);
|
| | | m_SpringFestivalItemB1.SetReward(model.SelectedNow, ItemDayList[1], 1, 2);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_One.SetActive(true);
|
| | | m_Two.SetActive(false);
|
| | | m_SpringFestivalItemA.SetReward(model.SelectedNow, ItemDayList[0], 0, 1);
|
| | | }
|
| | | }
|
| | | private void ChooseDay()//选择天
|
| | | {
|
| | | foreach (var key in model.RedPointDic.Keys)//红点选择可领取的天
|
| | | {
|
| | | if (model.RedPointDic[key].state == RedPointState.GetReward)
|
| | | {
|
| | | model.SelectedNow = key;
|
| | | return;
|
| | | }
|
| | | }
|
| | | model.SelectedNow = model.DayNow;
|
| | | } |
| | | } |
| | | |
| | | } |