AirControl  1.3.0
Open Source, Modular, and Extensible Flight Simulator For Deep Learning Research
AC_Airplane_FuelGauge.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using Commons;
5 namespace AirControl
6 {
10  public class AC_Airplane_FuelGauge : MonoBehaviour, IAirplaneUI
11  {
12  #region Variables
13  [Header("Fuel Guage Properties")]
14  [SerializeField]
15  private AC_Airplane_Fuel fuel;
16  public RectTransform pointer;
17  public Vector2 minMaxRotation = new Vector2(-90f, 90f);
18  #endregion
19 
20  #region Builtin methods
21  void Start(){
22  fuel = GameObject.Find(CommonFunctions.ActiveAirplane).GetComponent<AC_Airplane_Fuel>();
23  }
24  #endregion
25 
26  #region Custom Methods
27  public void HandleAirplaneUI()
31  {
32  if(fuel && pointer)
33  {
34  float wantedRotation = Mathf.Lerp(minMaxRotation.x, minMaxRotation.y, fuel.NormalizedFuel);
35  pointer.rotation = Quaternion.Euler(0f, 0f, -wantedRotation);
36  }
37  }
38  #endregion
39 
40  }
41 }
AirControl.IAirplaneUI
Definition: IAirplaneUI.cs:8
AirControl.AC_Airplane_FuelGauge.HandleAirplaneUI
void HandleAirplaneUI()
Updates to UI
Definition: AC_Airplane_FuelGauge.cs:30
AirControl
Definition: AirplaneSelector.cs:8
AirControl.AC_Airplane_Fuel
Control fuel consumption
Definition: AC_Airplane_Fuel.cs:12
Commons
Definition: AirplaneProperties.cs:14
AirControl.AC_Airplane_FuelGauge
Monitor and updates the Fuel level to UI
Definition: AC_Airplane_FuelGauge.cs:10