70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using UnityEngine;
|
||
|
||
namespace Lights
|
||
{
|
||
public static class LightSystem
|
||
{
|
||
private static bool initialized = false;
|
||
private static LightConfig config;
|
||
|
||
public static void Init()
|
||
{
|
||
if (initialized) return;
|
||
|
||
config = new LightConfig();
|
||
|
||
initialized = true;
|
||
}
|
||
|
||
public static void SetLightActive(bool value)
|
||
{
|
||
var command = value ? "8501" : "8500";
|
||
ComPortController.Send(command);
|
||
}
|
||
|
||
public static void SetLight(LightMode mode)
|
||
{
|
||
|
||
}
|
||
|
||
public static void SetIndicator(Indiсator indiсator, float percent)
|
||
{
|
||
string command = indiсator switch
|
||
{
|
||
Indiсator.TorpedoAmmo => "8531",
|
||
Indiсator.Life => "8532",
|
||
Indiсator.MissileAmmo => "8533",
|
||
_ => "8532"
|
||
};
|
||
|
||
int diodesCount = 22;
|
||
int diodesToLight = (int)(diodesCount * percent);
|
||
|
||
ComPortController.Send(command + diodesToLight);
|
||
}
|
||
|
||
public static void SetAllIndicators(float percent)
|
||
{
|
||
SetIndicator(Indiсator.MissileAmmo, percent);
|
||
SetIndicator(Indiсator.TorpedoAmmo, percent);
|
||
SetIndicator(Indiсator.Life, percent);
|
||
}
|
||
}
|
||
|
||
public class LightConfig
|
||
{
|
||
|
||
}
|
||
|
||
public enum LightMode
|
||
{
|
||
Idle
|
||
}
|
||
|
||
public enum Indiсator
|
||
{
|
||
Life,
|
||
TorpedoAmmo,
|
||
MissileAmmo
|
||
}
|
||
} |