Обновить обработку ввода и стандарты стиля кода
This commit is contained in:
parent
26f9eb35d7
commit
963115e311
29
AGENTS.md
29
AGENTS.md
@ -21,3 +21,32 @@
|
||||
- При создании контекста решения обязательно объединять актуальное состояние репозитория и Unity Editor с информацией из `agentmemory`; не полагаться только на текущий чат.
|
||||
- Перед завершением задачи фиксировать в `agentmemory` важные изменения, решения и результаты проверки.
|
||||
- Если `agentmemory` недоступен, явно сообщить об этом пользователю. Попытка обратиться к `agentmemory` всё равно обязательна; задача не должна молча обходить это требование.
|
||||
|
||||
# Code Style
|
||||
|
||||
## Структура скрипта (строгий порядок)
|
||||
|
||||
1. `public event`
|
||||
2. `public` поля
|
||||
3. `[SerializeField] private` поля
|
||||
4. `private` поля
|
||||
5. Свойства
|
||||
6. Unity-методы (`Awake` → `OnEnable` → `Start` → `Update` → `FixedUpdate` → `LateUpdate` → `OnDisable` → `OnDestroy`)
|
||||
7. Публичные методы
|
||||
8. Приватные методы
|
||||
|
||||
## Именование
|
||||
|
||||
| Что | Как |
|
||||
|-----|-----|
|
||||
| Публичные поля | `camelCase` |
|
||||
| Публичные события | `PascalCase` |
|
||||
| `[SerializeField] private` | `_camelCase` |
|
||||
| Приватные поля | `_camelCase` |
|
||||
| Свойства | `PascalCase` |
|
||||
| Параметры методов | `camelCase` |
|
||||
|
||||
## Комментарии
|
||||
|
||||
- **Без `/// <summary>`**
|
||||
- Комментарии только для сложной/неочевидной логики
|
||||
@ -1075,7 +1075,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 698.89, y: -613.41504}
|
||||
m_AnchoredPosition: {x: 698.88995, y: -613.41504}
|
||||
m_SizeDelta: {x: 1342.78, y: 1342.78}
|
||||
m_Pivot: {x: 1, y: 0}
|
||||
--- !u!114 &64783861
|
||||
@ -2638,9 +2638,6 @@ MonoBehaviour:
|
||||
chipYOffset: 5
|
||||
prepareSpeed: 30
|
||||
moveSpeed: 50
|
||||
leftButtons: 03000000
|
||||
rightButtons: 01000000
|
||||
actionButtons: 04000000
|
||||
--- !u!4 &245771469
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3537,9 +3534,6 @@ MonoBehaviour:
|
||||
chipYOffset: 5
|
||||
prepareSpeed: 30
|
||||
moveSpeed: 50
|
||||
leftButtons: 03000000
|
||||
rightButtons: 01000000
|
||||
actionButtons: 04000000
|
||||
--- !u!4 &304437820
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -18842,7 +18836,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1967587903
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -19613,7 +19607,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: -587.89, y: 673.615}
|
||||
m_AnchoredPosition: {x: -587.88995, y: 673.615}
|
||||
m_SizeDelta: {x: 1342.78, y: 1342.78}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &1984669016
|
||||
@ -22508,6 +22502,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: PrizesConfigurator
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5423109734219761443, guid: dcef42dd0beb95f4e9b230192966f091, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@ -24323,7 +24321,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7725792043156676869, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
|
||||
propertyPath: m_fontSize
|
||||
value: 0.55
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8620231027088551242, guid: 50b5075221b823240b287cd5e6c02d64, type: 3}
|
||||
propertyPath: m_Name
|
||||
|
||||
@ -24,9 +24,7 @@ public class PveLossPanel : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
int direction = 0;
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.left)) direction -= 1;
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.right)) direction += 1;
|
||||
int direction = In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x;
|
||||
|
||||
int newButtonIndex = Mathf.Clamp(buttonIndex + direction, 0, buttons.Count-1);
|
||||
bool indexChanged = newButtonIndex != buttonIndex;
|
||||
@ -37,7 +35,7 @@ public class PveLossPanel : MonoBehaviour, IControlable
|
||||
}
|
||||
|
||||
//interact
|
||||
if(In.GetButtonDownAnyPlayer(PlayerAction.action))
|
||||
if(In.GetAction(JoystickSide.Both, InteractMode.Discrete))
|
||||
{
|
||||
var selectedButton = buttons[buttonIndex];
|
||||
selectedButton.Interact();
|
||||
|
||||
@ -117,7 +117,7 @@ public class PveWinPanel : MonoBehaviour, IControlable
|
||||
{
|
||||
if(ControlsEnabled == false) return;
|
||||
|
||||
if(In.GetButtonDownAnyPlayer(PlayerAction.action))
|
||||
if(In.GetAction(JoystickSide.Both, InteractMode.Discrete))
|
||||
{
|
||||
print("Кнопка нажата");
|
||||
Close();
|
||||
|
||||
@ -27,9 +27,7 @@ public class PvpWinPanel : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
int direction = 0;
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.left)) direction -= 1;
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.right)) direction += 1;
|
||||
int direction = In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x;
|
||||
|
||||
int newButtonIndex = Mathf.Clamp(buttonIndex + direction, 0, buttons.Count);
|
||||
bool indexChanged = newButtonIndex != buttonIndex;
|
||||
@ -40,7 +38,7 @@ public class PvpWinPanel : MonoBehaviour, IControlable
|
||||
}
|
||||
|
||||
//interact
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.action))
|
||||
if (In.GetAction(JoystickSide.Both, InteractMode.Discrete))
|
||||
{
|
||||
var selectedButton = buttons[buttonIndex];
|
||||
selectedButton.Interact();
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Player : BasePlayer, IGamePlayer
|
||||
@ -9,11 +8,6 @@ public class Player : BasePlayer, IGamePlayer
|
||||
[SerializeField] private float prepareSpeed;
|
||||
[SerializeField] private float moveSpeed;
|
||||
|
||||
[Header("Input")]
|
||||
[SerializeField] private List<InSignal> leftButtons;
|
||||
[SerializeField] private List<InSignal> rightButtons;
|
||||
[SerializeField] private List<InSignal> actionButtons;
|
||||
|
||||
// State
|
||||
private PlayerState state = PlayerState.Sleep;
|
||||
private Chip currentChip;
|
||||
@ -183,17 +177,17 @@ public class Player : BasePlayer, IGamePlayer
|
||||
|
||||
private int GetHorizontalInput()
|
||||
{
|
||||
int direction = 0;
|
||||
if (In.GetButtonDown(leftButtons)) direction -= 1;
|
||||
if (In.GetButtonDown(rightButtons)) direction += 1;
|
||||
return direction;
|
||||
return In.GetAxis(GetJoystickSide(), InteractMode.Discrete).x;
|
||||
}
|
||||
|
||||
private bool IsActionPressed()
|
||||
{
|
||||
return In.GetButtonDown(actionButtons);
|
||||
return In.GetAction(GetJoystickSide(), InteractMode.Discrete);
|
||||
}
|
||||
|
||||
private JoystickSide GetJoystickSide()
|
||||
=> team == Team.Player1 ? JoystickSide.Left : JoystickSide.Right;
|
||||
|
||||
private void SetState(PlayerState newState)
|
||||
{
|
||||
state = newState;
|
||||
@ -213,4 +207,4 @@ public class Player : BasePlayer, IGamePlayer
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class COMinput : InputSource
|
||||
pinMappings[InSignal.action2] = 9;
|
||||
pinMappings[InSignal.startOnePlayer] = 10;
|
||||
pinMappings[InSignal.startTwoPlayers] = 11;
|
||||
pinMappings[InSignal.secret] = 12;
|
||||
pinMappings[InSignal.service] = 12;
|
||||
pinMappings[InSignal.extra] = 13;
|
||||
pinMappings[InSignal.hasPrize] = 14;
|
||||
pinMappings[InSignal.prizeGiven] = 15;
|
||||
@ -97,7 +97,7 @@ public class COMinput : InputSource
|
||||
pinMappings[InSignal.action2] = 11;
|
||||
pinMappings[InSignal.startOnePlayer] = 5;
|
||||
pinMappings[InSignal.startTwoPlayers] = 6;
|
||||
pinMappings[InSignal.secret] = 12;
|
||||
pinMappings[InSignal.service] = 12;
|
||||
pinMappings[InSignal.extra] = 13;
|
||||
pinMappings[InSignal.hasPrize] = 14;
|
||||
pinMappings[InSignal.prizeGiven] = 15;
|
||||
@ -205,7 +205,7 @@ public class COMinput : InputSource
|
||||
public override bool GetButtonUp(int pinIndex) => ConsumeButtonEvent(buttonUp, pinIndex);
|
||||
// ------------------------------------------------------------------------------------
|
||||
//ЭТА ГРУППА МЕТОДОВ ПОЗВОЛЯЕТ УЗНАТЬ СОСТОЯНИЯ КНОПОК АКТИВНОГО ИГРОКА (проверка по enum PlayerAction)
|
||||
//Служебные кнопки типа startOnePlayer, startTwoPlayers, secret, extra, hasPrize, prizeGiven здесь не проверяются
|
||||
//Служебные кнопки типа startOnePlayer, startTwoPlayers, service, extra, hasPrize, prizeGiven здесь не проверяются
|
||||
|
||||
/// <summary>
|
||||
/// Получает состояние действия для текущего игрока.
|
||||
@ -236,7 +236,7 @@ public class COMinput : InputSource
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
//ЭТА ГРУППА МЕТОДОВ ПОЗВОЛЯЕТ УЗНАТЬ СОСТОЯНИЯ КНОПОК ЛЮБОГО ИГРОКА (проверка по enum PlayerAction)
|
||||
//Служебные кнопки типа startOnePlayer, startTwoPlayers, secret, extra, hasPrize, prizeGiven здесь не проверяются
|
||||
//Служебные кнопки типа startOnePlayer, startTwoPlayers, service, extra, hasPrize, prizeGiven здесь не проверяются
|
||||
|
||||
/// <summary>
|
||||
/// Получает состояние действия для любого из игроков.
|
||||
@ -385,4 +385,4 @@ public class COMinput : InputSource
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class In : MonoBehaviour
|
||||
@ -20,78 +19,44 @@ public class In : MonoBehaviour
|
||||
if (!success) Debug.LogWarning("Не удалось проинициалзировать источник управления.");
|
||||
}
|
||||
|
||||
public static int GetAxis(Axis axis, JoystickSide side, InteractMode interactMode = InteractMode.Discrete)
|
||||
/// <summary>Возвращает горизонтальную и вертикальную оси выбранного джойстика.</summary>
|
||||
public static Vector2Int GetAxis(JoystickSide side, InteractMode interactMode = InteractMode.Discrete)
|
||||
{
|
||||
if (axis == Axis.Horizontal) return GetHorizontalAxis(side, interactMode);
|
||||
else if (axis == Axis.Vertical) return GetVerticalAxis(side, interactMode);
|
||||
else return 0;
|
||||
}
|
||||
|
||||
private static int GetHorizontalAxis(JoystickSide side, InteractMode interactMode)
|
||||
{
|
||||
Func<InSignal, bool> func = interactMode == InteractMode.Discrete ? GetButtonDown : GetButton;
|
||||
|
||||
int dir = 0;
|
||||
|
||||
if (side == JoystickSide.Both)
|
||||
{
|
||||
if (func(InSignal.left1) || func(InSignal.left2)) dir -= 1;
|
||||
if (func(InSignal.right1) || func(InSignal.right2)) dir += 1;
|
||||
return dir;
|
||||
int horizontal = ToAxis(
|
||||
IsActive(InSignal.left1, interactMode) || IsActive(InSignal.left2, interactMode),
|
||||
IsActive(InSignal.right1, interactMode) || IsActive(InSignal.right2, interactMode));
|
||||
int vertical = ToAxis(
|
||||
IsActive(InSignal.down1, interactMode) || IsActive(InSignal.down2, interactMode),
|
||||
IsActive(InSignal.up1, interactMode) || IsActive(InSignal.up2, interactMode));
|
||||
|
||||
return new Vector2Int(horizontal, vertical);
|
||||
}
|
||||
else
|
||||
{
|
||||
InSignal left = side switch
|
||||
{
|
||||
JoystickSide.Left => InSignal.left1,
|
||||
JoystickSide.Right => InSignal.left2,
|
||||
};
|
||||
|
||||
InSignal right = side switch
|
||||
{
|
||||
JoystickSide.Left => InSignal.right1,
|
||||
JoystickSide.Right => InSignal.right2,
|
||||
};
|
||||
bool isLeft = side == JoystickSide.Left;
|
||||
InSignal left = isLeft ? InSignal.left1 : InSignal.left2;
|
||||
InSignal right = isLeft ? InSignal.right1 : InSignal.right2;
|
||||
InSignal down = isLeft ? InSignal.down1 : InSignal.down2;
|
||||
InSignal up = isLeft ? InSignal.up1 : InSignal.up2;
|
||||
|
||||
if (func(left)) dir -= 1;
|
||||
if (func(right)) dir += 1;
|
||||
|
||||
return dir;
|
||||
}
|
||||
return new Vector2Int(
|
||||
ToAxis(IsActive(left, interactMode), IsActive(right, interactMode)),
|
||||
ToAxis(IsActive(down, interactMode), IsActive(up, interactMode)));
|
||||
}
|
||||
|
||||
private static int GetVerticalAxis(JoystickSide side, InteractMode interactMode)
|
||||
/// <summary>Возвращает состояние кнопки Action выбранного джойстика.</summary>
|
||||
public static bool GetAction(JoystickSide side, InteractMode interactMode = InteractMode.Discrete)
|
||||
{
|
||||
Func<InSignal, bool> func = interactMode == InteractMode.Discrete ? GetButtonDown : GetButton;
|
||||
int dir = 0;
|
||||
|
||||
if (side == JoystickSide.Both)
|
||||
{
|
||||
if (func(InSignal.down1) || func(InSignal.down2)) dir -= 1;
|
||||
if (func(InSignal.up1) || func(InSignal.up2)) dir += 1;
|
||||
return dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
InSignal downSignal = side switch
|
||||
{
|
||||
JoystickSide.Left => InSignal.down1,
|
||||
JoystickSide.Right => InSignal.down2,
|
||||
};
|
||||
return IsActive(InSignal.action1, interactMode) || IsActive(InSignal.action2, interactMode);
|
||||
|
||||
InSignal upSignal = side switch
|
||||
{
|
||||
JoystickSide.Left => InSignal.up1,
|
||||
JoystickSide.Right => InSignal.up2,
|
||||
};
|
||||
|
||||
if (func(downSignal)) dir -= 1;
|
||||
if (func(upSignal)) dir += 1;
|
||||
|
||||
return dir;
|
||||
}
|
||||
InSignal action = side == JoystickSide.Left ? InSignal.action1 : InSignal.action2;
|
||||
return IsActive(action, interactMode);
|
||||
}
|
||||
|
||||
/// <summary>Возвращает текущее состояние сервисной кнопки без обработки Up/Down.</summary>
|
||||
public static bool GetService() => GetButton(InSignal.service);
|
||||
|
||||
|
||||
public static bool GetButton(InSignal button) => source.GetButton(button);
|
||||
@ -107,27 +72,13 @@ public class In : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool GetButtonUp(InSignal button) => source.GetButtonUp(button);
|
||||
|
||||
public static bool GetButton(int pinindex) => source.GetButton(pinindex);
|
||||
|
||||
public static bool GetButtonDown(int pinindex) => source.GetButtonDown(pinindex);
|
||||
|
||||
public static bool GetButtonUp(int pinindex) => source.GetButtonUp(pinindex);
|
||||
|
||||
public static bool GetButtonAnyPlayer(PlayerAction button) => source.GetButtonAnyPlayer(button);
|
||||
|
||||
public static bool GetButtonDownAnyPlayer(PlayerAction button) => source.GetButtonDownAnyPlayer(button);
|
||||
|
||||
public static bool GetButtonUpAnyPlayer(PlayerAction button) => source.GetButtonUpAnyPlayer(button);
|
||||
|
||||
public static bool GetButtonCurrentPlayer(PlayerAction button) => source.GetButtonCurrentPlayer(button);
|
||||
|
||||
public static bool GetButtonDownCurrentPlayer(PlayerAction button) => source.GetButtonDownCurrentPlayer(button);
|
||||
|
||||
public static bool GetButtonUpCurrentPlayer(PlayerAction button) => source.GetButtonUpCurrentPlayer(button);
|
||||
|
||||
public static bool AnyButton() => source.AnyButton();
|
||||
|
||||
private static bool IsActive(InSignal signal, InteractMode interactMode)
|
||||
=> interactMode == InteractMode.Discrete ? GetButtonDown(signal) : GetButton(signal);
|
||||
|
||||
private static int ToAxis(bool negative, bool positive)
|
||||
=> (positive ? 1 : 0) - (negative ? 1 : 0);
|
||||
}
|
||||
|
||||
public enum Axis
|
||||
|
||||
@ -30,8 +30,8 @@ public enum InSignal
|
||||
startOnePlayer = 10,
|
||||
/// <summary>Запуск игры для двух игроков</summary>
|
||||
startTwoPlayers = 11,
|
||||
/// <summary>Секретная/служебная кнопка для захода в настройки</summary>
|
||||
secret = 12,
|
||||
/// <summary>Служебная кнопка для входа в сервисное меню</summary>
|
||||
service = 12,
|
||||
|
||||
/// <summary>Дополнительная/резервная кнопка</summary>
|
||||
extra = 13,
|
||||
|
||||
@ -128,7 +128,7 @@ public class KeyboardInput : InputSource
|
||||
InSignal.startOnePlayer => KeyCode.Alpha1,
|
||||
InSignal.startTwoPlayers => KeyCode.Alpha2,
|
||||
|
||||
InSignal.secret => KeyCode.F5,
|
||||
InSignal.service => KeyCode.F5,
|
||||
|
||||
InSignal.extra => KeyCode.Alpha3,
|
||||
|
||||
@ -162,7 +162,7 @@ public class KeyboardInput : InputSource
|
||||
10 => KeyCode.Alpha1, // startOnePlayer
|
||||
11 => KeyCode.Alpha2, // startTwoPlayers
|
||||
|
||||
12 => KeyCode.F5, // secret
|
||||
12 => KeyCode.F5, // service
|
||||
|
||||
13 => KeyCode.Alpha3, // extra
|
||||
|
||||
@ -177,4 +177,4 @@ public class KeyboardInput : InputSource
|
||||
{
|
||||
return Input.anyKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,13 +97,11 @@ public class CharacterSelectionPanel : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
int dir_h = In.GetAxis(Axis.Horizontal, JoystickSide.Both);
|
||||
SwitchCharacter(dir_h);
|
||||
Vector2Int axes = In.GetAxis(JoystickSide.Both, InteractMode.Discrete);
|
||||
SwitchCharacter(axes.x);
|
||||
SwitchButton(-axes.y);
|
||||
|
||||
int dir_v = -In.GetAxis(Axis.Vertical, JoystickSide.Both);
|
||||
SwitchButton(dir_v);
|
||||
|
||||
SelectedButton.TakeInput(In.GetButtonAnyPlayer(PlayerAction.action));
|
||||
SelectedButton.TakeInput(In.GetAction(JoystickSide.Both, InteractMode.Continious));
|
||||
}
|
||||
|
||||
private void ClearTable()
|
||||
@ -123,4 +121,4 @@ public class CharacterSelectionPanel : MonoBehaviour, IControlable
|
||||
view.SetPrize(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +23,12 @@ public class CountablePrizeConfigurator : BasePrizeConfigurator, IControlable
|
||||
|
||||
public override void UpdateControls()
|
||||
{
|
||||
numberInput.SetDirection(In.GetAxis(Axis.Horizontal, JoystickSide.Both, InteractMode.Continious));
|
||||
numberInput.SetDirection(In.GetAxis(JoystickSide.Both, InteractMode.Continious).x);
|
||||
|
||||
if (In.GetButtonAnyPlayer(PlayerAction.action))
|
||||
if (In.GetAction(JoystickSide.Both, InteractMode.Continious))
|
||||
{
|
||||
Prize prize = PrizeUtils.CreatePrize(CountablePrizeType.Hopper, numberInput.Value);
|
||||
Complete(prize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public class QrPrizeConfigurator : BasePrizeConfigurator, IControlable
|
||||
{
|
||||
textInput.UpdateControls();
|
||||
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.action))
|
||||
if (In.GetAction(JoystickSide.Both, InteractMode.Discrete))
|
||||
{
|
||||
Prize prize = PrizeUtils.CreatePrize(textInput.CollectText());
|
||||
Complete(prize);
|
||||
|
||||
@ -31,17 +31,17 @@ public class VitrinaPrizeConfigurator : BasePrizeConfigurator, IControlable
|
||||
|
||||
public override void UpdateControls()
|
||||
{
|
||||
var dir = In.GetAxis(Axis.Vertical, JoystickSide.Both);
|
||||
index = Mathf.Clamp(index + dir, 0, toggles.Count - 1);
|
||||
Vector2Int axes = In.GetAxis(JoystickSide.Both, InteractMode.Discrete);
|
||||
index = Mathf.Clamp(index + axes.y, 0, toggles.Count - 1);
|
||||
UpdPointerPos();
|
||||
|
||||
var toggleDir = In.GetAxis(Axis.Horizontal, JoystickSide.Both);
|
||||
int toggleDir = axes.x;
|
||||
if (toggleDir != 0)
|
||||
{
|
||||
toggles[index].SetValue(toggleDir > 0);
|
||||
}
|
||||
|
||||
if (In.GetButtonDownAnyPlayer(PlayerAction.action))
|
||||
if (In.GetAction(JoystickSide.Both, InteractMode.Discrete))
|
||||
{
|
||||
List<int> boxes = new();
|
||||
|
||||
@ -58,4 +58,4 @@ public class VitrinaPrizeConfigurator : BasePrizeConfigurator, IControlable
|
||||
Complete(prize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ public class QrPanel : MonoBehaviour
|
||||
|
||||
bool CollectInputs()
|
||||
{
|
||||
bool action = In.GetButtonAnyPlayer(PlayerAction.left);
|
||||
bool action = In.GetAction(JoystickSide.Both, InteractMode.Continious);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
@ -47,12 +47,12 @@ public class PrizesSelector : MonoBehaviour
|
||||
if (_availablePrizesTable.prizeButtons == null) return;
|
||||
if (_availablePrizesTable.prizeButtons.Count == 0) return;
|
||||
|
||||
index = index - In.GetAxis(Axis.Vertical, JoystickSide.Both);
|
||||
index -= In.GetAxis(JoystickSide.Both, InteractMode.Discrete).y;
|
||||
index = Mathf.Clamp(index, 0, _availablePrizesTable.prizeButtons.Count);
|
||||
pointer.position = _availablePrizesTable.prizeButtons[index].transform.position;
|
||||
|
||||
|
||||
if (In.GetButtonAnyPlayer(PlayerAction.action))
|
||||
if (In.GetAction(JoystickSide.Both, InteractMode.Continious))
|
||||
{
|
||||
_availablePrizesTable.prizeButtons[index].ClickAnimation();
|
||||
}
|
||||
@ -75,4 +75,4 @@ public class PrizesSelector : MonoBehaviour
|
||||
view.SetPrize(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,9 +147,8 @@ public class VitrinaPanel : MonoBehaviour
|
||||
|
||||
(int direction, bool action) CollectInputs()
|
||||
{
|
||||
int direction = (In.GetButtonDownAnyPlayer(PlayerAction.right) ? 1 : 0) -
|
||||
(In.GetButtonDownAnyPlayer(PlayerAction.left) ? 1 : 0);
|
||||
bool action = In.GetButtonAnyPlayer(PlayerAction.down);
|
||||
int direction = In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x;
|
||||
bool action = In.GetAction(JoystickSide.Both, InteractMode.Continious);
|
||||
return (direction, action);
|
||||
}
|
||||
|
||||
|
||||
@ -45,26 +45,31 @@ public class SettingsScreen : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
if(controlsBlocked && In.GetButtonAnyPlayer(PlayerAction.action) == false)
|
||||
if(controlsBlocked && In.GetAction(JoystickSide.Both, InteractMode.Continious) == false)
|
||||
controlsBlocked = false;
|
||||
|
||||
if (controlsBlocked)
|
||||
return;
|
||||
|
||||
int switchDirection = -In.GetAxis(switchAxis, JoystickSide.Both);
|
||||
Vector2Int switchAxes = In.GetAxis(JoystickSide.Both, InteractMode.Discrete);
|
||||
int switchDirection = -GetAxisValue(switchAxes, switchAxis);
|
||||
|
||||
if (switchDirection != 0)
|
||||
SwitchSetting(switchDirection);
|
||||
|
||||
int interactDirection = In.GetAxis(interactAxis, JoystickSide.Both, InteractMode.Continious);
|
||||
bool action = In.GetButtonAnyPlayer(PlayerAction.action);
|
||||
Vector2Int interactAxes = In.GetAxis(JoystickSide.Both, InteractMode.Continious);
|
||||
int interactDirection = GetAxisValue(interactAxes, interactAxis);
|
||||
bool action = In.GetAction(JoystickSide.Both, InteractMode.Continious);
|
||||
SelectedSetting.TakeInput(interactDirection, action);
|
||||
|
||||
if(_exitTimer.Update(In.GetButton(InSignal.secret)))
|
||||
if(_exitTimer.Update(In.GetService()))
|
||||
{
|
||||
_menuSettingsTransit.GotoMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetAxisValue(Vector2Int axes, Axis axis)
|
||||
=> axis == Axis.Horizontal ? axes.x : axes.y;
|
||||
|
||||
public void Generate()
|
||||
{
|
||||
@ -146,4 +151,4 @@ public class SettingsScreen : MonoBehaviour, IControlable
|
||||
|
||||
scrollRect.verticalNormalizedPosition = newPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,16 +41,16 @@ public class TextInput : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
int dir_h = In.GetAxis(Axis.Horizontal, JoystickSide.Both, InteractMode.Discrete);
|
||||
int dir_h = In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x;
|
||||
SwitchSlot(dir_h);
|
||||
|
||||
int dir_v = In.GetAxis(Axis.Vertical, JoystickSide.Both, InteractMode.Continious);
|
||||
int dir_v = In.GetAxis(JoystickSide.Both, InteractMode.Continious).y;
|
||||
SwitchLetter(dir_v);
|
||||
|
||||
if(In.GetButtonAnyPlayer(PlayerAction.action) == false)
|
||||
if(In.GetAction(JoystickSide.Both, InteractMode.Continious) == false)
|
||||
completeUnpressed = true;
|
||||
|
||||
completionRequested = In.GetButtonAnyPlayer(PlayerAction.action);
|
||||
completionRequested = In.GetAction(JoystickSide.Both, InteractMode.Continious);
|
||||
if (completionRequested && completeUnpressed)
|
||||
Complete();
|
||||
}
|
||||
@ -150,4 +150,4 @@ public class TextInput : MonoBehaviour, IControlable
|
||||
sb.Append(slot.Symbol);
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ public class Menu : MonoBehaviour, IControlable
|
||||
return;
|
||||
|
||||
//переход настройки
|
||||
if (_settingsTimer.Update(In.GetButton(InSignal.secret)))
|
||||
if (_settingsTimer.Update(In.GetService()))
|
||||
{
|
||||
_menuSettingsTransit.GotoSettings();
|
||||
return;
|
||||
@ -48,10 +48,10 @@ public class Menu : MonoBehaviour, IControlable
|
||||
|
||||
public void UpdateControls()
|
||||
{
|
||||
int direction_horizontal = In.GetAxis(Axis.Horizontal, JoystickSide.Both);
|
||||
int direction_horizontal = In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x;
|
||||
menuPanelManager.SwitchPanel(direction_horizontal);
|
||||
|
||||
bool action = In.GetButtonDownAnyPlayer(PlayerAction.action);
|
||||
bool action = In.GetAction(JoystickSide.Both, InteractMode.Discrete);
|
||||
if (action)
|
||||
menuPanelManager.InteractCurrent();
|
||||
}
|
||||
@ -80,4 +80,4 @@ public class Menu : MonoBehaviour, IControlable
|
||||
_promoTimer.Reset();
|
||||
_settingsTimer.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class MenuPanelsScroll : MenuPanel
|
||||
{
|
||||
if (!m_enabled || isTransitioning) return;
|
||||
|
||||
int dir_v = -In.GetAxis(Axis.Vertical, JoystickSide.Both);
|
||||
int dir_v = -In.GetAxis(JoystickSide.Both, InteractMode.Discrete).y;
|
||||
if (dir_v != 0)
|
||||
StartCoroutine(SwitchPanelCoroutine(dir_v));
|
||||
}
|
||||
@ -102,4 +102,4 @@ public class MenuPanelsScroll : MenuPanel
|
||||
}
|
||||
|
||||
public override void Interact() => currentPanel.Interact();
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class VitrinaCatcher : MonoBehaviour
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (animating && In.GetButtonDownAnyPlayer(PlayerAction.right))
|
||||
if (animating && In.GetAxis(JoystickSide.Both, InteractMode.Discrete).x > 0)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
Hide();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user