2025-01-20 14:10:53 +08:00
|
|
|
|
using cfg.SkillCfg;
|
2024-12-26 14:53:11 +08:00
|
|
|
|
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
|
|
|
|
|
2025-03-13 17:03:44 +08:00
|
|
|
|
public class UI_VehicleCultivateProController : UIWindow, IMobileInputEventHandler
|
2024-12-09 17:02:39 +08:00
|
|
|
|
{
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-20 19:34:04 +08:00
|
|
|
|
|
|
|
|
|
|
private bool isEditTeam;
|
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;
|
2025-01-15 17:25:50 +08:00
|
|
|
|
private Vector3 cameraPos;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2024-12-25 12:40:51 +08:00
|
|
|
|
private List<VehicleCultivateData> m_unlockedVehicles = new();
|
2025-03-13 17:03:44 +08:00
|
|
|
|
|
2025-03-18 17:30:49 +08:00
|
|
|
|
private InputInterpreter _inputInterpreter;
|
2025-03-13 17:03:44 +08:00
|
|
|
|
|
2025-03-20 19:34:04 +08:00
|
|
|
|
private class OpenData
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
2025-03-20 19:34:04 +08:00
|
|
|
|
public int ID = -1;
|
|
|
|
|
|
public bool EditTeam;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async static UniTask<UIWindow> Open(int VehicleID = -1,bool isEditTeam = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
var openData = new OpenData
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = VehicleID,
|
|
|
|
|
|
EditTeam = isEditTeam,
|
|
|
|
|
|
};
|
|
|
|
|
|
UIWindow uiWindow = await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_VehicleCultivatePro, openData);
|
2024-12-11 11:16:11 +08:00
|
|
|
|
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
|
|
|
|
{
|
2025-03-20 19:34:04 +08:00
|
|
|
|
if(data is not OpenData openData)
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (openData.ID != -1)
|
2025-03-20 14:57:51 +08:00
|
|
|
|
{
|
2025-03-20 19:34:04 +08:00
|
|
|
|
m_selectedVehicleID = openData.ID;
|
2025-03-20 14:57:51 +08:00
|
|
|
|
}
|
2025-03-20 19:34:04 +08:00
|
|
|
|
|
|
|
|
|
|
isEditTeam = openData.EditTeam;
|
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);
|
2025-01-16 15:00:19 +08:00
|
|
|
|
BindButton(Button_Look, () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowUI(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
|
|
|
|
{
|
2025-03-20 14:57:51 +08:00
|
|
|
|
if (m_unlockedVehicles.FirstOrDefault(x => x.Cfg.ID == SelectedVehicleID) == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SelectedVehicleID != 0)
|
|
|
|
|
|
DebugUtil.LogError("无法在已解锁载具中找到ID为{0}的载具!", SelectedVehicleID);
|
|
|
|
|
|
SelectedVehicleID = m_unlockedVehicles[0].Cfg.ID;
|
|
|
|
|
|
}
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
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);
|
2025-03-18 17:30:49 +08:00
|
|
|
|
|
2024-12-16 13:20:15 +08:00
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.VehecleUpgrade, OnVehicleInfoUpdate);
|
2025-03-13 17:03:44 +08:00
|
|
|
|
|
2025-03-18 17:30:49 +08:00
|
|
|
|
if (_inputInterpreter == null)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
2025-03-18 17:30:49 +08:00
|
|
|
|
_inputInterpreter = InputInterpreterFactory.CreateInterpreter(InputInterpreterType.AutoPlatform_ExcludeUI, "UI_VehicleCultivatePro", this);
|
2025-03-13 17:03:44 +08:00
|
|
|
|
}
|
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
|
|
|
|
|
2024-12-26 14:53:11 +08:00
|
|
|
|
if (_rotateTrans != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans.transform.DOKill();
|
|
|
|
|
|
_rotateTrans.transform.rotation = Quaternion.Euler(0, 0, 0);
|
2025-01-15 17:25:50 +08:00
|
|
|
|
|
|
|
|
|
|
_rotateTrans.GetChild(0).localPosition = cameraPos;
|
2025-01-16 15:00:19 +08:00
|
|
|
|
zoomScale = 0f;
|
2024-12-26 14:53:11 +08:00
|
|
|
|
}
|
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()
|
|
|
|
|
|
{
|
2025-01-16 15:00:19 +08:00
|
|
|
|
//ControllInput(false);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
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
|
|
|
|
|
2025-03-18 17:30:49 +08:00
|
|
|
|
if (_inputInterpreter != null)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
2025-03-18 17:30:49 +08:00
|
|
|
|
_inputInterpreter.Destroy(true);
|
|
|
|
|
|
_inputInterpreter = null;
|
2025-03-13 17:03:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-15 17:25:50 +08:00
|
|
|
|
if (_rotateTrans != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans.transform.DOKill();
|
|
|
|
|
|
_rotateTrans.transform.rotation = Quaternion.Euler(0, 0, 0);
|
|
|
|
|
|
_rotateTrans.GetChild(0).localPosition = cameraPos;
|
2025-01-16 15:00:19 +08:00
|
|
|
|
zoomScale = 0f;
|
2025-01-15 17:25:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-19 16:52:49 +08:00
|
|
|
|
AudioManager.Instance.StopSoundById(AudioID);
|
2024-12-16 13:20:15 +08:00
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.VehecleUpgrade, OnVehicleInfoUpdate);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-18 12:44:30 +08:00
|
|
|
|
public override UniTask<bool> OnBack(object data = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
CommonUtils.ChangeUIScene(Framework.Constants.MAIN_SCENE_PATH);
|
|
|
|
|
|
CloseWindow();
|
|
|
|
|
|
UIManager.Instance.ShowAllUI();
|
|
|
|
|
|
return base.OnBack(data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
GameObject vRoot = null;//载具根节点
|
|
|
|
|
|
Transform _rotateTrans;//旋转镜头的Transform
|
2024-12-12 19:11:59 +08:00
|
|
|
|
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;
|
2025-01-20 14:10:53 +08:00
|
|
|
|
if (vRoot.transform.childCount > 0)//载具根节点下有子物体,说明已经加载过了,清空
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-20 14:10:53 +08:00
|
|
|
|
else//无需清理
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (_vehicleGo != null)
|
|
|
|
|
|
SetVehicleRoot();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (go.name.Equals("Rotate_Axis"))
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans = go.transform;
|
2025-01-15 17:25:50 +08:00
|
|
|
|
cameraPos = _rotateTrans.GetChild(0).transform.localPosition;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-16 13:20:15 +08:00
|
|
|
|
void OnVehicleInfoUpdate()
|
|
|
|
|
|
{
|
|
|
|
|
|
LoadVehicleList();
|
2024-12-17 15:00:40 +08:00
|
|
|
|
VehicleInfoRefresh();
|
2024-12-16 13:20:15 +08:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.Log("mCurVehicles.Count = 0,载具数量为0将隐藏载具界面");
|
2024-12-12 19:11:59 +08:00
|
|
|
|
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);
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//#region 等级
|
2024-12-12 19:11:59 +08:00
|
|
|
|
//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
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
#region 属性
|
2024-12-19 15:25:35 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
#region 适应性
|
2024-12-12 19:11:59 +08:00
|
|
|
|
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
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
#region 技能
|
2024-12-12 19:11:59 +08:00
|
|
|
|
DataSkill nowSkillCfg = TableManager.Instance.Tables.SkillConfig.Get(VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID, true));
|
|
|
|
|
|
if (nowSkillCfg == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
nowSkillCfg = TableManager.Instance.Tables.SkillConfig.DataList[0];
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError("载具技能配置未能找到!载具ID为{0},技能ID为{1}\n>>请检查相关配置表:VehicleSkllUpgrade/SkillConfig_Vehicle", curShownVehicleData.Cfg.ID, VehicleDataHelper.GetVehicleSkillId(curShownVehicleData.Cfg.ID));
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-30 12:23:00 +08:00
|
|
|
|
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;
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//Text_Class_Value.text = CommonUtils.GetRomanCode((int)curShownVehicleData.SumBonus(BonusType.SkillLv) + 1);//未强化时等级为1
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
|
|
|
|
|
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;
|
2025-01-20 14:10:53 +08:00
|
|
|
|
if (_assetsLoadDic.ContainsKey(prefabPath))//已经加载过
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
go = _assetsLoadDic[prefabPath];
|
2024-12-26 15:48:33 +08:00
|
|
|
|
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-02-13 14:12:23 +08:00
|
|
|
|
var prefab = await AssetManager.Instance.LoadAssetAsync<GameObject>(prefabPath);
|
|
|
|
|
|
if(!prefab)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError("载具模型加载失败!载具ID为{0}", id);
|
2024-12-26 15:48:33 +08:00
|
|
|
|
return;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
2025-02-13 14:12:23 +08:00
|
|
|
|
go = Instantiate(prefab);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
// 加载炮台部分
|
|
|
|
|
|
// 找到炮台挂点
|
2024-12-12 19:11:59 +08:00
|
|
|
|
var allTrans = go.GetComponentsInChildren<Transform>();
|
|
|
|
|
|
var pointName = "Battery_point01";
|
|
|
|
|
|
var fireTrans = allTrans.First(t => t.name == pointName);
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//加载炮台模型
|
2025-02-08 19:09:29 +08:00
|
|
|
|
var curShownVehicleData = VehicleCultivateDataManager.Instance.GetVehicleCultivateData(id);
|
|
|
|
|
|
var rawConfig = TableManager.Instance.Tables.BatteryConfig.GetOrDefault(curShownVehicleData.WeaponId());
|
2025-03-19 17:08:57 +08:00
|
|
|
|
if (rawConfig == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("载具炮台配置为空: " + curShownVehicleData.WeaponId());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-12-12 19:11:59 +08:00
|
|
|
|
var batteryPath = PathEx.GetBatteryModelPath(rawConfig.ModelPath);
|
|
|
|
|
|
var sampleObj = await AssetManager.Instance.LoadAssetAsync<GameObject>(batteryPath);
|
|
|
|
|
|
if (sampleObj != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sampleObj.SetLayerEx(LayerDefine.UIView);
|
|
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//安装炮台
|
2024-12-12 19:11:59 +08:00
|
|
|
|
var rootObj = UnityEngine.Object.Instantiate(sampleObj, fireTrans);
|
|
|
|
|
|
rootObj.transform.ResetLocals();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError("加载炮台失败: {0}", batteryPath);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//设置涂装
|
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
|
|
|
|
|
2025-01-20 14:10:53 +08:00
|
|
|
|
//加载涂装材质球
|
|
|
|
|
|
var material = await CommonUtils.GetVehiclePaintMaterial(paintPath);//临时方法
|
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
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError("载具涂装配置为空!");
|
2024-12-25 12:40:51 +08:00
|
|
|
|
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
2024-12-26 15:48:33 +08:00
|
|
|
|
|
|
|
|
|
|
if (_vehicleGo != null)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
2024-12-26 15:48:33 +08:00
|
|
|
|
_vehicleGo.SetActive(false);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
2024-12-26 15:48:33 +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
|
|
|
|
|
|
{
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError(id + "载具数据为空!");
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.LogError("载具数据未找到!载具ID为{0}", id);
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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;
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.Log("载具已挂载到vRoot");
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-20 14:10:53 +08:00
|
|
|
|
DebugUtil.Log("vRoot尚未加载");
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2025-01-16 15:00:19 +08:00
|
|
|
|
void ShowUI(bool show)
|
2024-12-18 19:58:14 +08:00
|
|
|
|
{
|
|
|
|
|
|
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);
|
2025-01-16 15:00:19 +08:00
|
|
|
|
|
|
|
|
|
|
ControllInput(!show);
|
2024-12-18 19:58:14 +08:00
|
|
|
|
}
|
2024-12-11 11:16:11 +08:00
|
|
|
|
#region Button Click Event
|
2025-03-25 19:15:55 +08:00
|
|
|
|
public async void OnButton_backClick()
|
2024-12-18 19:58:14 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (m_isVehicleUIShow)
|
|
|
|
|
|
{
|
2025-03-25 19:29:50 +08:00
|
|
|
|
CommonUtils.BackToHome();
|
2024-12-18 19:58:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-01-16 15:00:19 +08:00
|
|
|
|
if (_rotateTrans != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans.transform.DOKill();
|
|
|
|
|
|
_rotateTrans.transform.rotation = Quaternion.Euler(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
_rotateTrans.GetChild(0).localPosition = cameraPos;
|
|
|
|
|
|
zoomScale = 0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
ShowUI(true);
|
2024-12-18 19:58:14 +08:00
|
|
|
|
}
|
2025-03-20 19:34:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (isEditTeam)
|
|
|
|
|
|
{
|
|
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.TeamReloadModel);
|
|
|
|
|
|
}
|
2024-12-11 11:16:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-25 19:15:55 +08:00
|
|
|
|
public async void OnButton_HomeClick()
|
2024-12-25 12:40:51 +08:00
|
|
|
|
{
|
2025-03-25 19:29:50 +08:00
|
|
|
|
CommonUtils.BackToHome();
|
2024-12-11 11:16:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
{
|
2025-01-15 17:25:50 +08:00
|
|
|
|
//_rotateTrans.transform.DOMove(new Vector3(55, 0, 20), 0.3f);
|
2025-01-16 15:00:19 +08:00
|
|
|
|
//_rotateTrans.transform.DORotate(new Vector3(0, 0, 0), 0.3f);
|
2025-01-15 17:25:50 +08:00
|
|
|
|
|
|
|
|
|
|
var camera = _rotateTrans.GetChild(0);
|
2025-01-20 14:10:53 +08:00
|
|
|
|
var cameraNextPos = cameraPos + _rotateTrans.InverseTransformDirection(camera.transform.right) * 2;//将世界坐标系向量转换为局部坐标系内的向量
|
2025-01-16 15:00:19 +08:00
|
|
|
|
camera.transform.DOLocalMove(cameraNextPos, 0.25f);
|
2025-01-15 17:25:50 +08:00
|
|
|
|
|
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;
|
|
|
|
|
|
|
2024-12-16 13:20:15 +08:00
|
|
|
|
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)
|
2024-12-16 13:20:15 +08:00
|
|
|
|
{
|
|
|
|
|
|
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
|
|
|
|
}
|
2024-12-16 13:20:15 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-01-20 14:10:53 +08:00
|
|
|
|
/// 滑动列表Item点击
|
2024-12-16 13:20:15 +08:00
|
|
|
|
/// </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
|
|
|
|
|
|
private void ControllInput(bool isRegister)
|
|
|
|
|
|
{
|
2025-03-18 17:30:49 +08:00
|
|
|
|
if (_inputInterpreter != null)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
2025-03-18 17:30:49 +08:00
|
|
|
|
_inputInterpreter.enabled = isRegister;
|
2024-12-12 19:11:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-13 17:03:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnPointerDown(Vector2 screenPosition)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnPointerUp(Vector2 screenPosition)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnPressMove(Vector2 delta)
|
2024-12-12 19:11:59 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (delta == Vector2.zero) return;
|
|
|
|
|
|
if (_rotateTrans != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_rotateTrans.Rotate(Vector3.up, .3f * delta.x);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("Rotate_Axis is null");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-01-16 15:00:19 +08:00
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnTap(Vector2 screenPosition)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnLongPress(Vector2 screenPosition)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 14:44:19 +08:00
|
|
|
|
public void OnLongPressUp(Vector2 screenPosition)
|
2025-03-13 17:03:44 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-16 15:00:19 +08:00
|
|
|
|
float scaleStep = 0.1f;
|
|
|
|
|
|
float maxScale = .9f;
|
|
|
|
|
|
float minScale = -.9f;
|
|
|
|
|
|
|
|
|
|
|
|
float zoomScale = 0f;
|
2025-03-13 17:03:44 +08:00
|
|
|
|
public void OnZoom(float delta)
|
2025-01-16 15:00:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
var camera = _rotateTrans.GetChild(0);
|
|
|
|
|
|
var stepvalue = 0f;
|
|
|
|
|
|
|
|
|
|
|
|
if (delta > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (zoomScale >= maxScale)
|
|
|
|
|
|
{
|
|
|
|
|
|
zoomScale = maxScale;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
stepvalue = scaleStep;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (zoomScale <= minScale)
|
|
|
|
|
|
{
|
|
|
|
|
|
zoomScale = minScale;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
stepvalue = -scaleStep;
|
|
|
|
|
|
}
|
|
|
|
|
|
zoomScale += stepvalue;
|
2025-01-20 14:10:53 +08:00
|
|
|
|
camera.transform.localPosition += _rotateTrans.InverseTransformDirection(camera.transform.forward) * stepvalue;//将世界坐标系向量转换为局部坐标系内的向量
|
2025-03-13 17:03:44 +08:00
|
|
|
|
|
2025-01-16 15:00:19 +08:00
|
|
|
|
}
|
2024-12-09 17:02:39 +08:00
|
|
|
|
}
|