更新PerformanceAdjusting
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UIFramework;
using System;
//using DG.Tweening;
//using UniRx;
using OpenCover.Framework.Model;
using System.Linq;
public class PerformanceAdjusting : MonoBehaviour
{
///
/// 性能调节 前后轴输出功率Toggle
///
[SerializeField] private List<Toggle> _FrontRearAxleOutputPowerToggles;
///
/// 性能调节 前后轴输出功率TextMeshProUGUI
///
[SerializeField] private List<Text> _FrontRearAxleOutputPowerTxts;
/// <summary>
/// 性能调节 动力响应Toggle
/// </summary>
[SerializeField] private List<Toggle> _DynamicResponseToggles;
/// <summary>
/// 性能调节 动力响应TextMeshProUGUI
/// </summary>
[SerializeField]
private List<Text> _DynamicResponseTxts;
/// <summary>
/// 性能调节 制动反馈Toggle
/// </summary>
[SerializeField] private List<Toggle> _BrakeFeedbackToggles;
/// <summary>
/// 性能调节 制动反馈TextMeshProUGUI
/// </summary>
[SerializeField]
private List<Text> _BrakeFeedbackTxts;
/ <summary>
/ 性能调节 转向手感Toggle
/ </summary>
//[SerializeField] private List<Toggle> _SteeringFeelToggles;
/ <summary>
/ 性能调节 转向手感TextMeshProUGUI
/ </summary>
//[SerializeField]
//private List<TextMeshProUGUI> _SteeringFeelTxts;
/ <summary>
/ 性能调节 悬架阻尼Toggle
/ </summary>
//[SerializeField] private List<Toggle> _SuspensionDampingToggles;
/ <summary>
/ 性能调节 悬架阻尼TextMeshProUGUI
/ </summary>
//[SerializeField]
//private List<TextMeshProUGUI> _SuspensionDampingTxts;
/ <summary>
/ 性能调节 车身稳定系统Toggle
/ </summary>
//[SerializeField] private List<Toggle> _BodyStabilizationSystemToggles;
/ <summary>
/ 性能调节 车身稳定系统TextMeshProUGUI
/ </summary>
//[SerializeField]
//private List<TextMeshProUGUI> _BodyStabilizationSystemTxts;
/ <summary>
/ 性能调节 能量回收系统Toggle
/ </summary>
//[SerializeField] private List<Toggle> _EnergyRecoverySystemsToggles;
/ <summary>
/ 性能调节 能量回收系统TextMeshProUGUI
/ </summary>
//[SerializeField]
//private List<TextMeshProUGUI> _EnergyRecoverySystemsTxts;
/ <summary>
/ 性能调节 超强冷却系统Toggle
/ </summary>
//[SerializeField] private List<Toggle> _SuperCoolingSystemToggles;
/ <summary>
/ 性能调节 超强冷却系统TextMeshProUGUI
/ </summary>
//[SerializeField]
//private List<TextMeshProUGUI> _SuperCoolingSystemTxts;
private ToggleController _FrontRearAxleOutputPowerController;
private ToggleController _DynamicResponseController;
//private ToggleController _BrakeFeedbackController;
//private ToggleController _SteeringFeelController;
//private ToggleController _SuspensionDampingController;
//private ToggleController _BodyStabilizationSystemController;
//private ToggleController _EnergyRecoverySystemsController;
//private ToggleController _SuperCoolingSystemController;
//private TextMeshProUGUI _FrontRearAxleOutputPowerTxt;
//private TextMeshProUGUI _DynamicResponseTxts;
//private TextMeshProUGUI _BrakeFeedbackTxts;
//private TextMeshProUGUI _SteeringFeelTxts;
//private TextMeshProUGUI _SuspensionDampingTxts;
//private TextMeshProUGUI _BodyStabilizationSystemTxts;
//private TextMeshProUGUI _EnergyRecoverySystemsTxts;
//private TextMeshProUGUI _SuperCoolingSystemTxts;
public enum ToggleID
{
Toggle_0,
Toggle_1,
Toggle_2,
Toggle_3,
Toggle_4,
Toggle_5,
Toggle_6,
Toggle_7,
Toggle_8,
Toggle_9,
Toggle_10
}
public Dictionary<SignalEnum, Dictionary<ToggleID, int>> toggleMapping;
public class SuperSportNative
{
public static void SetInt(int id, int param)
{
Debug.Log("id:" + id + "param:" + param);
}
}
/// <summary>
/// GET 获得参数的值
/// 使用批量处理接口。目前 Get 接口的存略是获得 Native 对各个信号参数对应值的缓存。
/// </summary>
/// <param name="ids">因为 id 代表一个信号参数,ids 代表 Unity 想要获得的多个信号参数的值。</param>
/// <param name="len">是 ids 数组中元素的个数。</param>
/// <returns></returns>
//[DllImport("libsnake_native.so", EntryPoint = "Get", CallingConvention = CallingConvention.Cdecl)]
// private static extern UnityCallbackProtocol get(int[] ids, int len);
// public static UnityCallbackProtocol Get(int[] ids, int len)
// {
//#if UNITY_EDITOR
// return new UnityCallbackProtocol();
//#else
//return get(ids, len);
//#endif
// }
/// <summary>
/// SET 设置参数的值
/// Set 设置某一个信号参数的值。提供了参数的值是整形和字符创类型的接口。
/// </summary>
/// <param name="id">id 代表一个信号参数。id 具体代表哪个信号取决于信号映射表中的配置情况。</param>
/// <param name="param">信号参数的整形值。</param>
/// <returns>bool false set 失败,true set 成功。</returns>
//[DllImport("libsnake_native.so", EntryPoint = "SetInt", CallingConvention = CallingConvention.Cdecl)]
// private static extern bool setInt(int id, int param);
// public static bool SetInt(int id, int param)
// {
// Debug.Log("id:" + id + "param:" + param);
//#if UNITY_EDITOR
// return true;
//#else
//return setInt(id, param);
//#endif
// }
private void Awake()
{
}
private void Start()
{
_FrontRearAxleOutputPowerController = new ToggleController(SignalEnum.performanceadjusting_frontrearaxleoutputpower,
_FrontRearAxleOutputPowerToggles, _FrontRearAxleOutputPowerTxts, HandleAxleOutputText);
_DynamicResponseController = new ToggleController(SignalEnum.performanceadjusting_dynamicresponse,
_DynamicResponseToggles, _DynamicResponseTxts, HandleToggleText);
//_BrakeFeedbackController = new ToggleController(_BrakeFeedbackToggles);
//_SteeringFeelController = new ToggleController(_SteeringFeelToggles);
//_SuspensionDampingController = new ToggleController(_SuspensionDampingToggles);
//_BodyStabilizationSystemController = new ToggleController(_BodyStabilizationSystemToggles);
//_EnergyRecoverySystemsController = new ToggleController(_EnergyRecoverySystemsToggles);
//_SuperCoolingSystemController = new ToggleController(_SuperCoolingSystemToggles);
//GetToggleControllerCurrentIndex();
//_FrontRearAxleOutputPowerController.AddListener(SignalEnum.performanceadjusting_frontrearaxleoutputpower);
//_DynamicResponseController.AddListener(SignalEnum.performanceadjusting_dynamicresponse);
//_BrakeFeedbackController.AddListener(SignalEnum.performanceadjusting_brakefeedback, _BrakeFeedbackTxts);
//_SteeringFeelController.AddListener(SignalEnum.performanceadjusting_steeringfeel, _SteeringFeelTxts);
//_SuspensionDampingController.AddListener(SignalEnum.performanceadjusting_suspensiondamping, _SuspensionDampingTxts);
//_BodyStabilizationSystemController.AddListener(SignalEnum.performanceadjusting_esp, _BodyStabilizationSystemTxts);
//_EnergyRecoverySystemsController.AddListener(SignalEnum.performanceadjusting_energyrecoverysystems, _EnergyRecoverySystemsTxts);
//_SuperCoolingSystemController.AddListener(SignalEnum.performanceadjusting_supercoolingsystem, _SuperCoolingSystemTxts);
}
//private void GetToggleControllerCurrentIndex()
//{
// // 获取 TBD
// // 比如拿到了_FrontRearAxleOutputPowerController的当前index
// _FrontRearAxleOutputPowerController.SetCurrentIndex(2);
// _DynamicResponseController.SetCurrentIndex(0);
//}
private void HandleAxleOutputText(int index, List<Text> texts)
{
int front = index * 10;
int rear = 100 - front;
string text = front.ToString() + " / " + rear.ToString();
texts[0].text = text;
}
private void HandleToggleText(int index, List<Text> texts)
{
foreach (Text txt in texts)
{
txt.fontSize = 22;
txt.color = new Color32(255, 255, 255, 128);
}
texts[index].fontSize = 28;
texts[index].color = new Color32(255, 255, 255, 255);
}