diff --git a/Assets/Prefabs/MainMenu/Right group/Right panel.prefab b/Assets/Prefabs/MainMenu/Right group/Right panel.prefab index e1bf283..9dd97dc 100644 --- a/Assets/Prefabs/MainMenu/Right group/Right panel.prefab +++ b/Assets/Prefabs/MainMenu/Right group/Right panel.prefab @@ -322,6 +322,10 @@ PrefabInstance: propertyPath: m_Name value: 2player mode panel objectReference: {fileID: 0} + - target: {fileID: 6776297778741082393, guid: 148df6817f74c934db0b476a88e85208, type: 3} + propertyPath: gameMode + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7375687429925126630, guid: 148df6817f74c934db0b476a88e85208, type: 3} propertyPath: m_Pivot.x value: 0.5 diff --git a/Assets/Scenes/GameScene3D.unity b/Assets/Scenes/GameScene3D.unity index ec962d0..03081dd 100644 --- a/Assets/Scenes/GameScene3D.unity +++ b/Assets/Scenes/GameScene3D.unity @@ -4492,8 +4492,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0427b50b8b84b5641a0188046aaee227, type: 3} m_Name: m_EditorClassIdentifier: - Rows: 5 - Cols: 6 botsAmount: 5 stateMachine: {fileID: 259182281} AdminPanel: {fileID: 581100730} @@ -4525,6 +4523,7 @@ MonoBehaviour: valutaPerPulseInput: {fileID: 0} leaderboard: {fileID: 1784614873} CharactersConfigurator: {fileID: 141381088} + menuGameplayTransit: {fileID: 29868612} setPasswordPanel: {fileID: 131572818} vitrinaPanel: {fileID: 61619038} qrPanel: {fileID: 1060301113} diff --git a/Assets/Scripts/Common/GameFSM/CheckLeadersFromMenuState.cs b/Assets/Scripts/Common/GameFSM/CheckLeadersFromMenuState.cs index d727178..33f62cb 100644 --- a/Assets/Scripts/Common/GameFSM/CheckLeadersFromMenuState.cs +++ b/Assets/Scripts/Common/GameFSM/CheckLeadersFromMenuState.cs @@ -35,7 +35,7 @@ public class CheckLeadersFromMenuState : IState bool exitCombo = In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right); if (exitCombo) { - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } bool keepDownButton = In.GetButtonAnyPlayer(PlayerAction.down); @@ -45,7 +45,7 @@ public class CheckLeadersFromMenuState : IState timeElapsed += Time.deltaTime; if (timeElapsed > timeToExit) { - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } } diff --git a/Assets/Scripts/Common/GameFSM/ChipFallingState.cs b/Assets/Scripts/Common/GameFSM/ChipFallingState.cs index 59a5627..1547809 100644 --- a/Assets/Scripts/Common/GameFSM/ChipFallingState.cs +++ b/Assets/Scripts/Common/GameFSM/ChipFallingState.cs @@ -52,7 +52,7 @@ public class ChipFallingState : IState private void CompleteChipLanding() { - Board.Instance.AttachChipToGrid(chip, targetColumn, targetRow); + //Board.Instance.AttachChipToGrid(chip, targetColumn, targetRow); StateRouter.RouteAfterTurn(); } diff --git a/Assets/Scripts/Common/GameFSM/LeaderboardState.cs b/Assets/Scripts/Common/GameFSM/LeaderboardState.cs index 6e18617..af0bf8e 100644 --- a/Assets/Scripts/Common/GameFSM/LeaderboardState.cs +++ b/Assets/Scripts/Common/GameFSM/LeaderboardState.cs @@ -35,7 +35,7 @@ public class LeaderboardState : IState if (In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right)) { Board.Instance.MakeClearField(); - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } } } diff --git a/Assets/Scripts/Common/GameFSM/MenuState.cs b/Assets/Scripts/Common/GameFSM/MenuState.cs deleted file mode 100644 index 3f6deb6..0000000 --- a/Assets/Scripts/Common/GameFSM/MenuState.cs +++ /dev/null @@ -1,137 +0,0 @@ -public class MenuState : IState -{ - private GameManager gm; - private HoldTimer promoTimer; - private HoldTimer settingsTimer; - private MenuSubStates subState; - - public void enter() - { - gm = GameManager.instance; - gm.ResetGameSession(); - - subState = MenuSubStates.InputPolling; - - promoTimer = new(180f); - settingsTimer = new(3f); - - LightUtility.Idle(); - } - - public void exit() - { - promoTimer.Reset(); - settingsTimer.Reset(); - } - - public void update() - { - if (subState == MenuSubStates.InputPolling) - InputPolling(); - else if (subState == MenuSubStates.WaitAnimation) - WaitAnimation(); - } - - private void InputPolling()//основное состояние(выбор) - { - //if (ui.AnimationInProcess) return; - - if (HandleSettings()) return; - if (HandleGameStart()) return; - if (HandleRules()) return; - if (HandleLeaderboard()) return; - if (HandlePromo()) return; - } - - private bool HandleSettings() - { - bool settingButtonPressed = In.GetButton(InSignal.secret); - bool gotoSettings = UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.F5) || settingsTimer.Update(settingButtonPressed); - if (gotoSettings) - { - TransitionTo(new CheckSettingsPasswordState()); - return true; - } - return false; - } - - private bool HandleGameStart() => TrySelectGameMode(out var mode) && TryStartGame(mode); - - private bool HandleRules() - { - if (In.GetButtonDownAnyPlayer(PlayerAction.down)) - { - TransitionTo(new RulesState()); - return true; - } - return false; - } - - private bool HandleLeaderboard() - { - bool gotoLeaderboard = In.GetButtonDownAnyPlayer(PlayerAction.left) && In.GetButtonDownAnyPlayer(PlayerAction.right); - if (gotoLeaderboard) - { - TransitionTo(new CheckLeadersFromMenuState()); - return true; - } - return false; - } - - private bool HandlePromo() - { - if (promoTimer.Update(!In.AnyButton())) - { - TransitionTo(new PromoState(), playSound: false); - return true; - } - return false; - } - - private bool TrySelectGameMode(out GameMode mode) - { - mode = GameMode.pve; - - if (In.GetButtonDown(InSignal.startOnePlayer)) - mode = GameMode.pve; - else if (In.GetButtonDown(InSignal.startTwoPlayers)) - mode = GameMode.pvp; - else - return false; - - return true; - } - - private bool TryStartGame(GameMode mode) - { - if (!PaymentSystem.TryPayForMode(mode)) return false; - - gm.SetMode(mode); - gm.timerManager.SetTimersActivity(gm.gameMode); - //ui.CloseMenu(); - //gm.InitVictoryScales(); - - subState = MenuSubStates.WaitAnimation; - return true; - } - - private void WaitAnimation() - { - //if (ui.AnimationInProcess) return; - - CharactersController.ResetState(); - SoundManager.instance.playChoose(); - gm.PrepareRound(CellState.Player1); - - //if (gm.gameMode == GameMode.pve) - // gm.movesAndTimeCounter.SetVisibility(true); - } - - private void TransitionTo(IState state, bool playSound = true) - { - if (playSound) SoundManager.instance.playChoose(); - gm.stateMachine.ChangeState(state); - } - - private enum MenuSubStates { InputPolling, WaitAnimation } -} \ No newline at end of file diff --git a/Assets/Scripts/Common/GameFSM/MenuState.cs.meta b/Assets/Scripts/Common/GameFSM/MenuState.cs.meta deleted file mode 100644 index 004ba51..0000000 --- a/Assets/Scripts/Common/GameFSM/MenuState.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ff2dd8d6c42d77b45bfe64d3c8d88b4e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Common/GameFSM/PositioningState.cs b/Assets/Scripts/Common/GameFSM/PositioningState.cs index e550976..ff1f037 100644 --- a/Assets/Scripts/Common/GameFSM/PositioningState.cs +++ b/Assets/Scripts/Common/GameFSM/PositioningState.cs @@ -63,7 +63,7 @@ public class PositioningState : IState HandleChipMovement(input.direction); - chipOnPosition = chip.MoveToLinear(stickedPosition); + //chipOnPosition = chip.MoveToLinear(stickedPosition); if (HandleDrop(input.action)) return; if (HandleExitToMenu()) return; @@ -97,7 +97,7 @@ public class PositioningState : IState board.MakeClearField(); PaymentSystem.ReturnCredits(gm.gameMode); GameManager.instance.timerManager.StopAllTimers(); - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); return true; } return false; diff --git a/Assets/Scripts/Common/GameFSM/PromoState.cs b/Assets/Scripts/Common/GameFSM/PromoState.cs index dc48507..83c3417 100644 --- a/Assets/Scripts/Common/GameFSM/PromoState.cs +++ b/Assets/Scripts/Common/GameFSM/PromoState.cs @@ -33,7 +33,7 @@ public class PromoState : IState if (anyInput || kinoVse) { - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } } } diff --git a/Assets/Scripts/Common/GameFSM/RulesState.cs b/Assets/Scripts/Common/GameFSM/RulesState.cs index fcbac47..6424b6c 100644 --- a/Assets/Scripts/Common/GameFSM/RulesState.cs +++ b/Assets/Scripts/Common/GameFSM/RulesState.cs @@ -37,7 +37,7 @@ public class RulesState : IState if (In.GetButtonDownAnyPlayer(PlayerAction.down) || restTime <= 0) { rules.Close(); - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } restTime -= Time.deltaTime; } diff --git a/Assets/Scripts/Common/GameFSM/SettingsState.cs b/Assets/Scripts/Common/GameFSM/SettingsState.cs index 78998ea..be94c6e 100644 --- a/Assets/Scripts/Common/GameFSM/SettingsState.cs +++ b/Assets/Scripts/Common/GameFSM/SettingsState.cs @@ -22,7 +22,7 @@ public class SettingsState : IState if (ShouldExit()) { SoundManager.instance.playChoose(); - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); } } diff --git a/Assets/Scripts/Common/GameFSM/ShowWinnerState.cs b/Assets/Scripts/Common/GameFSM/ShowWinnerState.cs index 86e763c..e46db4f 100644 --- a/Assets/Scripts/Common/GameFSM/ShowWinnerState.cs +++ b/Assets/Scripts/Common/GameFSM/ShowWinnerState.cs @@ -217,7 +217,7 @@ public class ShowWinnerState : IState DualAvatarController.Instance.HideCharacters(); Board.Instance.MakeClearField(); //GameManager.instance.stateMachine.ChangeState(new MenuState(fromGameplay: true)); - GameManager.instance.stateMachine.ChangeState(new MenuState()); + GameManager.instance.GotoMenu(); break; } } diff --git a/Assets/Scripts/Common/GameFSM/StateRouter.cs b/Assets/Scripts/Common/GameFSM/StateRouter.cs index 919d80c..3086610 100644 --- a/Assets/Scripts/Common/GameFSM/StateRouter.cs +++ b/Assets/Scripts/Common/GameFSM/StateRouter.cs @@ -150,7 +150,8 @@ public static class StateRouter public static IState ToMenu() { Board.Instance.MakeClearField(); - return new MenuState(); + GameManager.instance.GotoMenu(); + return null;// } diff --git a/Assets/Scripts/Common/GameManager.cs b/Assets/Scripts/Common/GameManager.cs index 0f3706e..5309800 100644 --- a/Assets/Scripts/Common/GameManager.cs +++ b/Assets/Scripts/Common/GameManager.cs @@ -1,11 +1,15 @@ using PrizeSystem; +using System; using System.Collections; using UnityEngine; public enum GameMode { pve, pvp } public class GameManager : MonoBehaviour { - - public int Rows = 7, Cols = 7; + public static event Action OnGameStarted; + public static event Action OnGameFinished; + public event Action OnRoundStarted; + + public PlayerStatsService StatsService; public int botsAmount = 5; @@ -22,6 +26,10 @@ public class GameManager : MonoBehaviour [Header("Menu")] public GameMode gameMode; + [HideInInspector] public CellState currentPlayer = CellState.Player2; + + + [Header("Scores")] public int player1score = 0, player2score = 0, vsBotScore = 0; @@ -30,7 +38,6 @@ public class GameManager : MonoBehaviour public int vsBotMoves; public float vsBotThinkTime; - [HideInInspector] public CheckResult lastResult; @@ -41,12 +48,10 @@ public class GameManager : MonoBehaviour public Chip chipPrefab; [HideInInspector] public Chip currentChip; - [HideInInspector] public CellState currentPlayer = CellState.Player2; public bool canReturnToMenu = false; //todo: разобраться нафига эта переменная - // Кешированные компоненты для избежания GetComponent в DrawAnimation [Header("Панели ввода")] public TextInput nameInput; public TextInput ValutaNameInput; @@ -60,8 +65,11 @@ public class GameManager : MonoBehaviour public Leaderboard leaderboard; public GameObject CharactersConfigurator; - + [Header("Переходы")] + [SerializeField] private MenuGameplayTransit menuGameplayTransit; + + //public PvpPointer pvpPointer; //public MovesAndTimeCounter movesAndTimeCounter; @@ -92,21 +100,28 @@ public class GameManager : MonoBehaviour //stateMachine.ChangeState(new MenuState()); } + public void TryEnterGame(GameMode mode) + { + if (!PaymentSystem.TryPayForMode(mode)) + return; + SetMode(mode); + + menuGameplayTransit.GotoGameplay(); + OnGameStarted?.Invoke(gameMode); + //timerManager.SetTimersActivity(gameMode); + } + private void OnApplicationQuit() => ComNativeWrapper.Serial_CloseAll(); private void Update() { -#if UNITY_EDITOR - if (Input.GetKeyDown(KeyCode.G)) - { - PrizeSystemManager.GivePrize(PrizeUtils.CreatePrize(CountablePrizeType.Hopper, 1)); - } - if (Input.GetKeyDown(KeyCode.O)) - { - PlayerPrefs.SetInt("PrizeGivenBuffer", 1); - } -#endif - if (increaseVsBotTimer) vsBotThinkTime += Time.deltaTime; + if (increaseVsBotTimer) + vsBotThinkTime += Time.deltaTime; + } + + public void GotoMenu() + { + print("ПЕРЕХОД в МЕНЮ"); } public void StartVsBotTimer() => increaseVsBotTimer = true; @@ -127,7 +142,6 @@ public class GameManager : MonoBehaviour currentChip.GetComponentInChildren().sprite = CharactersController.CurrentCharacter.chipImage; } - public void SwitchPlayer() { currentPlayer = currentPlayer == CellState.Player1 ? CellState.Player2 : CellState.Player1; diff --git a/Assets/Scripts/Gameplay/Board.cs b/Assets/Scripts/Gameplay/Board.cs index e020134..4569966 100644 --- a/Assets/Scripts/Gameplay/Board.cs +++ b/Assets/Scripts/Gameplay/Board.cs @@ -28,6 +28,8 @@ public class Board : MonoBehaviour SettingsManager.OnSettingsChanged += ApplySettings; } + public Vector2 GetMiddleStickedPosition() => new Vector2(GetXPosition(Columns/2), config.stickedY); + public Vector2 GetStickedPosition(int column) => new Vector2(GetXPosition(column), config.stickedY); public Vector2 GetTargetPosition(int column) => new Vector2(GetXPosition(column), GetYPosition(column)); @@ -41,8 +43,9 @@ public class Board : MonoBehaviour public bool CanDrop(int column) => Grid[column, 0] == null; - public void AttachChipToGrid(Chip chip, int column, int row) + public void DropChip(Chip chip, int column) { + int row = GetLowestEmptyRow(column); if (column < 0 || column >= Columns) { Debug.LogError($"Попытка поставить фишку в колонку {column}. Колонок: {Columns}"); diff --git a/Assets/Scripts/Gameplay/Bot Characters/CharactersController.cs b/Assets/Scripts/Gameplay/Bot Characters/CharactersController.cs index e9bf30d..c3528ab 100644 --- a/Assets/Scripts/Gameplay/Bot Characters/CharactersController.cs +++ b/Assets/Scripts/Gameplay/Bot Characters/CharactersController.cs @@ -37,6 +37,19 @@ public class CharactersController : MonoBehaviour { I = this; SetupCharacters(); + GameManager.OnGameStarted += Enable; + GameManager.OnGameFinished += Disable; + } + + public void Enable(GameMode gameMode) + { + if(gameMode == GameMode.pve) + print("ВКЛЮЧЕНИЕ СИСТЕМЫ ПЕРСОНАЖЕЙ"); + } + public void Disable(GameMode gameMode) + { + if (gameMode == GameMode.pve) + print("ВЫКЛЮЧЕНИЕ СИСТЕМЫ ПЕРСОНАЖЕЙ"); } public void SetAllCharactersPrizeAvailable(bool value) diff --git a/Assets/Scripts/Gameplay/Chip.cs b/Assets/Scripts/Gameplay/Chip.cs index 873ae78..dbfb817 100644 --- a/Assets/Scripts/Gameplay/Chip.cs +++ b/Assets/Scripts/Gameplay/Chip.cs @@ -3,7 +3,6 @@ public class Chip : MonoBehaviour { public CellState Team; - [SerializeField] float linearSpeed = 50f; [SerializeField] float acceleration = 200f; [SerializeField] float maxFallingRotationSpeed = 500; @@ -15,10 +14,10 @@ public class Chip : MonoBehaviour Destroy(gameObject); } - public bool MoveToLinear(Vector2 target) + public bool MoveToLinear(Vector2 target, float speed) { - transform.position = Vector2.MoveTowards(transform.position, target, linearSpeed * Time.deltaTime); - if((Vector2)transform.position == target) + transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime); + if ((Vector2)transform.position == target) return true; return false; } diff --git a/Assets/Scripts/Gameplay/Player.cs b/Assets/Scripts/Gameplay/Player.cs new file mode 100644 index 0000000..ae49648 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player.cs @@ -0,0 +1,142 @@ +using System.Collections.Generic; +using UnityEngine; + +public class Player : MonoBehaviour, IControlable +{ + [SerializeField] private Board board; + [SerializeField] private float chipYOffset = 5f; + + [SerializeField] private float prepareSpeed; + [SerializeField] private float moveSpeed; + + [Header("Управление")] + [SerializeField] List _leftButtons; + [SerializeField] List _rightButtons; + [SerializeField] List _actionButtons; + + private int[] availableColumns; + private int availableColumnsIndex; + private Chip myChip; + private Vector2 targetStickedPosition; + private Vector2 targetPosition; + private PlayerState _state; + private bool controlsEnabled; + + private int SelectedColumn => availableColumns[availableColumnsIndex]; + + public bool ControlsEnabled { + get => _state == PlayerState.Idle || _state == PlayerState.Moving; + set => controlsEnabled = value;} + + + + public void PrepareChip(Chip chip) + { + _state = PlayerState.Preparing; + CacheColumns(); + myChip = chip; + targetStickedPosition = board.GetMiddleStickedPosition(); + chip.transform.position = targetStickedPosition + Vector2.up * chipYOffset; + } + + public void Sleep() + { + _state = PlayerState.Sleep; + availableColumns = null; + myChip = null; + } + + public void UpdateControls() + { + if (!ControlsEnabled) return; + HandleHorizontalMove(); + + switch (_state) + { + case PlayerState.Preparing: + if (myChip.MoveToLinear(targetStickedPosition, prepareSpeed)) + _state = PlayerState.Idle; + break; + + case PlayerState.Moving: + if (myChip.MoveToLinear(targetStickedPosition, moveSpeed)) + _state = PlayerState.Idle; + break; + + case PlayerState.Dropped: + if (myChip.MoveToAccelerated(targetPosition)) + { + _state = PlayerState.Sleep; + Debug.Log("Падение фишки закончено"); + } + break; + + case PlayerState.Idle: + if (HandleDrop()) return; + break; + + case PlayerState.Sleep: + break; + } + } + private void CacheColumns() + { + availableColumns = board.GetNonFullColumns(); + availableColumnsIndex = availableColumns.Length / 2; + } + + private bool HandleHorizontalMove() + { + int direction = 0; + if (IsButtonPressed(_leftButtons)) direction -= 1; + if (IsButtonPressed(_rightButtons)) direction += 1; + + if (direction != 0) + { + int newIndex = Mathf.Clamp(availableColumnsIndex+direction, 0, availableColumns.Length - 1); + bool indexChanged = newIndex != availableColumnsIndex; + + if (indexChanged) + { + availableColumnsIndex = newIndex; + targetStickedPosition = board.GetStickedPosition(SelectedColumn); + _state = PlayerState.Moving; + return true; + } + } + + return false; + } + + private bool HandleDrop() + { + if (_state != PlayerState.Idle) + return false; + + bool hasAction = IsButtonPressed(_actionButtons); + + if (hasAction) + { + PerformDrop(); + return true; + } + + return false; + } + private void PerformDrop() + { + targetPosition = board.GetTargetPosition(SelectedColumn); + board.DropChip(myChip, SelectedColumn); + _state = PlayerState.Dropped; + } + + private bool IsButtonPressed(List buttons) + { + foreach (var signal in buttons) + if (In.GetButtonDown(signal)) + return true; + return false; + } + + private enum PlayerState { Preparing, Idle, Moving, Dropped, Sleep } +} diff --git a/Assets/Scripts/Gameplay/Player.cs.meta b/Assets/Scripts/Gameplay/Player.cs.meta new file mode 100644 index 0000000..4e38815 --- /dev/null +++ b/Assets/Scripts/Gameplay/Player.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0302f7201f8ad714280dbc7ceefc55a7 \ No newline at end of file diff --git a/Assets/Scripts/Gameplay/SolverV2.cs b/Assets/Scripts/Gameplay/SolverV2.cs index a92aeb1..aade191 100644 --- a/Assets/Scripts/Gameplay/SolverV2.cs +++ b/Assets/Scripts/Gameplay/SolverV2.cs @@ -53,8 +53,9 @@ public static class SolverV2 static SolverV2() { - WIDTH = GameManager.instance.Cols; - HEIGHT = GameManager.instance.Rows; + WIDTH = Board.Instance.Columns; + HEIGHT = Board.Instance.Rows; + MoveOrder = GenerateMoveOrder(); // Инициализация масок колонок for (int c = 0; c < WIDTH; c++) diff --git a/Assets/Scripts/Menu/MenuController.cs b/Assets/Scripts/Menu/MenuController.cs new file mode 100644 index 0000000..01124e5 --- /dev/null +++ b/Assets/Scripts/Menu/MenuController.cs @@ -0,0 +1,65 @@ +using UnityEngine; + +public class MenuController : MonoBehaviour +{ + [SerializeField] private float _timeToPromo = 180f; + [SerializeField] private float _timeToSettings = 1f; + + private HoldTimer _promoTimer; + private HoldTimer _settingsTimer; + private bool _isInit = false; + private bool _isEnabled = false; + + private void Update() + { + if ((_isEnabled && _isInit) == false) + return; + + if (HandleSettings()) return; + if (HandlePromo()) return; + } + + public void Initialize() + { + _promoTimer = new HoldTimer(_timeToPromo); + _settingsTimer = new HoldTimer(_timeToSettings); + + _isInit = true; + } + + public void Enable() + { + _isEnabled = true; + LightUtility.Idle(); + GameManager.instance.ResetGameSession(); + } + + public void Disable() + { + _isEnabled = false; + _promoTimer.Reset(); + _settingsTimer.Reset(); + } + + private bool HandleSettings() + { + bool settingButtonPressed = In.GetButton(InSignal.secret); + bool gotoSettings = Input.GetKeyDown(KeyCode.F5) || _settingsTimer.Update(settingButtonPressed); + if (gotoSettings) + { + print("ТУТ БУДЕТ ПЕРЕХОД В НАСТРОЙКИ"); + return true; + } + return false; + } + + private bool HandlePromo() + { + if (_promoTimer.Update(!In.AnyButton())) + { + print("ТУТ БУДЕТ ПЕРЕХОД В ПРОМО"); + return true; + } + return false; + } +} diff --git a/Assets/Scripts/Menu/MenuController.cs.meta b/Assets/Scripts/Menu/MenuController.cs.meta new file mode 100644 index 0000000..8988ce5 --- /dev/null +++ b/Assets/Scripts/Menu/MenuController.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d133b2b4d98bff34f8e91f7744df602a \ No newline at end of file diff --git a/Assets/Scripts/Menu/MenuLayoutController.cs b/Assets/Scripts/Menu/MenuLayoutController.cs index 023cafc..e4ca717 100644 --- a/Assets/Scripts/Menu/MenuLayoutController.cs +++ b/Assets/Scripts/Menu/MenuLayoutController.cs @@ -1,8 +1,6 @@ -using Cysharp.Threading.Tasks; -using DG.Tweening; +using DG.Tweening; using System; using System.Collections.Generic; -using System.Threading; using UnityEngine; public class MenuLayoutController : MonoBehaviour, IControlable @@ -18,7 +16,6 @@ public class MenuLayoutController : MonoBehaviour, IControlable [SerializeField] private Ease _ease; private float _leftOpenedPosition; private float _rightOpenedPosition; - //private Sequence _sequence; public bool ControlsEnabled { get; set; } diff --git a/Assets/Scripts/Menu/Panels/GamemodePanel.cs b/Assets/Scripts/Menu/Panels/GamemodePanel.cs index d11081d..f3c561c 100644 --- a/Assets/Scripts/Menu/Panels/GamemodePanel.cs +++ b/Assets/Scripts/Menu/Panels/GamemodePanel.cs @@ -27,6 +27,9 @@ public class GamemodePanel : MenuPanel [SerializeField] RectTransform modeSign; [SerializeField] Vector2 signOffset = new(-200, 0); + [Header("Взаимодействие")] + [SerializeField] private GameMode gameMode; + private Vector2 signStart; private CancellationTokenSource cts; @@ -99,10 +102,7 @@ public class GamemodePanel : MenuPanel .WithCancellation(cts.Token); } - public override void Interact() - { - Debug.Log("interact " + name); - } + public override void Interact() => GameManager.instance.TryEnterGame(gameMode); private void StopAnimation() { diff --git a/Assets/Scripts/MenuGameplayTransit.cs b/Assets/Scripts/MenuGameplayTransit.cs index b68ecf2..447954f 100644 --- a/Assets/Scripts/MenuGameplayTransit.cs +++ b/Assets/Scripts/MenuGameplayTransit.cs @@ -13,12 +13,12 @@ public class MenuGameplayTransit : MonoBehaviour if (locked) return; if (Input.GetKeyDown(KeyCode.Alpha1)) - StartGame(); + GotoGameplay(); else if (Input.GetKeyDown(KeyCode.Alpha2)) GotoMenu(); } - public void StartGame() + public void GotoGameplay() { Lock(); if (_sequence != null) @@ -52,6 +52,6 @@ public class MenuGameplayTransit : MonoBehaviour _sequence.PlayForward(); } - private void Lock() => this.locked = true; - private void Unlock() => this.locked = false; + private void Lock() => locked = true; + private void Unlock() => locked = false; }