238 lines
5.9 KiB
C#
238 lines
5.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using Animancer;
|
||
using Logic;
|
||
using Logic.Action;
|
||
using Logic.AI;
|
||
using Logic.Audio;
|
||
using Logic.Multilingual;
|
||
using ParadoxNotion;
|
||
using RuntimeData;
|
||
using Steamworks;
|
||
using TH1_Core.Events;
|
||
using TH1_Core.Managers;
|
||
using TH1_Logic.Action;
|
||
using TH1_Logic.Config;
|
||
using TH1_Logic.Core;
|
||
using TH1_Logic.Net;
|
||
using TH1_Logic.Steam;
|
||
using TH1_UI.View.Announce;
|
||
using TH1Resource;
|
||
using TMPro;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
using UnityEngine.Serialization;
|
||
using UnityEngine.UI;
|
||
|
||
namespace TH1_UI.View.Outside
|
||
{
|
||
|
||
|
||
|
||
public enum LibrarySheetType
|
||
{
|
||
Hero,
|
||
Wonder
|
||
}
|
||
public class UIOutsideLibraryView : Base.View
|
||
{
|
||
[Header("按钮")]
|
||
//public Button CloseButton;
|
||
public Button CloseButton;
|
||
|
||
public UIOutsideSelectOptionGroupMono MenuBar;
|
||
public Button HeroListButton;
|
||
public Button WonderListButton;
|
||
|
||
public Transform HeroList;
|
||
public Transform WonderList;
|
||
public Transform HeroListContent;
|
||
public Transform WonderListContent;
|
||
private List<UIOutsideLibraryGridItemMono> _heroMonoList;
|
||
private List<UIOutsideLibraryGridItemMono> _wonderMonoList;
|
||
|
||
|
||
public UIOutsideLibraryHeroPanelMono HeroPanel;
|
||
|
||
public TextMeshProUGUI AllStarText;
|
||
|
||
public GameObject GridItemPrefab;
|
||
|
||
|
||
//所有参与图鉴的herolist
|
||
private readonly List<GiantType> _heroTypeList = new List<GiantType>
|
||
{
|
||
GiantType.EgyptianRemilia,GiantType.EgyptianPatchouli,GiantType.EgyptianSakuya,GiantType.EgyptianFlandre,GiantType.EgyptianMeiling,
|
||
GiantType.FrenchKaguya,GiantType.FrenchEirin,GiantType.FrenchTewi,GiantType.FrenchReisen,GiantType.FrenchMokou,
|
||
GiantType.GermanyKanako,GiantType.GermanySuwako,GiantType.GermanySanae,GiantType.GermanyAya,GiantType.GermanyMomiji
|
||
};
|
||
|
||
//所有参与图鉴的civlist
|
||
private readonly List<Empire> _empireList = new List<Empire>
|
||
{
|
||
new Empire(CivEnum.Egyptian,ForceEnum.Remilia), new Empire(CivEnum.French,ForceEnum.Kaguya),new Empire(CivEnum.Germany,ForceEnum.Kanako)
|
||
};
|
||
|
||
|
||
//关闭时执行的委托
|
||
public ViDelegateAssisstant.Dele OnBtnCloseClick;
|
||
|
||
protected override void OnInit()
|
||
{
|
||
base.OnInit();
|
||
CloseButton.onClick.RemoveAllListeners();
|
||
CloseButton.onClick.AddListener(OnClose);
|
||
_heroMonoList = new List<UIOutsideLibraryGridItemMono>();
|
||
_wonderMonoList = new List<UIOutsideLibraryGridItemMono>();
|
||
}
|
||
|
||
|
||
|
||
private void SetAllWonderStars()
|
||
{
|
||
int sum = _empireList.Count * 7 * 3;
|
||
int now = 0;
|
||
for(int i = 0;i < _empireList.Count; i++)
|
||
foreach (WonderTypeEnum wonderType in Enum.GetValues(typeof(WonderTypeEnum)))
|
||
if(wonderType != WonderTypeEnum.None)
|
||
for (uint k = 1; k <= 3; k++)
|
||
if(AchievementDataManager.Instance.IsFinished(2, (uint)wonderType, k)) now++;
|
||
AllStarText.text = now + " / " + sum;
|
||
}
|
||
|
||
private void SetAllHeroStars()
|
||
{
|
||
int sum = _heroTypeList.Count * 3;
|
||
int now = 0;
|
||
for(int i = 0;i < _heroTypeList.Count; i++)
|
||
if(AchievementDataManager.Instance.GetSmallIdByGiantType(_heroTypeList[i], out var smallid))
|
||
for (uint k = 1; k <= 3; k++)
|
||
if(AchievementDataManager.Instance.IsFinished(2, smallid, k)) now++;
|
||
AllStarText.text = now + " / " + sum;
|
||
}
|
||
|
||
private void InitHeroList()
|
||
{
|
||
//Step #1 判断容器是否够
|
||
int heroSum = _heroTypeList.Count;
|
||
while (_heroMonoList.Count < heroSum)
|
||
{
|
||
var obj = Instantiate(GridItemPrefab, HeroListContent);
|
||
var mono = obj.GetComponent<UIOutsideLibraryGridItemMono>();
|
||
_heroMonoList.Add(mono);
|
||
}
|
||
|
||
//Step #2 设置每个mono的内容
|
||
for (int i = 0; i < _heroMonoList.Count; i++)
|
||
{
|
||
_heroMonoList[i].gameObject.SetActive(i < heroSum);
|
||
if (i >= heroSum) break;
|
||
_heroMonoList[i].SetHeroContent(_heroTypeList[i],OnClickHeroItem);
|
||
}
|
||
}
|
||
|
||
private void OnClickHeroItem(GiantType giantType)
|
||
{
|
||
HeroPanel.SetContent(giantType);
|
||
HeroPanel.Show();
|
||
}
|
||
|
||
private void InitWonderList()
|
||
{
|
||
//Step #1 判断容器是否够
|
||
int wonderSum = _empireList.Count * 7 ;
|
||
while (_wonderMonoList.Count < wonderSum)
|
||
{
|
||
var obj = Instantiate(GridItemPrefab, WonderListContent);
|
||
var mono = obj.GetComponent<UIOutsideLibraryGridItemMono>();
|
||
_wonderMonoList.Add(mono);
|
||
}
|
||
|
||
//Step #2 设置每个mono的内容
|
||
for (int i = 0; i < _wonderMonoList.Count; i++)
|
||
{
|
||
_wonderMonoList[i].gameObject.SetActive(i < wonderSum);
|
||
int empireIdx = i / 7;
|
||
int wonderIdx = i % 7 + 1;
|
||
if (i >= wonderSum) break;
|
||
_wonderMonoList[i].SetWonderContent(_empireList[empireIdx], (WonderTypeEnum)wonderIdx);
|
||
}
|
||
}
|
||
|
||
private void InitMenuBar()
|
||
{
|
||
HeroListButton.onClick.RemoveAllListeners();
|
||
HeroListButton.onClick.AddListener(() =>
|
||
{
|
||
MenuBar.Select(0);
|
||
ShowList(LibrarySheetType.Hero);
|
||
});
|
||
WonderListButton.onClick.RemoveAllListeners();
|
||
WonderListButton.onClick.AddListener(() =>
|
||
{
|
||
MenuBar.Select(1);
|
||
ShowList(LibrarySheetType.Wonder);
|
||
});
|
||
}
|
||
|
||
private void SetMenuBar(LibrarySheetType sheetType)
|
||
{
|
||
MenuBar.Select(sheetType == LibrarySheetType.Hero? (uint)0 : 1);
|
||
}
|
||
|
||
|
||
private void ShowList(LibrarySheetType sheetType)
|
||
{
|
||
WonderList.gameObject.SetActive(false);
|
||
HeroList.gameObject.SetActive(false);
|
||
|
||
if (sheetType == LibrarySheetType.Hero)
|
||
{
|
||
SetAllHeroStars();
|
||
HeroList.gameObject.SetActive(true);
|
||
}
|
||
|
||
else if (sheetType == LibrarySheetType.Wonder)
|
||
{
|
||
SetAllWonderStars();
|
||
WonderList.gameObject.SetActive(true);
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
public void SetContent(ShowUIOutsideLibrary evt)
|
||
{
|
||
InitMenuBar();
|
||
InitHeroList();
|
||
InitWonderList();
|
||
SetMenuBar(LibrarySheetType.Hero);
|
||
ShowList(LibrarySheetType.Hero);
|
||
|
||
|
||
}
|
||
|
||
//在Controller 调用Close的时候,会先调用这个closeview
|
||
public void OnCloseView()
|
||
{
|
||
}
|
||
|
||
public void OnSettingClicked()
|
||
{
|
||
}
|
||
|
||
public void OnStartClicked()
|
||
{
|
||
EventManager.Publish(new ShowUIOutsideSelect());
|
||
}
|
||
|
||
|
||
public void OnClose()
|
||
{
|
||
OnBtnCloseClick.Invoke();
|
||
}
|
||
}
|
||
|
||
}
|