2024-12-09 17:02:39 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
using UnityEngine.UIElements;
|
|
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
|
|
|
|
using PhxhSDK;
|
|
|
|
|
|
using Framework;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
|
using static UINoticeOneController;
|
|
|
|
|
|
using cfg.VihecleCultivateCfg;
|
|
|
|
|
|
using Gameplay.Net;
|
|
|
|
|
|
using Gameplay.Common;
|
2024-12-13 14:56:43 +08:00
|
|
|
|
using Gameplay;
|
2024-12-16 12:04:37 +08:00
|
|
|
|
using System.Linq;
|
2024-12-09 17:02:39 +08:00
|
|
|
|
|
|
|
|
|
|
public class UI_VehiclePartTreeController : UIWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
|
public Image Image_Bg;
|
|
|
|
|
|
public Image Image_TreeBg1;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
//public Button Button_Return;
|
2024-12-09 17:02:39 +08:00
|
|
|
|
public Button Button_back;
|
|
|
|
|
|
public TMP_Text Text_Back;
|
|
|
|
|
|
public Button Button_Home;
|
|
|
|
|
|
public Image Image_TreeBg0;
|
|
|
|
|
|
public Toggle Toggle_Dev;
|
|
|
|
|
|
public Toggle Toggle_Reinforce;
|
|
|
|
|
|
public Toggle Toggle_BlueMap;
|
|
|
|
|
|
public Toggle Toggle_Repair;
|
|
|
|
|
|
public PhxhScrollView ScrollView_PartsTree;
|
|
|
|
|
|
public Button Button_Back;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2024-12-09 17:02:39 +08:00
|
|
|
|
///Auto Gen End///
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
|
|
|
|
|
private long curVehicleID = -1;
|
|
|
|
|
|
|
|
|
|
|
|
private GameObject uiPrefab;
|
|
|
|
|
|
|
|
|
|
|
|
public async static UniTask<UIWindow> Open(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_VehiclePartTree, data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-09 17:02:39 +08:00
|
|
|
|
// deal with input data
|
|
|
|
|
|
public override void PreLoad(object data = null)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
curVehicleID = (long)data;
|
|
|
|
|
|
|
|
|
|
|
|
var path = string.Format(UIManager.UI_PREFAB_PATH, "Interface_Vehicle/TechTree/TechTree_" + curVehicleID);
|
|
|
|
|
|
PostPreload<GameObject>(path).Forget();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
|
public override void OnInit()
|
2024-12-09 17:02:39 +08:00
|
|
|
|
{
|
|
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UI_VehiclePartTreeBinder.GetComponents(this);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
var currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
|
2024-12-16 12:04:37 +08:00
|
|
|
|
currencyList.SetData(GLConfig.Inst.data.GoldItemId);//GLConfig.Inst.data.DiamondItemId,
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
|
|
|
|
|
BindButton(Button_back, OnClickBack);
|
|
|
|
|
|
BindButton(Button_Back, () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var parentID = VehicleCultivateManager.Instance.GetVehicleParent(curVehicleID).ID;
|
|
|
|
|
|
curVehicleID = parentID;
|
|
|
|
|
|
UpdateTreePrefab();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var path = string.Format(UIManager.UI_PREFAB_PATH, "Interface_Vehicle/TechTree/TechTree_" + curVehicleID);
|
|
|
|
|
|
uiPrefab = GameObject.Instantiate(GetPreLoadResult<GameObject>(path), ScrollView_PartsTree.content, false);
|
2024-12-16 12:04:37 +08:00
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.VehecleUpgrade, UpdateTreeNode);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
2024-12-09 17:02:39 +08:00
|
|
|
|
|
2024-12-16 12:04:37 +08:00
|
|
|
|
//invoke when open window
|
|
|
|
|
|
protected override void OnShowWindow(object data = null)
|
2024-12-09 17:02:39 +08:00
|
|
|
|
{
|
2024-12-12 19:11:59 +08:00
|
|
|
|
UpdateTreeNode();
|
|
|
|
|
|
var currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
|
|
|
|
|
|
currencyList.Refresh();
|
|
|
|
|
|
}
|
2024-12-09 17:02:39 +08:00
|
|
|
|
|
|
|
|
|
|
//invoke when reload window
|
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when close window
|
|
|
|
|
|
protected override void OnHideWindow()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
2024-12-13 14:56:43 +08:00
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.EN_UIControllCultivateMainInput, true);
|
|
|
|
|
|
CommonUtils.ScreenshotReset();
|
2024-12-16 12:04:37 +08:00
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.VehecleUpgrade, UpdateTreeNode);
|
2024-12-13 14:56:43 +08:00
|
|
|
|
}
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2024-12-16 13:20:15 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>νṹԤ<E1B9B9><D4A4><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
2024-12-13 14:56:43 +08:00
|
|
|
|
async void UpdateTreePrefab()
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
var path = string.Format(UIManager.UI_PREFAB_PATH, "Interface_Vehicle/TechTree/TechTree_" + curVehicleID);
|
|
|
|
|
|
var go = await AssetManager.Instance.LoadAssetAsync<GameObject>(path);
|
|
|
|
|
|
if (go == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("go is null");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (uiPrefab != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Destroy(uiPrefab);
|
|
|
|
|
|
}
|
|
|
|
|
|
uiPrefab = GameObject.Instantiate(go, ScrollView_PartsTree.content, false);
|
|
|
|
|
|
UpdateTreeNode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-16 13:20:15 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>νṹ<CEBD>ڵ<EFBFBD><DAB5><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// </summary>
|
2024-12-12 19:11:59 +08:00
|
|
|
|
void UpdateTreeNode()
|
|
|
|
|
|
{
|
|
|
|
|
|
var partTree = VehicleCultivateManager.Instance.GetPartialTree(curVehicleID);
|
|
|
|
|
|
|
|
|
|
|
|
if (VehicleCultivateManager.Instance.GetVehicleParent(curVehicleID) == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Back.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Button_Back.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (partTree == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("partTree is null");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-12-16 12:04:37 +08:00
|
|
|
|
GameObject rootVehicleNode = CommonUtils.GetGameObject(uiPrefab, "v_" + curVehicleID);
|
|
|
|
|
|
|
|
|
|
|
|
CommonUtils.GetComponent<TMP_Text>(rootVehicleNode, "Image_CurrentVehicle/Text_PartName").text
|
|
|
|
|
|
= VehicleDataHelper.GetVehicleLocalizeName((int)curVehicleID);
|
|
|
|
|
|
|
|
|
|
|
|
VehicleDevelopmentInfo data = Actor.Instance.Character.GetVehicleDevelopment(curVehicleID);
|
|
|
|
|
|
foreach (var node in partTree)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
var id = node.ID;
|
2024-12-16 12:04:37 +08:00
|
|
|
|
var treeNode = CommonUtils.GetGameObject(uiPrefab, "v_" + id);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
if (treeNode == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("treeNode is null");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
var button = treeNode.GetComponent<Button>();
|
|
|
|
|
|
if (button == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("button is null");
|
|
|
|
|
|
}
|
|
|
|
|
|
BindButton(button, () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("click node: " + id);
|
|
|
|
|
|
if (node is VehicleTreeNode Vehicle)
|
|
|
|
|
|
{
|
|
|
|
|
|
curVehicleID = Vehicle.ID;
|
|
|
|
|
|
UpdateTreePrefab();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-12-16 12:04:37 +08:00
|
|
|
|
bool unlock = false;
|
|
|
|
|
|
if (node is VehicleTreeNode vehicleNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
unlock = Actor.Instance.Character.GetVehicleDevelopment(vehicleNode.ID) != null;
|
|
|
|
|
|
|
|
|
|
|
|
#region vehicle_level
|
|
|
|
|
|
var Text_level = CommonUtils.GetComponent<TMP_Text>(treeNode.transform.GetChild(0).gameObject, "Text_Level");
|
|
|
|
|
|
if (Text_level != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var vehicleLevel = 1;
|
|
|
|
|
|
if (TableManager.Instance.Tables.VehicleConfig.DataMap.ContainsKey((int)vehicleNode.ID))
|
|
|
|
|
|
vehicleLevel = TableManager.Instance.Tables.VehicleConfig.DataMap[(int)vehicleNode.ID].VehicleLevel;
|
|
|
|
|
|
Text_level.text = CommonUtils.GetRomanCode(vehicleLevel);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (node is VehicleComponentTreeNode componentNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (data != null)
|
|
|
|
|
|
unlock = data.UpgradedComponents.Contains((uint)componentNode.ID);
|
|
|
|
|
|
|
|
|
|
|
|
#region component_level
|
|
|
|
|
|
var Text_level = CommonUtils.GetComponent<TMP_Text>(treeNode.transform.GetChild(0).gameObject, "Text_Level");
|
|
|
|
|
|
if (Text_level != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int compLevel = (int)(componentNode.ID % 100);
|
|
|
|
|
|
Text_level.text = CommonUtils.GetRomanCode(compLevel);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2024-12-16 12:04:37 +08:00
|
|
|
|
var tag = treeNode.transform.GetChild(0).Find("Image_Unlock");
|
2024-12-12 19:11:59 +08:00
|
|
|
|
if (tag == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogWarning("tag is null");
|
|
|
|
|
|
}
|
2024-12-16 12:04:37 +08:00
|
|
|
|
if (!unlock)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (tag != null)
|
|
|
|
|
|
tag.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tag != null)
|
|
|
|
|
|
tag.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnClickBack()
|
|
|
|
|
|
{
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//void OnClickHome()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.Instance.CloseAllWindow();
|
|
|
|
|
|
// UIManager.Instance.OpenWindow(UINameConst.UI_VehicleMain);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
}
|