From db1b1fc364b73af26054ea577fd9ea77c267a03b Mon Sep 17 00:00:00 2001 From: _sega Date: Thu, 19 Feb 2026 10:21:06 +0300 Subject: [PATCH] =?UTF-8?q?REFACTOR:=20=D0=A0=D0=B0=D0=B7=D0=B2=D1=8F?= =?UTF-8?q?=D0=B7=D0=B0=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D1=81=D0=B2=D0=B5=D1=82=D0=BA=D0=B8=20=D0=B8=20Com?= =?UTF-8?q?Wrapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Inputs/ComSystem/ComWrapper.cs | 34 +---------- Assets/Scripts/LightUtility.cs | 60 +++++++++++++++---- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs b/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs index 869d00e..160df7f 100644 --- a/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs +++ b/Assets/Scripts/Inputs/ComSystem/ComWrapper.cs @@ -52,13 +52,6 @@ public class ComWrapper : MonoBehaviour onInputRecieved?.AddListener(InputRecievedCather); StartCoroutine(SetupBoard()); - - - } - - private void send_port_pin_message(int pin) - { - } public static void AddCredit() @@ -111,17 +104,7 @@ public class ComWrapper : MonoBehaviour } catch { Debug.LogError("Ошибка отправки строкового сигнала."); } - } - - public static void Send(LightMode lightMode) - { - try - { - string signal = LightUtility.GetLightString(lightMode); - Send(signal); - } - catch { Debug.LogError("Ошибка отправки светового сигнала."); } - } + } public static bool Pay(int amount) @@ -506,18 +489,3 @@ public class ComWrapper : MonoBehaviour } -public enum LightMode -{ - Idle1, - Idle2, - Orange, - Blue, - Win, - Lose, - Prize, - Toaster, - Tama, - Dog, - Sam, - Mistress -} \ No newline at end of file diff --git a/Assets/Scripts/LightUtility.cs b/Assets/Scripts/LightUtility.cs index 3ca4e78..49dbb95 100644 --- a/Assets/Scripts/LightUtility.cs +++ b/Assets/Scripts/LightUtility.cs @@ -2,34 +2,35 @@ public static class LightUtility { + private const string LIGHT_COMMAND_PREFIX = "80"; public static void Idle() { if (Random.Range(0, 2) == 0) - ComWrapper.Send(LightMode.Idle1); + SendLightCommandToCom(LightMode.Idle1); else - ComWrapper.Send(LightMode.Idle2); + SendLightCommandToCom(LightMode.Idle2); } public static void Win() { - ComWrapper.Send(LightMode.Win); + SendLightCommandToCom(LightMode.Win); } public static void Lose() { - ComWrapper.Send(LightMode.Lose); + SendLightCommandToCom(LightMode.Lose); } public static void Player(CellState currentPlayer) { if (currentPlayer == CellState.Player1) - ComWrapper.Send(LightMode.Orange); + SendLightCommandToCom(LightMode.Orange); else - ComWrapper.Send(LightMode.Blue); + SendLightCommandToCom(LightMode.Blue); } public static void Prize() { - ComWrapper.Send(LightMode.Prize); + SendLightCommandToCom(LightMode.Prize); } public static void Character(Character currentCharacter) @@ -49,15 +50,37 @@ public static class LightUtility _ => LightMode.Idle2 }; - ComWrapper.Send(lightMode); + SendLightCommandToCom(lightMode); } public static void Promo() { - string[] signals = { "80521", "80523", "80524" }; + string[] signals = { "521", "523", "524" }; string signal = signals[Random.Range(0, signals.Length)]; - ComWrapper.Send(signal); + SendLightCommandToCom(signal); + } + + public static void SendLightCommandToCom(LightMode lightMode) + { + try + { + string signal = GetLightString(lightMode); + ComWrapper.Send(signal); + } + catch { Debug.LogError("Ошибка отправки светового сигнала."); } + } + + /// + /// Принимает сингнал без префикса. В процессе сам его добавляет. + /// + public static void SendLightCommandToCom(string signal) + { + try + { + ComWrapper.Send(LIGHT_COMMAND_PREFIX + signal); + } + catch { Debug.LogError("Ошибка отправки светового сигнала."); } } @@ -117,9 +140,24 @@ public static class LightUtility } - return "80" + lightsingal; + return LIGHT_COMMAND_PREFIX + lightsingal; } } +public enum LightMode +{ + Idle1, + Idle2, + Orange, + Blue, + Win, + Lose, + Prize, + Toaster, + Tama, + Dog, + Sam, + Mistress +} \ No newline at end of file