2024-08-19 13:37:31 +08:00
|
|
|
|
using cfg.SkillCfg;
|
2024-08-16 19:38:29 +08:00
|
|
|
|
using cfg.VihecleCultivateCfg;
|
2024-08-16 14:36:25 +08:00
|
|
|
|
using Cysharp.Threading.Tasks;
|
2024-08-16 19:38:29 +08:00
|
|
|
|
using Framework;
|
2024-08-16 14:36:25 +08:00
|
|
|
|
using Gameplay;
|
2024-08-23 16:34:36 +08:00
|
|
|
|
using Gameplay.Common;
|
|
|
|
|
|
using Gameplay.Utils;
|
2024-08-16 14:36:25 +08:00
|
|
|
|
using PhxhSDK;
|
2024-08-20 13:41:45 +08:00
|
|
|
|
using System;
|
2024-08-16 14:36:25 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-09-30 17:17:10 +08:00
|
|
|
|
using System.Linq;
|
2024-08-16 14:36:25 +08:00
|
|
|
|
using TMPro;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using static UI_VehicleChooseController;
|
|
|
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
|
using Constants = Framework.Constants;
|
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
|
|
|
|
|
|
|
public class UI_VehicleCultivateNewController : UIWindow
|
|
|
|
|
|
{
|
|
|
|
|
|
#region UI_Obj
|
|
|
|
|
|
//UI GameObj
|
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
|
public Button Button_back;
|
|
|
|
|
|
public TMP_Text Text_Back;
|
|
|
|
|
|
public Button Button_Home;
|
|
|
|
|
|
public Image Image_PhoneState;
|
|
|
|
|
|
public Image Image_Property;
|
|
|
|
|
|
public TMP_Text Text_Property;
|
|
|
|
|
|
public Image Image_Hp;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_Hp;
|
|
|
|
|
|
public TMP_Text Text_Hp_Value;
|
|
|
|
|
|
public Image Image_Defance;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_Defance;
|
|
|
|
|
|
public TMP_Text Text_Defance_Value;
|
|
|
|
|
|
public Image Image_Capacity;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_Capacity;
|
|
|
|
|
|
public TMP_Text Text_Capacity_Value;
|
|
|
|
|
|
public Image Image_PersonNum;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_PersonNum;
|
|
|
|
|
|
public TMP_Text Text_PersonNum_Value;
|
|
|
|
|
|
public Image Image_Attack;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_Attack;
|
|
|
|
|
|
public TMP_Text Text_Attack_Value;
|
|
|
|
|
|
public Image Image_Speed;
|
|
|
|
|
|
public TMP_Text Text_Vehicle_Speed;
|
|
|
|
|
|
public TMP_Text Text_Speed_Value;
|
|
|
|
|
|
public Image Image_Terrian;
|
|
|
|
|
|
public TMP_Text Text_Terrian;
|
|
|
|
|
|
public Image Image_Road;
|
|
|
|
|
|
public TMP_Text Text_RoadName;
|
|
|
|
|
|
public TMP_Text Text_Road_Value;
|
|
|
|
|
|
public Image Image_Snow;
|
|
|
|
|
|
public TMP_Text Text_SnowName;
|
|
|
|
|
|
public TMP_Text Text_Snow_Value;
|
|
|
|
|
|
public Image Image_Mountain;
|
|
|
|
|
|
public TMP_Text Text_MountainName;
|
|
|
|
|
|
public TMP_Text Text_Mountain_Value;
|
|
|
|
|
|
public Image Image_Forest;
|
|
|
|
|
|
public TMP_Text Text_ForestName;
|
|
|
|
|
|
public TMP_Text Text_Forest_Value;
|
|
|
|
|
|
public Image Image_LevelBarBG;
|
|
|
|
|
|
public Button Button_LevelStrengthen;
|
|
|
|
|
|
public TMP_Text Text_Level_Max;
|
|
|
|
|
|
public TMP_Text Text_LevelName;
|
|
|
|
|
|
public TMP_Text Text_Level_Now;
|
|
|
|
|
|
public Image Image_LastAndNextLevel;
|
|
|
|
|
|
public TMP_Text Text_Last;
|
|
|
|
|
|
public TMP_Text Text_Next;
|
|
|
|
|
|
public Image Image_ActiveSkill;
|
|
|
|
|
|
public TMP_Text Text_ActiveSkill;
|
|
|
|
|
|
public TMP_Text Text_ActiveSkillName;
|
|
|
|
|
|
public TMP_Text Text_SkillLevel;
|
|
|
|
|
|
public TMP_Text Text_Class;
|
|
|
|
|
|
public TMP_Text Text_Class_Value;
|
|
|
|
|
|
public Image Image_SkillLogo;
|
|
|
|
|
|
public Image Image_UI_SkillCd;
|
|
|
|
|
|
public TMP_Text Text_CDSecond;
|
|
|
|
|
|
public TMP_Text Text_CDTme;
|
|
|
|
|
|
public TMP_Text Text_SkillInfo;
|
|
|
|
|
|
public Image Image_VehicelIconBg;
|
|
|
|
|
|
public Image Image_Icon;
|
|
|
|
|
|
public TMP_Text Text_VehicleName;
|
|
|
|
|
|
public Button Button_VehicleList;
|
|
|
|
|
|
public Image Image_HeadPic;
|
|
|
|
|
|
public Image Image_Lv;
|
|
|
|
|
|
public TMP_Text Text_Max;
|
|
|
|
|
|
public TMP_Text Text_Current;
|
|
|
|
|
|
public Image Image_LastAndNext;
|
|
|
|
|
|
public Image Image_BottomDark;
|
|
|
|
|
|
public Image Image_JobBg;
|
|
|
|
|
|
public Image Image_Job;
|
|
|
|
|
|
public TMP_Text Text_Name;
|
|
|
|
|
|
public Image Image_HealthIcon;
|
|
|
|
|
|
public TMP_Text Text_PropertyValue;
|
|
|
|
|
|
public Image Image_Mask;
|
|
|
|
|
|
public Image Image_Back;
|
|
|
|
|
|
public Image Image_LeftDark;
|
|
|
|
|
|
public Image Image_TopBlackBar;
|
|
|
|
|
|
public Image Image_BottomBlackBar;
|
|
|
|
|
|
|
|
|
|
|
|
///Auto Gen End///
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
// deal with input data
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
//List<VehicleCultivateData> mShowList;
|
|
|
|
|
|
|
2024-08-16 14:36:25 +08:00
|
|
|
|
PhxhScrollViewEx BottomVehicleScrollView;
|
|
|
|
|
|
|
|
|
|
|
|
List<VehicleCultivateData> mCurVehicles;
|
|
|
|
|
|
VehicleCultivateData curShownVehicleData;
|
|
|
|
|
|
|
2024-08-23 16:34:36 +08:00
|
|
|
|
GameObject _vehicleGo = null;
|
|
|
|
|
|
GameObject vRoot = null;//载具根节点
|
2024-08-23 18:01:15 +08:00
|
|
|
|
Transform _rotateTrans;//旋转镜头的Transform
|
2024-08-23 16:34:36 +08:00
|
|
|
|
|
|
|
|
|
|
Dictionary<string, GameObject> _assetsLoadDic = new Dictionary<string, GameObject>();
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
#region API
|
2024-08-16 14:36:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打开载具界面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static async UniTask<UIWindow> Open()
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow uiWindow = await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_VehicleCultivateNew);
|
2024-08-23 16:34:36 +08:00
|
|
|
|
CommonUtils.ChangeUIScene(Constants.UI_VEHICLE_CHOOSE_SCENE_PATH);
|
|
|
|
|
|
var wind = uiWindow as UI_VehicleCultivateNewController;
|
|
|
|
|
|
wind.BindScene();
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
|
|
|
|
|
CameraManager.Instance.SetMainCameraActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
return uiWindow;
|
|
|
|
|
|
}
|
2024-08-16 19:38:29 +08:00
|
|
|
|
#endregion
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
#region UIWindow_Function
|
2024-08-16 14:36:25 +08:00
|
|
|
|
public override void PreLoad(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
GetStorageData();
|
2024-08-19 13:37:31 +08:00
|
|
|
|
|
|
|
|
|
|
#region 载具图片
|
|
|
|
|
|
foreach (var cfg in mCurVehicles)
|
2024-08-16 14:36:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
string imgPath = VehicleDataHelper.GetVehiclePicPath(cfg.Cfg.ID);
|
|
|
|
|
|
AssetManager.Instance.PostPreload<Sprite>(imgPath).Forget();
|
|
|
|
|
|
}
|
2024-08-19 13:37:31 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 技能图片
|
|
|
|
|
|
foreach (var cfg in mCurVehicles)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataSkill nowSkillCfg = TableManager.Instance.Tables.SkillConfig.Get(VehicleDataHelper.GetVehicleSkillId(cfg.Cfg.ID));
|
|
|
|
|
|
if (nowSkillCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("载具技能配置未能找到!载具ID为{0},技能ID为{1}\n>>请检查相关配置表:VehicleSkllUpgrade/SkillConfig_Vehicle", cfg.Cfg.ID, VehicleDataHelper.GetVehicleSkillId(cfg.Cfg.ID));
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
AssetManager.Instance.PostPreload<Sprite>(Framework.Constants.UI_Cultivata_skillIconFolder + nowSkillCfg.IconPath).Forget();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mCurVehicles.Count > 0)
|
2024-08-16 14:36:25 +08:00
|
|
|
|
curShownVehicleData = mCurVehicles[0];
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownVehicleData = null;
|
|
|
|
|
|
DebugUtil.LogError("mCurVehicles.Count is 0");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-20 13:41:45 +08:00
|
|
|
|
|
2024-08-16 14:36:25 +08:00
|
|
|
|
// Use this for initialization
|
|
|
|
|
|
public override void OnInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
//bind UI GameObj
|
|
|
|
|
|
UI_VehicleCultivateNewBinder.GetComponents(this);
|
|
|
|
|
|
BottomVehicleScrollView = GetComponent<PhxhScrollViewEx>("UI_VehicleList/UI_VehicleList");
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
BindButton(Button_back, OnBackClick);
|
|
|
|
|
|
BindButton(Button_Home, OnHomeClick);
|
2024-08-16 14:36:25 +08:00
|
|
|
|
BindButton(Button_VehicleList, OnVehicleListClick);
|
2024-08-16 19:38:29 +08:00
|
|
|
|
BindButton(Button_LevelStrengthen, OnCultivateClick);
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
|
|
|
|
|
BottomVehicleScrollView.SetItemCountFunc(() => mCurVehicles.Count);
|
|
|
|
|
|
BottomVehicleScrollView.SetUpdateFunc(_RefreshSkinItem);
|
2024-08-20 13:41:45 +08:00
|
|
|
|
BottomVehicleScrollView.UpdateData();
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
2024-08-23 18:01:15 +08:00
|
|
|
|
VehicleInfoRefresh();
|
2024-08-16 19:38:29 +08:00
|
|
|
|
|
2024-09-20 19:01:06 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.VehecleUpgrade, OnVehicleUpgrade);
|
2024-08-20 13:41:45 +08:00
|
|
|
|
EventManager.Instance.Register<uint>(EventManager.EventName.VehicleInfoChoose, OnVehicleChange);
|
2024-08-23 18:01:15 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.EN_UIControllCultivateMainInput, (Action<bool>)ControllInput);
|
2024-08-20 13:41:45 +08:00
|
|
|
|
}
|
2024-08-16 19:38:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when open window
|
|
|
|
|
|
protected override void OnShowWindow(object data = null)
|
2024-08-16 14:36:25 +08:00
|
|
|
|
{
|
2024-08-23 18:01:15 +08:00
|
|
|
|
ControllInput(true);
|
|
|
|
|
|
}
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
|
|
|
|
|
//invoke when reload window
|
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when close window
|
|
|
|
|
|
protected override void OnHideWindow()
|
|
|
|
|
|
{
|
2024-08-23 18:01:15 +08:00
|
|
|
|
ControllInput(false);
|
2024-08-16 14:36:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when destroy
|
|
|
|
|
|
public override void OnRelease()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnRelease();
|
2024-09-20 19:01:06 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.VehecleUpgrade, OnVehicleUpgrade);
|
2024-08-20 13:41:45 +08:00
|
|
|
|
EventManager.Instance.Unregister<uint>(EventManager.EventName.VehicleInfoChoose, OnVehicleChange);
|
2024-08-23 18:01:15 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.EN_UIControllCultivateMainInput, (Action<bool>)ControllInput);
|
2024-08-19 13:37:31 +08:00
|
|
|
|
|
|
|
|
|
|
#region 卸载预载载具图片
|
|
|
|
|
|
foreach (var cfg in mCurVehicles)
|
|
|
|
|
|
{
|
|
|
|
|
|
string imgPath = VehicleDataHelper.GetVehiclePicPath(cfg.Cfg.ID);
|
|
|
|
|
|
AssetManager.Instance.Unload(imgPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-08-16 19:38:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-21 16:37:46 +08:00
|
|
|
|
public override UniTask<bool> OnBack(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
|
|
|
|
|
|
return base.OnBack(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2024-08-23 16:34:36 +08:00
|
|
|
|
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;
|
2024-09-30 17:17:10 +08:00
|
|
|
|
if(vRoot.transform.childCount > 0)//载具根节点下有子物体,说明已经加载过了,清空
|
|
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-23 16:34:36 +08:00
|
|
|
|
}
|
2024-09-30 17:17:10 +08:00
|
|
|
|
else//无需清理
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_vehicleGo != null)
|
|
|
|
|
|
SetVehicleRoot();
|
|
|
|
|
|
}
|
2024-08-23 18:01:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (go.name.Equals("Rotate_Axis"))
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans = go.transform;
|
|
|
|
|
|
DebugUtil.Log("find Rotate_Axis");
|
|
|
|
|
|
//break;
|
2024-08-23 16:34:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-20 19:01:06 +08:00
|
|
|
|
void OnVehicleUpgrade()
|
|
|
|
|
|
{
|
|
|
|
|
|
VehicleInfoRefresh();
|
|
|
|
|
|
BottomVehicleScrollView.UpdateData();
|
|
|
|
|
|
}
|
2024-08-23 16:34:36 +08:00
|
|
|
|
|
2024-08-21 16:37:46 +08:00
|
|
|
|
void VehicleInfoRefresh()
|
2024-08-16 19:38:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
Text_VehicleName.text = curShownVehicleData.Name;
|
|
|
|
|
|
Text_Name.text = curShownVehicleData.Name;
|
2024-08-19 13:37:31 +08:00
|
|
|
|
string imgPath = VehicleDataHelper.GetVehiclePicPath(curShownVehicleData.Cfg.ID);
|
|
|
|
|
|
Image_HeadPic.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(imgPath);
|
2024-08-16 19:38:29 +08:00
|
|
|
|
|
2024-08-19 13:37:31 +08:00
|
|
|
|
#region 等级
|
|
|
|
|
|
Text_Level_Max.text = curShownVehicleData.SumPowerMaxLevel().ToString();
|
2024-08-16 19:38:29 +08:00
|
|
|
|
Text_Max.text = curShownVehicleData.SumPowerMaxLevel().ToString();
|
|
|
|
|
|
Text_Level_Now.text = curShownVehicleData.SumPowerLevel().ToString();
|
|
|
|
|
|
Text_Current.text = curShownVehicleData.SumPowerLevel().ToString();
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 属性
|
|
|
|
|
|
Text_Hp_Value.text = curShownVehicleData.Hp().ToString();
|
|
|
|
|
|
Text_PersonNum_Value.text = curShownVehicleData.SeatCount().ToString();
|
|
|
|
|
|
Text_Defance_Value.text = curShownVehicleData.Defense().ToString();
|
|
|
|
|
|
Text_Speed_Value.text = curShownVehicleData.MoveSpeed().ToString();
|
|
|
|
|
|
Text_Attack_Value.text = curShownVehicleData.Attack().ToString();
|
|
|
|
|
|
Text_Capacity_Value.text = curShownVehicleData.BulletCapacity().ToString();
|
2024-08-19 13:37:31 +08:00
|
|
|
|
#endregion
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
2024-08-19 13:37:31 +08:00
|
|
|
|
#region 适应性
|
|
|
|
|
|
Text_Road_Value.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainPlain);
|
|
|
|
|
|
Text_Snow_Value.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainSnow);
|
|
|
|
|
|
Text_Mountain_Value.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainMountain);
|
|
|
|
|
|
Text_Forest_Value.text = curShownVehicleData.GetTerrainAdapt(BonusType.TerrainForest);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 技能
|
|
|
|
|
|
DataSkill nowSkillCfg =
|
|
|
|
|
|
TableManager.Instance.Tables.SkillConfig.Get(VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID));
|
|
|
|
|
|
if (nowSkillCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
nowSkillCfg = TableManager.Instance.Tables.SkillConfig.DataList[0];
|
|
|
|
|
|
DebugUtil.LogError("载具技能配置未能找到!载具ID为{0},技能ID为{1}\n>>请检查相关配置表:VehicleSkllUpgrade/SkillConfig_Vehicle", curShownVehicleData.Cfg.ID, VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Text_CDTme.text = nowSkillCfg.CDTime.ToString();
|
|
|
|
|
|
Text_ActiveSkillName.text = CommonUtils.GetLocalizeText(E_LocalizePrefix.skill, nowSkillCfg.ID);
|
|
|
|
|
|
|
|
|
|
|
|
var skillIcon = AssetManager.Instance.GetPreLoadResult<Sprite>(Framework.Constants.UI_Cultivata_skillIconFolder + nowSkillCfg.IconPath);
|
|
|
|
|
|
Image_SkillLogo.sprite = skillIcon;
|
|
|
|
|
|
Text_Class_Value.text = CommonUtils.GetRomanCode((int)curShownVehicleData.SumBonus(BonusType.SkillLv) + 1);//未强化时等级为1
|
|
|
|
|
|
|
|
|
|
|
|
Text_SkillInfo.text = CommonUtils.GetLocalizeText(E_LocalizePrefix.skill_desc, nowSkillCfg.ID);
|
|
|
|
|
|
#endregion
|
2024-08-23 16:34:36 +08:00
|
|
|
|
|
2024-09-30 17:17:10 +08:00
|
|
|
|
LoadVehicleModel(curShownVehicleData);
|
2024-10-17 18:38:07 +08:00
|
|
|
|
AudioManager.Instance.PlayAudio(Constants.Sound.TEAM_VEHICLE, AudioCriManager.EPlayType.Music, null, true);
|
|
|
|
|
|
}
|
2024-08-23 16:34:36 +08:00
|
|
|
|
|
2024-09-30 17:17:10 +08:00
|
|
|
|
async void LoadVehicleModel(VehicleCultivateData curShownVehicleData)
|
2024-08-23 16:34:36 +08:00
|
|
|
|
{
|
2024-09-30 17:17:10 +08:00
|
|
|
|
var id = (uint)curShownVehicleData.Cfg.ID;
|
|
|
|
|
|
var config = VehicleDataHelper.CombineConfigData(curShownVehicleData);
|
|
|
|
|
|
|
|
|
|
|
|
var vehicleDataDic = VehicleCultivateDataManager.Instance.DataDic;
|
2024-08-23 16:34:36 +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))//已经加载过
|
|
|
|
|
|
{
|
|
|
|
|
|
go = _assetsLoadDic[prefabPath];
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var prefab = await AssetManager.Instance.LoadAssetAsync<GameObject>(prefabPath);
|
|
|
|
|
|
go = Instantiate(prefab);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (go)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_vehicleGo != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_vehicleGo.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
_vehicleGo = go;
|
|
|
|
|
|
_vehicleGo.SetActive(true);
|
|
|
|
|
|
_assetsLoadDic.TryAdd(prefabPath, go);
|
|
|
|
|
|
go.SetLayerEx(LayerDefine.UIView);
|
|
|
|
|
|
|
2024-09-30 17:17:10 +08:00
|
|
|
|
// 加载炮台部分
|
|
|
|
|
|
// 找到炮台挂点
|
|
|
|
|
|
var allTrans = go.GetComponentsInChildren<Transform>();
|
|
|
|
|
|
var pointName = "Battery_point01";
|
|
|
|
|
|
var fireTrans = allTrans.First(t => t.name == pointName);
|
|
|
|
|
|
|
|
|
|
|
|
//加载炮台模型
|
|
|
|
|
|
var rawConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(config.weaponId);
|
|
|
|
|
|
var batteryPath = rawConfig.ModelPath;
|
|
|
|
|
|
var sampleObj = await AssetManager.Instance.LoadAssetAsync<GameObject>(batteryPath);
|
|
|
|
|
|
if (sampleObj != null)
|
2024-08-23 18:01:15 +08:00
|
|
|
|
{
|
2024-09-30 17:17:10 +08:00
|
|
|
|
sampleObj.SetLayerEx(LayerDefine.UIView);
|
|
|
|
|
|
|
|
|
|
|
|
//安装炮台
|
|
|
|
|
|
var rootObj = UnityEngine.Object.Instantiate(sampleObj, fireTrans);
|
|
|
|
|
|
rootObj.transform.ResetLocals();
|
2024-08-23 18:01:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-09-30 17:17:10 +08:00
|
|
|
|
DebugUtil.LogError("加载炮台失败: {0}", batteryPath);
|
|
|
|
|
|
|
|
|
|
|
|
SetVehicleRoot();
|
2024-08-23 16:34:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("载具模型加载失败!载具ID为{0}", id);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError(id + "载具数据为空!");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("载具数据未找到!载具ID为{0}", id);
|
|
|
|
|
|
}
|
2024-08-19 13:37:31 +08:00
|
|
|
|
}
|
2024-08-23 16:34:36 +08:00
|
|
|
|
|
2024-09-30 17:17:10 +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("载具已挂载到vRoot");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("vRoot尚未加载");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
void GetStorageData()
|
2024-08-16 14:36:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (mCurVehicles == null)
|
|
|
|
|
|
mCurVehicles = new List<VehicleCultivateData>();
|
|
|
|
|
|
mCurVehicles.Clear();
|
|
|
|
|
|
mCurVehicles.AddRange(VehicleCultivateDataManager.Instance.DataList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-20 13:41:45 +08:00
|
|
|
|
private void OnVehicleChange(uint id)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ValueValidator.IsIdValid(id))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (id == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("选中载具ID为0,无效!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var vehicle in mCurVehicles)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (vehicle.Cfg.ID == id)
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownVehicleData = vehicle;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownVehicleData = mCurVehicles[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
VehicleInfoRefresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-23 18:01:15 +08:00
|
|
|
|
private void ControllInput(bool isRegister)
|
|
|
|
|
|
{
|
|
|
|
|
|
//非UI区域才可拖拽
|
|
|
|
|
|
if (isRegister)
|
|
|
|
|
|
{
|
|
|
|
|
|
InputManager.Instance.OnFingerMove += OnFingleSwipe;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
InputManager.Instance.OnFingerMove -= OnFingleSwipe;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-20 13:41:45 +08:00
|
|
|
|
#region scrollview
|
|
|
|
|
|
private void _RefreshSkinItem(int index, RectTransform item)
|
2024-08-16 14:36:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
var cfg = mCurVehicles[index];
|
|
|
|
|
|
if(cfg == null)
|
|
|
|
|
|
{
|
2024-08-16 19:38:29 +08:00
|
|
|
|
DebugUtil.LogError($"Index:{index} VehicleCultivateData cfg is null");
|
2024-08-16 14:36:25 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var image = CommonUtils.GetComponent<Image>(item.gameObject, "UI_CultivateVehicle/Vehicle/Image_HeadPic");
|
2024-08-16 19:38:29 +08:00
|
|
|
|
TMP_Text nameText = CommonUtils.GetComponent<TMP_Text>(item.gameObject, "UI_CultivateVehicle/Text_Name");
|
|
|
|
|
|
TMP_Text levelText = CommonUtils.GetComponent<TMP_Text>(item.gameObject, "UI_CultivateVehicle/Image_Lv/Text_Current");
|
|
|
|
|
|
TMP_Text maxLevelText = CommonUtils.GetComponent<TMP_Text>(item.gameObject, "UI_CultivateVehicle/Image_Lv/Text_Max");
|
|
|
|
|
|
Button btn = CommonUtils.GetComponent<Button>(item.gameObject, "UI_CultivateVehicle");
|
|
|
|
|
|
|
2024-08-16 14:36:25 +08:00
|
|
|
|
if (image != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var path = VehicleDataHelper.GetVehiclePicPath(cfg.Cfg.ID);
|
|
|
|
|
|
image.sprite = AssetManager.Instance.GetPreLoadResult<Sprite>(path);
|
|
|
|
|
|
}
|
2024-08-16 19:38:29 +08:00
|
|
|
|
|
|
|
|
|
|
if (nameText != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string vehicleName = cfg.Name;
|
|
|
|
|
|
nameText.text = vehicleName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (levelText != null && maxLevelText != null)
|
2024-08-16 14:36:25 +08:00
|
|
|
|
{
|
2024-08-16 19:38:29 +08:00
|
|
|
|
levelText.text = cfg.SumPowerLevel().ToString();
|
|
|
|
|
|
maxLevelText.text = cfg.SumPowerMaxLevel().ToString();
|
2024-08-16 14:36:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
if (btn != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ClearBind(btn);
|
|
|
|
|
|
BindButton(btn, OnSelectVehicleClick, index);
|
|
|
|
|
|
}
|
2024-08-16 14:36:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Button_Listener
|
|
|
|
|
|
|
|
|
|
|
|
async void OnVehicleListClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_VehicleChoose);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnSelectVehicleClick(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
VehicleCultivateData info = mCurVehicles[index];
|
2024-08-16 19:38:29 +08:00
|
|
|
|
VehicleCultivateParam cultivateStruct = new VehicleCultivateParam();
|
2024-08-16 14:36:25 +08:00
|
|
|
|
cultivateStruct.showList = mCurVehicles;//mShowList;
|
2024-08-16 19:38:29 +08:00
|
|
|
|
cultivateStruct.info = info;
|
|
|
|
|
|
|
|
|
|
|
|
if (curShownVehicleData != info)
|
|
|
|
|
|
{
|
|
|
|
|
|
curShownVehicleData = info;
|
|
|
|
|
|
VehicleInfoRefresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-16 14:36:25 +08:00
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
void OnBackClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
|
UIManager.Instance.ShowAllUI();
|
2024-08-16 14:36:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-16 19:38:29 +08:00
|
|
|
|
void OnHomeClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
//
|
|
|
|
|
|
CommonUtils.ChangeUIScene(Constants.MAIN_SCENE_PATH);
|
|
|
|
|
|
//CloseWindow();
|
|
|
|
|
|
//UIManager.Instance.ShowAllUI();
|
|
|
|
|
|
UIManager.Instance.CloseAllNormalExcept(UINameConst.UI_MainPanel);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async void OnCultivateClick()
|
|
|
|
|
|
{
|
|
|
|
|
|
await UI_VehicleLevelUpController.Open(curShownVehicleData);
|
2024-08-23 18:01:15 +08:00
|
|
|
|
ControllInput(false);//关闭旋转,因为此时该界面不隐藏
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-08-16 19:38:29 +08:00
|
|
|
|
|
2024-08-16 14:36:25 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|