47 lines
1.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Lights
{
public static class LightSystem
{
public static void SetLightActive(bool value)
{
var command = value ? "8501" : "8500";
ComPortController.Send(command);
}
public static void Ef_Start() => ComPortController.Send("8540");
public static void Ef_End() => ComPortController.Send("8541");
public static void Ef_Hit() => ComPortController.Send("8542");
public static void Ef_Shoot() => ComPortController.Send("8543");
public static void Ef_Alarm() => ComPortController.Send("8548");
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 enum Indiсator
{
Life,
TorpedoAmmo,
MissileAmmo
}
}