From 16b02e828a957f9d65b22f1aa91fbda42dd365ca Mon Sep 17 00:00:00 2001 From: se_ga Date: Fri, 20 Mar 2026 13:32:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20=D0=B3=D0=BB?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BC=D0=B5=D0=BD=D1=8E?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B2=D1=8F=D0=B7=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B2=20UiManager;=20DifficultyManager=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=20=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1?= =?UTF-8?q?=20=D0=B8=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D1=81=D0=B8=D0=BD=D0=B3=D0=BB=D1=82=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Fonts/NEW/NexaRegular COOL.asset | 2 +- Assets/Scenes/GameScene3D.unity | 51 ++++++++++++- Assets/Scripts/Core/GameManager.cs | 85 +++++++++++---------- Assets/Scripts/Core/UiManager.cs | 32 ++++++++ Assets/Scripts/Core/UiManager.cs.meta | 11 +++ Assets/Scripts/DifficultyManager.cs | 28 +++++-- Assets/Scripts/GameFSM/FieldCleaner.cs | 2 +- Assets/Scripts/GameFSM/MenuState.cs | 16 ++-- Assets/Scripts/GameFSM/StartRoundState.cs | 2 +- Assets/Scripts/Gameplay/EndOfTurnHandler.cs | 36 ++++----- 10 files changed, 189 insertions(+), 76 deletions(-) create mode 100644 Assets/Scripts/Core/UiManager.cs create mode 100644 Assets/Scripts/Core/UiManager.cs.meta diff --git a/Assets/Fonts/NEW/NexaRegular COOL.asset b/Assets/Fonts/NEW/NexaRegular COOL.asset index 3429684..03eea19 100644 --- a/Assets/Fonts/NEW/NexaRegular COOL.asset +++ b/Assets/Fonts/NEW/NexaRegular COOL.asset @@ -11349,7 +11349,7 @@ Material: - _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767} - _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0} - _FaceColor: {r: 1, g: 1, b: 1, a: 1} - - _GlowColor: {r: 1, g: 0.77535063, b: 0, a: 1} + - _GlowColor: {r: 1, g: 0.0684407, b: 0, a: 1} - _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767} - _OutlineColor: {r: 0.554717, g: 0.554717, b: 0.554717, a: 1} - _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Scenes/GameScene3D.unity b/Assets/Scenes/GameScene3D.unity index 6979ebe..44016b4 100644 --- a/Assets/Scenes/GameScene3D.unity +++ b/Assets/Scenes/GameScene3D.unity @@ -3670,6 +3670,54 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 157258767} m_CullTransparentMesh: 1 +--- !u!1 &163302437 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 163302439} + - component: {fileID: 163302438} + m_Layer: 0 + m_Name: UiManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &163302438 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 163302437} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7b4f42eaa95c3eb4f95825ea27e72fcb, type: 3} + m_Name: + m_EditorClassIdentifier: + UpperMenuGroup: {fileID: 382964715} + PveOption: {fileID: 2047831684} + PvpOption: {fileID: 95872202} + DownMenuGroup: {fileID: 109738548} +--- !u!4 &163302439 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 163302437} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 5.273878, y: -1.551749, z: -0.07899367} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &164597568 GameObject: m_ObjectHideFlags: 0 @@ -24822,9 +24870,9 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 382964715} - {fileID: 2047831684} - {fileID: 95872202} - - {fileID: 382964715} - {fileID: 109738548} m_Father: {fileID: 1122363135} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -72627,6 +72675,7 @@ SceneRoots: m_ObjectHideFlags: 0 m_Roots: - {fileID: 519420032} + - {fileID: 163302439} - {fileID: 829871288} - {fileID: 259182280} - {fileID: 151433695} diff --git a/Assets/Scripts/Core/GameManager.cs b/Assets/Scripts/Core/GameManager.cs index 498688c..fb0e7a5 100644 --- a/Assets/Scripts/Core/GameManager.cs +++ b/Assets/Scripts/Core/GameManager.cs @@ -1,5 +1,4 @@ -using System; -using TMPro; +using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; @@ -8,6 +7,9 @@ using PrizeSystem; public enum GameMode { pve, pvp } public class GameManager : MonoBehaviour { + private const int DEFAULT_FRAME_RATE = 60; + + public int Rows = 7, Cols = 7; public PlayerStatsService StatsService; public bool dummyBots = false; @@ -31,11 +33,7 @@ public class GameManager : MonoBehaviour public bool menuOpened = true; public GameMode gameMode; public Transform - label, - buttonLeft, - buttonRight, coinPanel, - label2, board, noPrizeLabel; public GameObject mainMenu; @@ -130,7 +128,7 @@ public class GameManager : MonoBehaviour if (instance == null) { - Application.targetFrameRate = 60; + Application.targetFrameRate = DEFAULT_FRAME_RATE; instance = this; fieldModel = new FieldModel(Cols, Rows); @@ -138,19 +136,53 @@ public class GameManager : MonoBehaviour } ConfigManager.Initialize(); - UnityMainThreadDispatcher.Initialize(); + InitializePrefs(); SettingsManager.Initialize(); GetComponent().Initialize(); - //Тестируем пока что. Не прод(ну ладно прод.) logger = GetComponent(); + InitializeDevices(); + + + SingleWallet.Initialize(); + ComWrapper.PaymentReceived += ProcessDifficultyCounter; + SettingsManager.OnSettingsChanged.AddListener(ProcessDifficultyCounter); + + soundManager.Initialize(); + GetComponent().Initialize(); + + + vitrinaCatcher.Initialize(); + + ProcessDifficultyCounter(); + + GetComponent().Initialize(); + GetComponent().Initialize(); + GetComponent().Initialize(); + StatsService = new(); + StatsService.Initialize(); + +#if !UNITY_EDITOR + Defender.Instance.StartCoroutine(Defender.Instance.CheckLicenseCoroutine()); + dummyBots = false; +#endif + + StartCoroutine(AddBotRecordEvery2Days());// добавлять каждые 2 дня запись + + avatarController.GetComponent().Initialize(); + avatarController.Initialize(); + + } + + private void InitializeDevices() + { //ИНИЦИАЛИЗАЦИЯ УСТРОЙСТВ var devices = ComPortScanner.ScanPorts(); logger.Log($"Найдено устройств: {devices.Count}"); @@ -199,39 +231,10 @@ public class GameManager : MonoBehaviour else logger.Log("Не Открыл"); PrizeStandController.Initialize(h, 5, logger); } - //рабочая(до витрины) версия - //ComWrapper.Initialize(ComNativeWrapper.ListPorts(), boardVersion); - - - SingleWallet.Initialize(); - ComWrapper.PaymentReceived += ProcessDifficultyCounter; - SettingsManager.OnSettingsChanged.AddListener(ProcessDifficultyCounter); - - soundManager.Initialize(); - GetComponent().Initialize(); - - - vitrinaCatcher.Initialize(); - - ProcessDifficultyCounter(); - - GetComponent().Initialize(); - GetComponent().Initialize(); - GetComponent().Initialize(); - StatsService = new(); - StatsService.Initialize(); - -#if !UNITY_EDITOR - Defender.Instance.StartCoroutine(Defender.Instance.CheckLicenseCoroutine()); - dummyBots = false; -#endif - - StartCoroutine(AddBotRecordEvery2Days());// добавлять каждые 2 дня запись - - avatarController.GetComponent().Initialize(); - avatarController.Initialize(); - } + + + private void OnApplicationQuit() { ComNativeWrapper.Serial_CloseAll(); diff --git a/Assets/Scripts/Core/UiManager.cs b/Assets/Scripts/Core/UiManager.cs new file mode 100644 index 0000000..301f229 --- /dev/null +++ b/Assets/Scripts/Core/UiManager.cs @@ -0,0 +1,32 @@ +using UnityEngine; + +public class UiManager : MonoBehaviour +{ + private static UiManager _instance; + public static UiManager Instance + { + get + { + if (_instance == null) + { + _instance = FindObjectOfType(); + + if (_instance == null) + { + Debug.LogWarning($"Не найден {typeof(UiManager)}"); + } + } + return _instance; + } + } + + + //Ссылки главно меню + public RectTransform UpperMenuGroup; + public RectTransform PveOption; + public RectTransform PvpOption; + public RectTransform DownMenuGroup; + + + +} diff --git a/Assets/Scripts/Core/UiManager.cs.meta b/Assets/Scripts/Core/UiManager.cs.meta new file mode 100644 index 0000000..ef57b7c --- /dev/null +++ b/Assets/Scripts/Core/UiManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7b4f42eaa95c3eb4f95825ea27e72fcb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/DifficultyManager.cs b/Assets/Scripts/DifficultyManager.cs index bb3edd1..5db1202 100644 --- a/Assets/Scripts/DifficultyManager.cs +++ b/Assets/Scripts/DifficultyManager.cs @@ -3,20 +3,32 @@ using UnityEngine.Events; public class DifficultyManager : MonoBehaviour { - public static DifficultyManager instance; - public UnityEvent OnVictory = new UnityEvent(); - public int currentOpponent = 0; - - void Awake() + private static DifficultyManager instance; + public static DifficultyManager Instance { - if (instance == null) + get { - instance = this; - currentOpponent = 0; + if (instance == null) + { + instance = FindObjectOfType(); + + if (instance == null) + { + Debug.LogWarning($"Не найден {typeof(DifficultyManager)}"); + } + else + { + instance.currentOpponent = 0; + } + } + return instance; } } + public UnityEvent OnVictory = new UnityEvent(); + public int currentOpponent = 0; + public DifficultyPreset DifficultyPreset => CharacterController.CurrentCharacter.CurrentDifficultyPreset; public void IncreaseDifficulty() diff --git a/Assets/Scripts/GameFSM/FieldCleaner.cs b/Assets/Scripts/GameFSM/FieldCleaner.cs index 37a3c3b..e04b9b9 100644 --- a/Assets/Scripts/GameFSM/FieldCleaner.cs +++ b/Assets/Scripts/GameFSM/FieldCleaner.cs @@ -48,7 +48,7 @@ public static class FieldCleaner { //Фишка ходит первой если ее не побеждали сегодня еще - bool goingToLastBot = DifficultyManager.instance.currentOpponent == GameManager.instance.botsAmount - 1; + bool goingToLastBot = DifficultyManager.Instance.currentOpponent == GameManager.instance.botsAmount - 1; if (goingToLastBot) { diff --git a/Assets/Scripts/GameFSM/MenuState.cs b/Assets/Scripts/GameFSM/MenuState.cs index 99246ed..36259df 100644 --- a/Assets/Scripts/GameFSM/MenuState.cs +++ b/Assets/Scripts/GameFSM/MenuState.cs @@ -5,6 +5,8 @@ enum MenuSubStates { OpeningMenu, Choosing, Payment, ClosingMenu, SwitchState } public class MenuState : IState { GameManager gm; + UiManager ui; + float SecondsToPromo = 180; float ElapsedPromoTimer; @@ -82,11 +84,15 @@ public class MenuState : IState private void PullRefs() { gm = GameManager.instance; - label = gm.label; - buttonLeft = gm.buttonLeft; - buttonRight = gm.buttonRight; + ui = UiManager.Instance; + + + label = ui.UpperMenuGroup; + buttonLeft = ui.PveOption; + buttonRight = ui.PvpOption; + label2 = ui.DownMenuGroup; + coinPanel = gm.coinPanel; - label2 = gm.label2; board = gm.board; noPrizeLabel = gm.noPrizeLabel; SmallPrizesOut = gm.smallPrizesOut; @@ -102,7 +108,7 @@ public class MenuState : IState CharacterController.I.SetAllCharactersPrizeAvailable(true); DualAvatarController.Instance.HideCharacters(); - DifficultyManager.instance.ResetDifficulty(); + DifficultyManager.Instance.ResetDifficulty(); gm.player1score = 0; gm.player2score = 0; diff --git a/Assets/Scripts/GameFSM/StartRoundState.cs b/Assets/Scripts/GameFSM/StartRoundState.cs index 1064251..dca6a40 100644 --- a/Assets/Scripts/GameFSM/StartRoundState.cs +++ b/Assets/Scripts/GameFSM/StartRoundState.cs @@ -20,7 +20,7 @@ public class StartRoundState : IState if (gm.gameMode == GameMode.pve) gm.timerManager.SetActiveTimer(CellState.Player1);//если деремся с ботом, держим таймер включенным - int difficultyIndex = DifficultyManager.instance.currentOpponent; + int difficultyIndex = DifficultyManager.Instance.currentOpponent; if (gm.gameMode == GameMode.pve) { CharacterController.SwitchToCharacter(difficultyIndex); diff --git a/Assets/Scripts/Gameplay/EndOfTurnHandler.cs b/Assets/Scripts/Gameplay/EndOfTurnHandler.cs index eb44ea5..9384a08 100644 --- a/Assets/Scripts/Gameplay/EndOfTurnHandler.cs +++ b/Assets/Scripts/Gameplay/EndOfTurnHandler.cs @@ -1,4 +1,4 @@ -using PrizeSystem; +using PrizeSystem; using UnityEngine; public static class EndOfTurnHandler @@ -13,7 +13,7 @@ public static class EndOfTurnHandler bool wrapToPrizeState = false; - IState nextState = new ShowWinnerState(result);//âðåìåííî + IState nextState = new ShowWinnerState(result);//временно if (result.End) { @@ -23,18 +23,18 @@ public static class EndOfTurnHandler { PvpEndroundHandler(); } - else if (gm.gameMode == GameMode.pve) //êîíåö ðàóíäà ñ áîòîì + else if (gm.gameMode == GameMode.pve) //конец раунда с ботом { PveEndroundHandler(); if (gm.currentPlayer == CellState.Player1) - {//àâòîïåðåõîä íà íåêñò áîòà. + {//автопереход на некст бота. wrapToPrizeState = true; nextState = CreateAutoTransitionState(result, 4); } } if (TotalWin()) - {//êîíåö èãðû - ïðèçîâîå ñîñòîÿíèå + {//конец игры - призовое состояние nextState = new VictoryState(); ClearAllScales(); } @@ -63,13 +63,13 @@ public static class EndOfTurnHandler { PlayerWinHandler(); } - else//Áîò ïîáåäèë + else//Бот победил { BotWinHandler(); } gm.botScale.SetMedalsCount(gm.vsBotScore); - //åñëè ôèøêó ïîáåäèëè, òî ïîâûøàåì. + //если фишку победили, то повышаем. if (gm.vsBotScore == gm.botsAmount) gm.upgradeFeeshkaDifficulty(); } @@ -87,7 +87,7 @@ public static class EndOfTurnHandler { LightUtility.Lose(); CharacterController.CurrentCharacter.GetComponent().SetTrigger("Win"); - DifficultyManager.instance.DecreaseDifficulty(); + DifficultyManager.Instance.DecreaseDifficulty(); if (gm.vsBotScore != 0) gm.vsBotScore -= 1; @@ -101,7 +101,7 @@ public static class EndOfTurnHandler CharacterController.CurrentCharacter.HasPrize = false; } - DifficultyManager.instance.IncreaseDifficulty(); + DifficultyManager.Instance.IncreaseDifficulty(); gm.vsBotScore += 1; CharacterEventBus.Instance.OnPlayerWin?.Invoke(); @@ -128,9 +128,9 @@ public static class EndOfTurnHandler public static void WinByTimerHandling() { - //Ïðè ïîáåäå ïî òàéìåðó: - //PVP ïðîèãðàë òîò, êòî íå óñïåë êèíóòü ôèøêó - //PVE - ïðîãðûâàåò ÷åëîâåê + //При победе по таймеру: + //PVP проиграл тот, кто не успел кинуть фишку + //PVE - прогрывает человек result = new CheckResult(true, false, null); @@ -138,26 +138,26 @@ public static class EndOfTurnHandler if (gm.gameMode == GameMode.pvp) { - //p2 íå óñïåë + //p2 не успел if (gm.currentPlayer == CellState.Player2) { gm.player1score += 1; gm.Player1Scale.SetMedalsCount(gm.player1score); } - else//p1 íå óñïåë + else//p1 не успел { gm.player2score += 1; gm.Player2Scale.SetMedalsCount(gm.player2score); } } - else if (gm.gameMode == GameMode.pve)//âðåìÿ âûøëî ïðè èãðå ñ áîòîì - áîò ïîáåäèë + else if (gm.gameMode == GameMode.pve)//время вышло при игре с ботом - бот победил { LightUtility.Lose(); CharacterController.CurrentCharacter.GetComponent().SetTrigger("Win"); - //ÍÅ ÍÈ×Üß + //НЕ НИЧЬЯ VictoryScale vsBotScale = gm.botScale; - DifficultyManager.instance.DecreaseDifficulty(); + DifficultyManager.Instance.DecreaseDifficulty(); CharacterEventBus.Instance.OnBotWin?.Invoke(); if (gm.vsBotScore != 0) gm.vsBotScore -= 1; @@ -166,7 +166,7 @@ public static class EndOfTurnHandler nextState = new ShowWinnerState(result); - //êîíåö èãðû - ïðèçîâîå ñîñòîÿíèå + //конец игры - призовое состояние if (TotalWin()) { nextState = new VictoryState();