using UnityEngine;
// Sci-Fi Ship Controller. Copyright (c) 2018-2023 SCSM Pty Ltd. All rights reserved.
namespace SciFiShipController
{
///
/// Sample code to show Health of a ship in the UI.
/// This is only a sample to demonstrate how API calls could be used in your own code.
/// Add this to an empty gameobject in the scene and drag a ship from the scene into
/// the shipControlModule slot.
///
[AddComponentMenu("Sci-Fi Ship Controller/Samples/Show Ship Health")]
[HelpURL("http://scsmmedia.com/ssc-documentation")]
public class SampleShowShipHealth : MonoBehaviour
{
#region Public variables
///
/// If true, will run just before first frame is rendered. Set to false if
/// you wish to add a reference to the ship from the scene at runtime.
///
public bool initialiseOnAwake = false;
public bool isHealthDisplayed = false;
public ShipControlModule shipControlModule = null;
public Color normalColour = Color.white;
public Color warningColour = Color.yellow;
public Color criticalColour = Color.red;
#endregion
#region Private variables
private bool isInitialised = false;
private Canvas canvas;
private UnityEngine.UI.Text uiTextHealthLabel;
private UnityEngine.UI.Text uiTextHealthValue;
private UnityEngine.UI.Text uiTextShieldLabel;
private UnityEngine.UI.Text uiTextShieldValue;
private float healthStartValue = 0f;
private float shieldStartValue = 0f;
#endregion
#region Initialisation Methods
void Start()
{
if (!isInitialised && initialiseOnAwake) { Initialise(); }
}
public void Initialise()
{
if (isHealthDisplayed)
{
// Add a new canvas
canvas = GetComponent