NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_VehicleCultivateProContr...

635 lines
22 KiB
C#
Raw Normal View History

2024-12-26 14:53:11 +08:00
using cfg.SkillCfg;
using cfg.VihecleCultivateCfg;
2024-12-11 11:16:11 +08:00
using Cysharp.Threading.Tasks;
2024-12-26 14:53:11 +08:00
using DG.Tweening;
using Framework;
2024-12-11 11:16:11 +08:00
using Gameplay;
using Gameplay.Common;
2024-12-12 19:11:59 +08:00
using Gameplay.Net;
using Gameplay.Utils;
2024-12-26 14:53:11 +08:00
using PhxhSDK;
2024-12-12 19:11:59 +08:00
using System;
2024-12-26 14:53:11 +08:00
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
2024-12-09 17:02:39 +08:00
public class UI_VehicleCultivateProController : UIWindow
{
2024-12-11 11:16:11 +08:00
#region UI Bind
//UI GameObj
///Auto Gen Start///
//public Button Button_Back;
public Button Button_back;
2024-12-25 12:40:51 +08:00
public TMP_Text Text_Back;
public Button Button_Home;
public Image Image_DarkLeft;
public Image Image_DarkLeftTop;
public Image Image_DarkTop;
public Image Image_DarkBottom;
public Image Image_OrganizatioFlag;
public Image Image_AngularShape0;
public TMP_Text Text_VehicleType;
public Image Image_AngularShape1;
public TMP_Text Text_Level;
public Image Image_AngularShape2;
public TMP_Text Text_Organization;
public TMP_Text Text_VehicleName;
public Button Button_Look;
public Image Image_Attributes;
public TMP_Text Text_TitleAttri;
public TMP_Text Text_EnAttri;
public Image Image_Hp;
public TMP_Text Text_HpTitle;
public TMP_Text Text_HpValue;
public Image Image_Def;
public TMP_Text Text_DefTitle;
public TMP_Text Text_DefValue;
public Image Image_BulletCount;
public TMP_Text Text_BulletCountTitle;
public TMP_Text Text_BulletCountValue;
public Image Image_MemberCount;
public TMP_Text Text_MemberCountTitle;
public TMP_Text Text_MemberCountValue;
public Image Image_Atk;
public TMP_Text Text_AtkTitle;
public TMP_Text Text_AtkValue;
public Image Image_Speed;
public TMP_Text Text_SpeedTitle;
public TMP_Text Text_SpeedValue;
public Image Image_Terrain;
public TMP_Text Text_TitleTerrain;
public TMP_Text Text_EnTerrain;
public Image Image_Ground;
public TMP_Text Text_GroundTitle;
public TMP_Text Text_GroundAdapt;
public Image Image_Snow;
public TMP_Text Text_SnowTitle;
public TMP_Text Text_SnowAdapt;
public Image Image_Mountain;
public TMP_Text Text_MountainTitle;
public TMP_Text Text_MountainAdapt;
public Image Image_Wood;
public TMP_Text Text_WoodTitle;
public TMP_Text Text_WoodAdapt;
public Button Button_Dev;
public Button Button_Paint;
public Image Image_VehicleSkill;
public TMP_Text Text_TitleSkill;
public TMP_Text Text_SkillName;
public Image Image_SkillIcon;
public Image Image_SkillCoolingTimeBg;
public TMP_Text Text_SkillCoolingTimeValue;
public TMP_Text Text_ClassTitle;
public TMP_Text Text_SkillLevel;
public TMP_Text Text_SkillInfo;
public Button Button_TechTree;
public PhxhScrollView ScrollView_VehicleList;
2024-12-11 11:16:11 +08:00
2024-12-12 19:11:59 +08:00
///Auto Gen End///
#endregion
private long m_selectedVehicleID = 0;
private long SelectedVehicleID
{
get
{
return m_selectedVehicleID;
}
set
{
m_selectedVehicleID = value;
DebugUtil.Log("SelectedVehicleID: " + m_selectedVehicleID.ToString());
}
}
2024-12-11 11:16:11 +08:00
2024-12-18 19:58:14 +08:00
private bool m_isVehicleUIShow = false;
2024-12-19 16:52:49 +08:00
private int AudioID = -1;
2024-12-12 19:11:59 +08:00
2024-12-25 12:40:51 +08:00
private List<VehicleCultivateData> m_unlockedVehicles = new();
2024-12-11 11:16:11 +08:00
public async static UniTask<UIWindow> Open()
2024-12-12 19:11:59 +08:00
{
2024-12-11 11:16:11 +08:00
UIWindow uiWindow = await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_VehicleCultivatePro);
CommonUtils.ChangeUIScene(Framework.Constants.UI_VEHICLE_CHOOSE_SCENE_PATH);
2024-12-12 19:11:59 +08:00
var wind = uiWindow as UI_VehicleCultivateProController;
wind.BindScene();
2024-12-11 11:16:11 +08:00
2024-12-12 19:11:59 +08:00
CameraManager.Instance.SetMainCameraActive(true);
2024-12-11 11:16:11 +08:00
return uiWindow;
}
2024-12-25 12:40:51 +08:00
// deal with input data
public override void PreLoad(object data = null)
2024-12-09 17:02:39 +08:00
{
2024-12-25 12:40:51 +08:00
2024-12-09 17:02:39 +08:00
}
2024-12-25 12:40:51 +08:00
// Use this for initialization
public override void OnInit()
{
//bind UI GameObj
UI_VehicleCultivateProBinder.GetComponents(this);
2024-12-11 11:16:11 +08:00
2024-12-19 16:52:49 +08:00
m_isVehicleUIShow = true;
2024-12-11 11:16:11 +08:00
var currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
2024-12-18 14:39:01 +08:00
currencyList.SetData();//GLConfig.Inst.data.DiamondItemId, GLConfig.Inst.data.GoldItemId
2024-12-11 11:16:11 +08:00
BindButton(Button_TechTree, OnButton_TreeClick);
2024-12-25 12:40:51 +08:00
BindButton(Button_Dev, OnButton_DevClick);
2024-12-13 14:56:43 +08:00
BindButton(Button_Paint, OnButton_PaintClick);
2024-12-25 12:40:51 +08:00
BindButton(Button_back, OnButton_backClick);
BindButton(Button_Home, OnButton_HomeClick);
BindButton(Button_Look, () => { HideUI(false); });
2024-12-09 17:02:39 +08:00
2024-12-25 12:40:51 +08:00
LoadVehicleList();
if (m_unlockedVehicles.Count > 0)
2024-12-12 19:11:59 +08:00
{
SelectedVehicleID = m_unlockedVehicles[0].Cfg.ID;
}
2024-12-25 12:40:51 +08:00
else
{
DebugUtil.LogWarning("None Vehicle");
2024-12-12 19:57:07 +08:00
FindObj("UI_LiuHaiLeft/Attributes").gameObject.SetActive(false);
FindObj("UI_LiuHaiLeft/Terrain").gameObject.SetActive(false);
Button_Dev.gameObject.SetActive(false);
Button_Paint.gameObject.SetActive(false);
Image_VehicleSkill.gameObject.SetActive(false);
2024-12-25 12:40:51 +08:00
}
2024-12-12 19:11:59 +08:00
VehicleInfoRefresh();
ScrollView_VehicleList.SetItemCountFunc(() => m_unlockedVehicles.Count);
2024-12-25 12:40:51 +08:00
ScrollView_VehicleList.SetItemSizeFunc((index) => new Vector2(264, 96));
ScrollView_VehicleList.SetUpdateFunc(UpdateScrollViewItem);
2024-12-12 19:11:59 +08:00
ScrollView_VehicleList.UpdateData();
2024-12-19 16:52:49 +08:00
AudioManager.Instance.StopAllMusic();
AudioID = AudioManager.Instance.PlayAudio(Framework.Constants.Sound.TEAM_VEHICLE, AudioCriManager.EPlayType.Sound, null, loop: true, isFade: true);
2024-12-12 19:11:59 +08:00
EventManager.Instance.Register(EventManager.EventName.EN_UIControllCultivateMainInput, (Action<bool>)ControllInput);
EventManager.Instance.Register(EventManager.EventName.VehecleUpgrade, OnVehicleInfoUpdate);
2024-12-12 19:11:59 +08:00
}
//invoke when open window
protected override void OnShowWindow(object data = null)
2024-12-25 12:40:51 +08:00
{
2024-12-11 11:16:11 +08:00
var currencyList = GetComponent<UI_CurrencyList>("UI_CurrencyList");
currencyList.Refresh();
2024-12-12 19:11:59 +08:00
ControllInput(true);
2024-12-26 14:53:11 +08:00
if (_rotateTrans != null)
{
_rotateTrans.transform.DOKill();
_rotateTrans.transform.position = new Vector3(56, 0, 19);
_rotateTrans.transform.rotation = Quaternion.Euler(0, 0, 0);
}
2024-12-11 11:16:11 +08:00
}
2024-12-25 12:40:51 +08:00
//invoke when reload window
protected override void OnReloadWindow(object data = null)
{
}
//invoke when close window
protected override void OnHideWindow()
{
2024-12-12 19:11:59 +08:00
ControllInput(false);
}
2024-12-25 12:40:51 +08:00
//invoke when destroy
public override void OnRelease()
{
base.OnRelease();
2024-12-19 16:52:49 +08:00
AudioManager.Instance.StopSoundById(AudioID);
2024-12-12 19:11:59 +08:00
EventManager.Instance.Unregister(EventManager.EventName.EN_UIControllCultivateMainInput, (Action<bool>)ControllInput);
EventManager.Instance.Unregister(EventManager.EventName.VehecleUpgrade, OnVehicleInfoUpdate);
2024-12-12 19:11:59 +08:00
}
GameObject vRoot = null;//<2F>ؾ߸<D8BE><DFB8>ڵ<EFBFBD>
Transform _rotateTrans;//<2F><>ת<EFBFBD><D7AA>ͷ<EFBFBD><CDB7>Transform
GameObject _vehicleGo = null;
Dictionary<string, GameObject> _assetsLoadDic = new Dictionary<string, GameObject>();
void BindScene()
{
PhxhSDK.Res.SceneHandle sceneHandle = GameSceneHelper.Instance.GetCurrentUIViewScene();
if (sceneHandle != null)
{
DebugUtil.Log("scene name is:" + sceneHandle.Scene.name);
var gos = sceneHandle.Scene.GetRootGameObjects();
foreach (var go in gos)
{
DebugUtil.Log("check go name: " + go.name);
if (go.name.Equals("Vehicle_Root"))
{
vRoot = go;
if (vRoot.transform.childCount > 0)//<2F>ؾ߸<D8BE><DFB8>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壬˵<E5A3AC><CBB5><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ع<EFBFBD><D8B9>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD>
{
if (_vehicleGo != null)
{
if (vRoot.transform.GetChild(0).GetInstanceID() != _vehicleGo.GetInstanceID())
{
foreach (Transform child in vRoot.transform)
{
Destroy(child.gameObject);
}
SetVehicleRoot();
}
}
else
{
foreach (Transform child in vRoot.transform)
{
Destroy(child.gameObject);
}
}
}
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
if (_vehicleGo != null)
SetVehicleRoot();
}
}
if (go.name.Equals("Rotate_Axis"))
{
_rotateTrans = go.transform;
DebugUtil.Log("find Rotate_Axis");
//break;
}
}
}
else
{
DebugUtil.LogWarning("sceneHandle is null");
}
if (_vehicleGo != null)
{
_vehicleGo.transform.SetParent(vRoot.transform);
_vehicleGo.transform.localPosition = Vector3.zero;
_vehicleGo.transform.localRotation = Quaternion.identity;
_vehicleGo.transform.localScale = Vector3.one;
}
}
void OnVehicleInfoUpdate()
{
LoadVehicleList();
2024-12-17 15:00:40 +08:00
VehicleInfoRefresh();
ScrollView_VehicleList.UpdateData();
}
2024-12-12 19:57:07 +08:00
async void VehicleInfoRefresh()
2024-12-12 19:11:59 +08:00
{
2024-12-25 12:40:51 +08:00
var curShownVehicleData = VehicleCultivateDataManager.Instance.GetVehicleCultivateData((uint)SelectedVehicleID);
2024-12-12 19:11:59 +08:00
if (curShownVehicleData == null)
{
DebugUtil.Log("mCurVehicles.Count = 0,<2C>ؾ<EFBFBD><D8BE><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ߽<D8BE><DFBD><EFBFBD>");
Text_VehicleName.text = CommonUtils.GetLocalizeText("vehicle_none");
return;
}
2024-12-12 19:57:07 +08:00
LoadVehicleModel(SelectedVehicleID);
2024-12-16 12:04:37 +08:00
Text_VehicleName.text = VehicleDataHelper.GetVehicleLocalizeName((int)SelectedVehicleID);
2024-12-12 19:11:59 +08:00
//Text_Name.text = curShownVehicleData.Name;
string imgPath = VehicleDataHelper.GetVehiclePicPath(curShownVehicleData.Cfg.ID);
//Image_HeadPic.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(imgPath);
//#region <20>ȼ<EFBFBD>
//Text_Level_Max.text = curShownVehicleData.SumPowerMaxLevel().ToString();
//Text_Max.text = curShownVehicleData.SumPowerMaxLevel().ToString();
//Text_Level_Now.text = curShownVehicleData.SumPowerLevel().ToString();
//Text_Current.text = curShownVehicleData.SumPowerLevel().ToString();
//#endregion
#region <20><><EFBFBD><EFBFBD>
Text_Level.text = CommonUtils.GetRomanCode(curShownVehicleData.Cfg.VehicleLevel);
2024-12-16 12:04:37 +08:00
Text_Organization.text = VehicleDataHelper.GetVehicleOrganization((int)SelectedVehicleID);
2025-01-08 15:41:43 +08:00
Text_VehicleType.text = VehicleDataHelper.GetVehicleCategory((int)SelectedVehicleID);
2024-12-16 12:04:37 +08:00
2024-12-12 19:11:59 +08:00
Text_HpValue.text = curShownVehicleData.Hp().ToString();
Text_MemberCountValue.text = curShownVehicleData.SeatCount().ToString();
Text_DefValue.text = curShownVehicleData.Defense().ToString();
Text_SpeedValue.text = curShownVehicleData.MoveSpeed().ToString();
Text_AtkValue.text = curShownVehicleData.Attack().ToString();
Text_BulletCountValue.text = curShownVehicleData.BulletCapacity().ToString();
#endregion
#region <20><>Ӧ<EFBFBD><D3A6>
Text_GroundAdapt.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainPlain);
Text_SnowAdapt.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainSnow);
Text_MountainAdapt.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainMountain);
Text_WoodAdapt.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainForest);
#endregion
2024-12-11 11:16:11 +08:00
2024-12-12 19:11:59 +08:00
#region <20><><EFBFBD><EFBFBD>
DataSkill nowSkillCfg = TableManager.Instance.Tables.SkillConfig.Get(VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID, true));
if (nowSkillCfg == null)
{
nowSkillCfg = TableManager.Instance.Tables.SkillConfig.DataList[0];
DebugUtil.LogError("<22>ؾ߼<D8BE><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ؾ<EFBFBD>IDΪ{0}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IDΪ{1}\n>><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>VehicleSkllUpgrade/SkillConfig_Vehicle", curShownVehicleData.Cfg.ID, VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID));
}
Text_SkillCoolingTimeValue.text = nowSkillCfg.ChargeParam.ToString() + "s";
2024-12-12 19:11:59 +08:00
Text_SkillName.text = CommonUtils.GetLocalizeText(E_LocalizePrefix.skill, nowSkillCfg.ID);
2024-12-12 19:57:07 +08:00
var skillIcon = await LoadAssetAsync<Sprite>(Framework.Constants.UI_Cultivata_skillIconFolder + nowSkillCfg.IconPath);
2024-12-12 19:11:59 +08:00
Image_SkillIcon.sprite = skillIcon;
//Text_Class_Value.text = CommonUtils.GetRomanCode((int)curShownVehicleData.SumBonus(BonusType.SkillLv) + 1);//δǿ<CEB4><C7BF>ʱ<EFBFBD>ȼ<EFBFBD>Ϊ1
Text_SkillInfo.text = CommonUtils.GetLocalizeText(E_LocalizePrefix.skill_desc, nowSkillCfg.ID);
#endregion
}
async void LoadVehicleModel(long id)
{
var config = TableManager.Instance.Tables.VehicleConfig.GetOrDefault((int)id);
2024-12-25 12:40:51 +08:00
var vehicleDataDic = VehicleCultivateDataManager.Instance.DataDic;
2024-12-12 19:11:59 +08:00
if (vehicleDataDic.TryGetValue(id, out var vehicleData))
{
if (vehicleData != null)
{
var prefabPath = PathEx.GetVehicleGameModelPath(vehicleData.Cfg.ID);
GameObject go = null;
if (_assetsLoadDic.ContainsKey(prefabPath))//<2F>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ع<EFBFBD>
{
go = _assetsLoadDic[prefabPath];
2024-12-12 19:11:59 +08:00
}
else
{
var prefab = await AssetManager.Instance.LoadAssetAsync<GameObject>(prefabPath);
go = Instantiate(prefab);
if(!go)
2024-12-12 19:11:59 +08:00
{
DebugUtil.LogError("<22>ؾ<EFBFBD>ģ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3>ؾ<EFBFBD>IDΪ{0}", id);
return;
2024-12-12 19:11:59 +08:00
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
// <20>ҵ<EFBFBD><D2B5><EFBFBD>̨<EFBFBD>ҵ<EFBFBD>
var allTrans = go.GetComponentsInChildren<Transform>();
var pointName = "Battery_point01";
var fireTrans = allTrans.First(t => t.name == pointName);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨ģ<CCA8><C4A3>
var rawConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(config.WeaponId);
var batteryPath = PathEx.GetBatteryModelPath(rawConfig.ModelPath);
var sampleObj = await AssetManager.Instance.LoadAssetAsync<GameObject>(batteryPath);
if (sampleObj != null)
{
sampleObj.SetLayerEx(LayerDefine.UIView);
//<2F><>װ<EFBFBD><D7B0>̨
var rootObj = UnityEngine.Object.Instantiate(sampleObj, fireTrans);
rootObj.transform.ResetLocals();
}
else
DebugUtil.LogError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨ʧ<CCA8><CAA7>: {0}", batteryPath);
2024-12-25 12:40:51 +08:00
//<2F><><EFBFBD><EFBFBD>Ϳװ
2024-12-25 15:38:35 +08:00
var paintCfg = Actor.Instance.Character.GetVehicleDevelopment(id).paint_set;
if (paintCfg != null)
{
for (int i = 1; i < (int)PaintType.Max; i++)
{
var paintID = paintCfg[i];
if (paintID == 0)
continue;
var paintPath = PathEx.GetVehiclePaintPath((int)id, (int)paintID);
2024-12-26 13:24:22 +08:00
//<2F><><EFBFBD><EFBFBD>Ϳװ<CDBF><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var material = await CommonUtils.GetVehiclePaintMaterial(paintPath);//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
2024-12-25 15:38:35 +08:00
var root = VehicleDataHelper.FindVehiclePartRoot(go, (int)id, (PaintType)i);
if (material != null && root != null)
{
var renderers = root.GetComponent<SkinnedMeshRenderer>();
renderers.materials = new Material[] { material };
}
}
}
else
DebugUtil.LogError("<22>ؾ<EFBFBD>Ϳװ<CDBF><D7B0><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>");
2024-12-25 12:40:51 +08:00
2024-12-12 19:11:59 +08:00
}
if (_vehicleGo != null)
2024-12-12 19:11:59 +08:00
{
_vehicleGo.SetActive(false);
2024-12-12 19:11:59 +08:00
}
_vehicleGo = go;
_vehicleGo.SetActive(true);
_assetsLoadDic.TryAdd(prefabPath, go);
go.SetLayerEx(LayerDefine.UIView);
SetVehicleRoot();
2024-12-12 19:11:59 +08:00
}
else
{
DebugUtil.LogError(id + "<22>ؾ<EFBFBD><D8BE><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD>");
}
}
else
{
DebugUtil.LogError("<22>ؾ<EFBFBD><D8BE><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ؾ<EFBFBD>IDΪ{0}", id);
}
}
2024-12-25 12:40:51 +08:00
async void SetVehiclePaint(int vehicleID, GameObject vehicleGO)
{
for (int i = 0; i < (int)cfg.VihecleCultivateCfg.PaintType.Max; i++)
{
var paintCfg = VehicleDataHelper.GetVehiclePartPaint(vehicleID, (cfg.VihecleCultivateCfg.PaintType)i);
if (paintCfg == null)
{
continue;
}
var paintPath = PathEx.GetVehiclePaintPath(vehicleID, paintCfg.PaintID);
var material = await CommonUtils.GetVehiclePaintMaterial(paintPath);
if (material != null)
{
switch (i)
{
case (int)cfg.VihecleCultivateCfg.PaintType.Entirety:
break;
case (int)cfg.VihecleCultivateCfg.PaintType.CaterpillarBelt:
break;
case (int)cfg.VihecleCultivateCfg.PaintType.Fort:
break;
}
}
}
}
2024-12-12 19:11:59 +08:00
void SetVehicleRoot()
{
if (vRoot != null)
{
_vehicleGo.transform.SetParent(vRoot.transform);
_vehicleGo.transform.localPosition = Vector3.zero;
_vehicleGo.transform.localRotation = Quaternion.identity;
_vehicleGo.transform.localScale = Vector3.one;
DebugUtil.Log("<22>ؾ<EFBFBD><D8BE>ѹ<EFBFBD><D1B9>ص<EFBFBD>vRoot");
}
else
{
DebugUtil.Log("vRoot<6F><74>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>");
}
}
void LoadVehicleList()
2024-12-25 12:40:51 +08:00
{
m_unlockedVehicles = VehicleCultivateDataManager.Instance.DataList;
foreach (var vehicle in m_unlockedVehicles)
{
//var item = ScrollView_VehicleList.AddItem();
//item.GetComponent<UI_VehicleItem>("UI_VehicleItem").SetData(vehicle);
DebugUtil.Log("LoadVehicleList: " + vehicle.Cfg.ID.ToString());
}
2024-12-30 16:13:58 +08:00
m_unlockedVehicles.Sort((a, b) => a.Cfg.ID.CompareTo(b.Cfg.ID));
2024-12-25 12:40:51 +08:00
}
2024-12-18 19:58:14 +08:00
void HideUI(bool show)
{
m_isVehicleUIShow = show;
FindObj("UI_CurrencyList").SetActive(show);
FindObj("UI_LiuHaiLeft").SetActive(show);
FindObj("UI_LiuHaiRight").SetActive(show);
Button_TechTree.gameObject.SetActive(show);
FindObj("VehicleList").SetActive(show);
}
2024-12-11 11:16:11 +08:00
#region Button Click Event
2024-12-18 19:58:14 +08:00
public void OnButton_backClick()
{
if (m_isVehicleUIShow)
{
CommonUtils.ChangeUIScene(Framework.Constants.MAIN_SCENE_PATH);
CloseWindow();
UIManager.Instance.ShowAllUI();
}
else
{
HideUI(true);
}
2024-12-11 11:16:11 +08:00
}
2024-12-25 12:40:51 +08:00
public void OnButton_HomeClick()
{
2024-12-11 11:16:11 +08:00
CommonUtils.ChangeUIScene(Framework.Constants.MAIN_SCENE_PATH);
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
}
2024-12-25 12:40:51 +08:00
public void OnButton_TreeClick()
{
UI_VehicleTechTreeController.Open().Forget();
}
2024-12-12 19:11:59 +08:00
2024-12-25 12:40:51 +08:00
public void OnButton_DevClick()
{
UI_VehiclePartTreeController.Open(SelectedVehicleID).Forget();
}
2024-12-13 14:56:43 +08:00
public void OnButton_PaintClick()
{
2024-12-26 14:53:11 +08:00
_rotateTrans.transform.DOMove(new Vector3(55, 0, 20), 0.3f);
_rotateTrans.transform.DORotate(new Vector3(0, 0, 0), 0.3f);
2024-12-25 12:40:51 +08:00
UI_VehicleSkinController.Open(SelectedVehicleID, _vehicleGo).Forget();
2024-12-13 14:56:43 +08:00
}
2024-12-12 19:11:59 +08:00
#endregion
#region scrollView
2024-12-16 12:04:37 +08:00
async void UpdateScrollViewItem(int index, RectTransform item)
2024-12-12 19:57:07 +08:00
{
item.gameObject.SetActive(true);
var vehicle = m_unlockedVehicles[index];
var vehicleCfg = vehicle.Cfg;
string name = vehicle.Name;
2024-12-16 12:04:37 +08:00
var levelStr = CommonUtils.GetRomanCode(vehicle.Cfg.VehicleLevel);
2024-12-12 19:57:07 +08:00
CommonUtils.GetComponent<TMP_Text>(item.gameObject, "Text_VehicleName").text = name;
2024-12-16 12:04:37 +08:00
CommonUtils.GetComponent<TMP_Text>(item.gameObject, "Text_Level").text = levelStr;
GameObject highLight = CommonUtils.GetGameObject(item.gameObject, "Image_CurrentSelection");
highLight.SetActive(SelectedVehicleID == vehicleCfg.ID);
var button = CommonUtils.GetComponent<Button>(item.gameObject);
2024-12-25 12:40:51 +08:00
if (button != null)
{
button.onClick.RemoveAllListeners();
CommonUtils.BindButton(button, () => OnVehicleSelected(vehicleCfg.ID));
}
2024-12-16 12:04:37 +08:00
var sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(VehicleDataHelper.GetVehiclePicPath(vehicleCfg.ID));
CommonUtils.GetComponent<Image>(item.gameObject, "Image_VehicleIcon").sprite = sprite;
2024-12-12 19:57:07 +08:00
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>Item<65><6D><EFBFBD><EFBFBD>
/// </summary>
/// <param name="id"></param>
void OnVehicleSelected(long id)
{
SelectedVehicleID = id;
ScrollView_VehicleList.UpdateData();
VehicleInfoRefresh();
}
2024-12-12 19:11:59 +08:00
#endregion
#region rotation
bool isRegisterInput = false;
private void ControllInput(bool isRegister)
{
if (isRegisterInput == isRegister)
{
return;
}
isRegisterInput = isRegister;
2024-12-13 14:56:43 +08:00
DebugUtil.Log("vehicle rotate input register: " + isRegister.ToString());
2024-12-12 19:11:59 +08:00
//<2F><>UI<55><49><EFBFBD><EFBFBD><EFBFBD>ſ<EFBFBD><C5BF><EFBFBD>ק
if (isRegister)
{
InputManager.Instance.OnFingerMove += OnFingleSwipe;
}
else
{
InputManager.Instance.OnFingerMove -= OnFingleSwipe;
}
}
private void OnFingleSwipe(Vector2 delta)
{
if (delta == Vector2.zero) return;
if (_rotateTrans != null)
{
_rotateTrans.Rotate(Vector3.up, .3f * delta.x);
}
else
{
DebugUtil.LogError("Rotate_Axis is null");
}
}
2024-12-11 11:16:11 +08:00
#endregion
2024-12-09 17:02:39 +08:00
}