199 lines
7.2 KiB
C#
199 lines
7.2 KiB
C#
// 文件位置: Assets/Scripts/TH1_UI/View/Announce/UIInteractionCityUpgradeItem.cs
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.Mime;
|
|
using System.Text;
|
|
using Logic.Action;
|
|
using Logic.Multilingual;
|
|
using RuntimeData;
|
|
using TH1_Logic.Action;
|
|
using TH1_Logic.Core;
|
|
using TH1_Logic.HeroTask;
|
|
using TH1_UI.HintUI;
|
|
using TH1Resource;
|
|
using TMPro;
|
|
using UI.HintUI;
|
|
using Unity.VisualScripting;
|
|
using UnityEditor.Rendering;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_UI.View.Info
|
|
{
|
|
public class UIInfoTechTreeCircleMono : MonoBehaviour
|
|
{
|
|
[Header("会响应玩家交互的模块")]
|
|
public Button ClickButton;
|
|
public HintTrigger HintTrigger;
|
|
|
|
|
|
[Header("需要每局游戏开始初始化的模块")]
|
|
public GameObject Group1;
|
|
public List<Image> Group1_Action;
|
|
public GameObject Group2;
|
|
public List<Image> Group2_Action;
|
|
public GameObject Group3;
|
|
public List<Image> Group3_Action;
|
|
public TextMeshProUGUI Title;
|
|
|
|
[Header("需要每次打开界面都刷新的模块")]
|
|
public Image BG;
|
|
public CanvasGroup BGCanvasGroup;
|
|
public Image CircleBG;
|
|
public GameObject CostBar;
|
|
public TextMeshProUGUI CostText;
|
|
public Color CostBlue;
|
|
public Color CostRed;
|
|
public Color CircleGray;
|
|
public Color CircleYellow;
|
|
|
|
public void SetContent(TechInfo techInfo,Action<TechType> techClickCallback)
|
|
{
|
|
if (techInfo == null) return;
|
|
//Step #1 根据atomList数量 确定采用哪种显示结构
|
|
List<Image> techListMono = techInfo.TechAtomList.Count switch
|
|
{
|
|
1 => Group1_Action,
|
|
2 => Group2_Action,
|
|
_ => Group3_Action,
|
|
};
|
|
Group1.SetActive(false);
|
|
Group2.SetActive(false);
|
|
Group3.SetActive(false);
|
|
switch( techInfo.TechAtomList.Count)
|
|
{
|
|
case 1 : Group1.SetActive(true); break;
|
|
case 2:Group2.SetActive(true); break;
|
|
default:Group3.SetActive(true); break;
|
|
}
|
|
|
|
//每个小图标单独设置
|
|
int rk = 0;
|
|
foreach (var atom in techInfo.TechAtomList)
|
|
{
|
|
|
|
if (techListMono.Count <= rk) break;
|
|
if(!Table.Instance.TechDataAssets.GetTechAtomInfo(atom, out var info))continue;
|
|
SetAtomContent(info,techListMono[rk]);
|
|
rk++;
|
|
}
|
|
MultilingualManager.Instance.SetUIText(Title,techInfo.TechName);
|
|
|
|
if (techClickCallback != null)
|
|
{
|
|
ClickButton.onClick.RemoveAllListeners();
|
|
ClickButton.onClick.AddListener(()=>
|
|
{
|
|
techClickCallback.Invoke(techInfo.TechType);
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void SetAtomContent(TechAtomInfo info,Image smallCircle)
|
|
{
|
|
var civEnum = Main.MapData.PlayerMap.SelfPlayerData.CivEnum;
|
|
var forceEnum = Main.MapData.PlayerMap.SelfPlayerData.ForceEnum;
|
|
if (info.UseActionSprite)
|
|
{
|
|
if (info.TechActions.Count == 0) return;
|
|
var t = info.TechActions[0];
|
|
if(Table.Instance.ActionDataAssets.GetActionInfo(t, out var actionInfo))
|
|
smallCircle.sprite = actionInfo.GetIcon(civEnum, forceEnum,GridSpType.None);
|
|
else
|
|
{
|
|
Debug.Log($"actionInfo Wrong is {t.ActionType} ");
|
|
}
|
|
}
|
|
else
|
|
smallCircle.sprite = info.IconContainer.GetIcon(civEnum,forceEnum);
|
|
|
|
IconSizingUtility.SetIconSize(smallCircle,info.iconViewSizeType);
|
|
}
|
|
|
|
public void RefreshStatus(TechInfo techInfo, bool forceLocked = false)
|
|
{
|
|
var player = Main.MapData.PlayerMap.SelfPlayerData;
|
|
|
|
//Step #1 设置costbar
|
|
CostBar.SetActive(false);
|
|
|
|
// forceLocked: 来自 Tutor 模式 PlayerOnlyShowT2AndT22Tech 限制——
|
|
// 非 t2/t22 槽位强制走灰态,已学的也要锁回灰,并禁掉点击。
|
|
if (forceLocked)
|
|
{
|
|
BG.sprite = ResourceCache.Instance.SpriteCache.CommonBG_CircleGrey;
|
|
BGCanvasGroup.alpha = 0.3f;
|
|
CircleBG.color = CircleGray;
|
|
if (ClickButton != null) ClickButton.interactable = false;
|
|
return;
|
|
}
|
|
|
|
// 解锁后恢复可交互
|
|
if (ClickButton != null) ClickButton.interactable = true;
|
|
|
|
//Step #2 先处理已经学会的
|
|
if (player.TechTree.CheckIfHasTech(techInfo.TechType))
|
|
{
|
|
BG.sprite = ResourceCache.Instance.SpriteCache.CommonBG_CircleGreen;
|
|
BGCanvasGroup.alpha = 1;
|
|
CircleBG.color = CircleYellow;
|
|
CostBar.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
//Step #3 处理当前可以学习的
|
|
bool fatherResearched = false;
|
|
foreach(var t in techInfo.FatherTechList)
|
|
if (player.TechTree.CheckIfHasTech(t))
|
|
{
|
|
fatherResearched = true;
|
|
break;
|
|
}
|
|
|
|
if (fatherResearched)
|
|
{
|
|
CostBar.SetActive(true);
|
|
var cost = player.GetTechCost(techInfo);
|
|
CostText.text = cost.ToString();
|
|
CostText.color = player.PlayerCoin + player.PlayerTechPoint < cost ? CostRed : CostBlue;
|
|
|
|
BG.sprite = ResourceCache.Instance.SpriteCache.CommonBG_CircleBlue;
|
|
BGCanvasGroup.alpha = 1;
|
|
CircleBG.color = CircleYellow;
|
|
return;
|
|
}
|
|
|
|
//Step #4 处理无法学习的情况
|
|
BG.sprite = ResourceCache.Instance.SpriteCache.CommonBG_CircleGrey;
|
|
BGCanvasGroup.alpha = 0.3f;
|
|
CircleBG.color = CircleGray;
|
|
}
|
|
|
|
public void SetContentForCheckPanel(TechAtom techAtom,bool learned = false)
|
|
{
|
|
CostBar.SetActive(false);
|
|
Group1.SetActive(true);
|
|
Group2.SetActive(false);
|
|
Group3.SetActive(false);
|
|
if (!Table.Instance.TechDataAssets.GetTechAtomInfo(techAtom, out var info)) return;
|
|
|
|
var player = Main.MapData.PlayerMap.SelfPlayerData;
|
|
Group1_Action[0].sprite = info.GetIcon(player.CivEnum, player.ForceEnum, GridSpType.None);
|
|
IconSizingUtility.SetIconSize(Group1_Action[0],info.iconViewSizeType);
|
|
BG.sprite = learned ? ResourceCache.Instance.SpriteCache.CommonBG_CircleGreen:ResourceCache.Instance.SpriteCache.CommonBG_CircleBlue;
|
|
BGCanvasGroup.alpha = 1;
|
|
CircleBG.color = CircleYellow;
|
|
MultilingualManager.Instance.SetUIText(Title,info.TechAtomName);
|
|
HintTrigger.DataProvider.HintDataType = HintDataType.TechAtomHintData;
|
|
HintTrigger.DataProvider.TechAtom = techAtom;
|
|
}
|
|
public void OnClose()
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
} |