Проделки в логике перемещения и бросания фишки
This commit is contained in:
parent
3375ae83c0
commit
fbb3bca0a9
@ -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
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 }
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff2dd8d6c42d77b45bfe64d3c8d88b4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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;
|
||||
|
||||
@ -33,7 +33,7 @@ public class PromoState : IState
|
||||
|
||||
if (anyInput || kinoVse)
|
||||
{
|
||||
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
||||
GameManager.instance.GotoMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ public class SettingsState : IState
|
||||
if (ShouldExit())
|
||||
{
|
||||
SoundManager.instance.playChoose();
|
||||
GameManager.instance.stateMachine.ChangeState(new MenuState());
|
||||
GameManager.instance.GotoMenu();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,8 @@ public static class StateRouter
|
||||
public static IState ToMenu()
|
||||
{
|
||||
Board.Instance.MakeClearField();
|
||||
return new MenuState();
|
||||
GameManager.instance.GotoMenu();
|
||||
return null;//
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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<GameMode> OnGameStarted;
|
||||
public static event Action<GameMode> 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<SpriteRenderer>().sprite = CharactersController.CurrentCharacter.chipImage;
|
||||
}
|
||||
|
||||
|
||||
public void SwitchPlayer()
|
||||
{
|
||||
currentPlayer = currentPlayer == CellState.Player1 ? CellState.Player2 : CellState.Player1;
|
||||
|
||||
@ -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}");
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
142
Assets/Scripts/Gameplay/Player.cs
Normal file
142
Assets/Scripts/Gameplay/Player.cs
Normal file
@ -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<InSignal> _leftButtons;
|
||||
[SerializeField] List<InSignal> _rightButtons;
|
||||
[SerializeField] List<InSignal> _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<InSignal> buttons)
|
||||
{
|
||||
foreach (var signal in buttons)
|
||||
if (In.GetButtonDown(signal))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private enum PlayerState { Preparing, Idle, Moving, Dropped, Sleep }
|
||||
}
|
||||
2
Assets/Scripts/Gameplay/Player.cs.meta
Normal file
2
Assets/Scripts/Gameplay/Player.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0302f7201f8ad714280dbc7ceefc55a7
|
||||
@ -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++)
|
||||
|
||||
65
Assets/Scripts/Menu/MenuController.cs
Normal file
65
Assets/Scripts/Menu/MenuController.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Menu/MenuController.cs.meta
Normal file
2
Assets/Scripts/Menu/MenuController.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d133b2b4d98bff34f8e91f7744df602a
|
||||
@ -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; }
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user