feat(inputs): remove obsolete COM input system and update dependencies
- Removed deprecated ButtonPinMapping enum and related COM input classes- Updated ComInputToInputSystemAdapter with improved binding logic- Refactored GameManager to use new globals prefab path - Enhanced GameEndUIController with event system focus management - Modified Globals prefab to use pin-based input bindings - Cleaned up obsolete COM system wrapper and native wrapper classes - Adjusted input adapter to support pin bindings over action bindings - Updated manufacturer name in virtual gamepad description
This commit is contained in:
parent
868089344b
commit
2f2d100eae
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -101,30 +101,30 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::ComInputToInputSystemAdapter
|
||||
useAnyPlayer: 1
|
||||
actionBindings:
|
||||
- action: 0
|
||||
target: 0
|
||||
actionBindings: []
|
||||
pinBindings:
|
||||
- pinIndex: 0
|
||||
target: 1
|
||||
button: 0
|
||||
dpadDirection: 0
|
||||
- action: 1
|
||||
target: 0
|
||||
button: 1
|
||||
dpadDirection: 1
|
||||
- action: 2
|
||||
target: 0
|
||||
- pinIndex: 3
|
||||
target: 1
|
||||
button: 2
|
||||
dpadDirection: 2
|
||||
- action: 3
|
||||
target: 0
|
||||
- pinIndex: 1
|
||||
target: 1
|
||||
button: 3
|
||||
dpadDirection: 3
|
||||
- action: 4
|
||||
- pinIndex: 2
|
||||
target: 0
|
||||
button: 12
|
||||
dpadDirection: 3
|
||||
- action: 5
|
||||
button: 6
|
||||
dpadDirection: 1
|
||||
- pinIndex: 4
|
||||
target: 0
|
||||
button: 13
|
||||
dpadDirection: 3
|
||||
pinBindings: []
|
||||
button: 5
|
||||
dpadDirection: 0
|
||||
- pinIndex: 10
|
||||
target: 0
|
||||
button: 10
|
||||
dpadDirection: 1
|
||||
logCreateDevice: 1
|
||||
|
||||
@ -2821,8 +2821,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 0bc7d3e0d74d74448be804ed4f109e23, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
moveAction: {fileID: -1680190386980627800, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
jumpAction: {fileID: -2099379676528639254, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
moveAction: {fileID: 7246501485463929903, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
jumpAction: {fileID: -3012215356801305305, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
moveSpeed: 9
|
||||
accel: 100
|
||||
decel: 30
|
||||
@ -2864,7 +2864,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 4e22b17be0e015040bb8efb0e96fa590, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
fireButton: {fileID: 5543754354036874770, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
fireButton: {fileID: 1757590381408031877, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
projectilePrefab: {fileID: 4169089013277977673, guid: 7fd3a37dc702ece42b51e5867473f0ff, type: 3}
|
||||
spawnIfMissing: 0
|
||||
throwSpeed: 20
|
||||
|
||||
@ -774,17 +774,17 @@ MonoBehaviour:
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_PointAction: {fileID: 1054132383583890850, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_MoveAction: {fileID: 3710738434707379630, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_SubmitAction: {fileID: 2064916234097673511, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_CancelAction: {fileID: 5054652661136980948, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_LeftClickAction: {fileID: -2213530898654114922, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_MiddleClickAction: {fileID: -736626283275062212, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_RightClickAction: {fileID: 6823006721379835850, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_ScrollWheelAction: {fileID: -1397063225743762887, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 8111645563656012570, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: -439368142081375595, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
@ -3764,7 +3764,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 55d821bd8bf8bb14c857f497ec6f2a0d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
close: {fileID: 7727032971491509709, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
close: {fileID: 5054652661136980948, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
panel: {fileID: 1946308725}
|
||||
resumeButton: {fileID: 1065887711}
|
||||
quitButton: {fileID: 1294478665}
|
||||
|
||||
@ -402971,6 +402971,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: LevelSpecificPlayerSFX
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1393790780435193682, guid: 4871f8ebaa803cd44900fa7f708836e4, type: 3}
|
||||
propertyPath: levelStepSounds
|
||||
value:
|
||||
objectReference: {fileID: 11400000, guid: 37fe07ddcac109a46a86ba44df16d551, type: 2}
|
||||
- target: {fileID: 3117561262541012963, guid: 4871f8ebaa803cd44900fa7f708836e4, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -24.01362
|
||||
|
||||
@ -1034,7 +1034,7 @@ MonoBehaviour:
|
||||
m_HandleRect: {fileID: 434895585}
|
||||
m_Direction: 2
|
||||
m_Value: 0
|
||||
m_Size: 0.9957961
|
||||
m_Size: 0.999998
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
@ -2946,17 +2946,17 @@ MonoBehaviour:
|
||||
m_MoveRepeatDelay: 0.5
|
||||
m_MoveRepeatRate: 0.1
|
||||
m_XRTrackingOrigin: {fileID: 0}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
|
||||
m_ActionsAsset: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_PointAction: {fileID: 1054132383583890850, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_MoveAction: {fileID: 3710738434707379630, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_SubmitAction: {fileID: 2064916234097673511, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_CancelAction: {fileID: 5054652661136980948, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_LeftClickAction: {fileID: -2213530898654114922, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_MiddleClickAction: {fileID: -736626283275062212, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_RightClickAction: {fileID: 6823006721379835850, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_ScrollWheelAction: {fileID: -1397063225743762887, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_TrackedDevicePositionAction: {fileID: 8111645563656012570, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_TrackedDeviceOrientationAction: {fileID: -439368142081375595, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
@ -4540,7 +4540,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -0.000009311028}
|
||||
m_AnchoredPosition: {x: 0, y: 0.00043223458}
|
||||
m_SizeDelta: {x: 0, y: 300}
|
||||
m_Pivot: {x: 0, y: 1}
|
||||
--- !u!114 &1792218764
|
||||
|
||||
@ -57,18 +57,10 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
EnsureVirtualGamepad();
|
||||
TryAddDefaultBindingsIfEmpty();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void OnEnable() => EnsureVirtualGamepad();
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Обычно устройство не удаляем, чтобы не ломать PlayerInput при живых сценах.
|
||||
// Если нужно строго чистить — раскомментируй:
|
||||
// if (_virtualPad != null) { InputSystem.RemoveDevice(_virtualPad); _virtualPad = null; _deviceCreated = false; }
|
||||
}
|
||||
private void OnEnable() => Initialize();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@ -77,9 +69,8 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
_state = default;
|
||||
|
||||
// 1) По действиям
|
||||
for (int i = 0; i < actionBindings.Count; i++)
|
||||
foreach (ActionBinding b in actionBindings)
|
||||
{
|
||||
var b = actionBindings[i];
|
||||
bool pressed = useAnyPlayer
|
||||
? In.GetButtonAnyPlayer(b.action)
|
||||
: In.GetButtonCurrentPlayer(b.action);
|
||||
@ -88,9 +79,8 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
}
|
||||
|
||||
// 2) По пинам
|
||||
for (int i = 0; i < pinBindings.Count; i++)
|
||||
foreach (PinBinding b in pinBindings)
|
||||
{
|
||||
var b = pinBindings[i];
|
||||
bool pressed = In.GetButton(b.pinIndex);
|
||||
ApplyBinding(ref _state, b.target, b.button, b.dpadDirection, pressed);
|
||||
}
|
||||
@ -99,6 +89,12 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
// Обновлять InputSystem вручную не нужно (обновится в цикле Unity)
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
EnsureVirtualGamepad();
|
||||
TryAddDefaultBindingsIfEmpty();
|
||||
}
|
||||
|
||||
private static void ApplyBinding(ref GamepadState st, TargetTarget target, GamepadButton btn, DpadDir dir, bool pressed)
|
||||
{
|
||||
if (!pressed) return;
|
||||
@ -109,13 +105,14 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (dir)
|
||||
st = dir switch
|
||||
{
|
||||
case DpadDir.Up: st = st.WithButton(GamepadButton.DpadUp, true); break;
|
||||
case DpadDir.Down: st = st.WithButton(GamepadButton.DpadDown, true); break;
|
||||
case DpadDir.Left: st = st.WithButton(GamepadButton.DpadLeft, true); break;
|
||||
case DpadDir.Right: st = st.WithButton(GamepadButton.DpadRight, true); break;
|
||||
}
|
||||
DpadDir.Up => st.WithButton(GamepadButton.DpadUp, true),
|
||||
DpadDir.Down => st.WithButton(GamepadButton.DpadDown, true),
|
||||
DpadDir.Left => st.WithButton(GamepadButton.DpadLeft, true),
|
||||
DpadDir.Right => st.WithButton(GamepadButton.DpadRight, true),
|
||||
_ => st
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,20 +123,18 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
// ищем уже созданный «COM Bridge», чтобы не дублировать
|
||||
foreach (var dev in InputSystem.devices)
|
||||
{
|
||||
if (dev is Gamepad gp && gp.description.product == "COM Bridge Gamepad")
|
||||
{
|
||||
_virtualPad = gp;
|
||||
_deviceCreated = true;
|
||||
return;
|
||||
}
|
||||
if (dev is not Gamepad { description: { product: "COM Bridge Gamepad" } } gp) continue;
|
||||
_virtualPad = gp;
|
||||
_deviceCreated = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var desc = new InputDeviceDescription
|
||||
InputDeviceDescription desc = new()
|
||||
{
|
||||
interfaceName = "Virtual",
|
||||
deviceClass = "Gamepad",
|
||||
product = "COM Bridge Gamepad",
|
||||
manufacturer = "YourCompany"
|
||||
manufacturer = "Robotic Retailers"
|
||||
};
|
||||
|
||||
_virtualPad = (Gamepad)InputSystem.AddDevice(desc);
|
||||
@ -150,18 +145,18 @@ public class ComInputToInputSystemAdapter : MonoBehaviour
|
||||
private void TryAddDefaultBindingsIfEmpty()
|
||||
{
|
||||
// Если пусто — добавим базовый маппинг стрелок на D-Pad.
|
||||
if (actionBindings.Count == 0)
|
||||
{
|
||||
// Переименуй ниже на свои реальные имена в enum PlayerAction, если отличаются.
|
||||
TryAddActionBinding(PlayerAction.up, TargetTarget.Dpad, GamepadButton.North, DpadDir.Up);
|
||||
TryAddActionBinding(PlayerAction.down, TargetTarget.Dpad, GamepadButton.South, DpadDir.Down);
|
||||
TryAddActionBinding(PlayerAction.left, TargetTarget.Dpad, GamepadButton.West, DpadDir.Left);
|
||||
TryAddActionBinding(PlayerAction.right, TargetTarget.Dpad, GamepadButton.East, DpadDir.Right);
|
||||
// Часто удобно:
|
||||
// Confirm -> South (A), Back/Cancel -> East (B)
|
||||
SafeTry(() => actionBindings.Add(new ActionBinding { action = PlayerAction.action, target = TargetTarget.Button, button = GamepadButton.South, dpadDirection = DpadDir.Up }));
|
||||
SafeTry(() => actionBindings.Add(new ActionBinding { action = PlayerAction.extra, target = TargetTarget.Button, button = GamepadButton.East, dpadDirection = DpadDir.Up }));
|
||||
}
|
||||
if (actionBindings.Count != 0) return;
|
||||
|
||||
TryAddActionBinding(PlayerAction.up, TargetTarget.Dpad, GamepadButton.North, DpadDir.Up);
|
||||
TryAddActionBinding(PlayerAction.down, TargetTarget.Dpad, GamepadButton.South, DpadDir.Down);
|
||||
TryAddActionBinding(PlayerAction.left, TargetTarget.Dpad, GamepadButton.West, DpadDir.Left);
|
||||
TryAddActionBinding(PlayerAction.right, TargetTarget.Dpad, GamepadButton.East, DpadDir.Right);
|
||||
|
||||
TryAddActionBinding(PlayerAction.action, TargetTarget.Button, GamepadButton.South, DpadDir.Up);
|
||||
TryAddActionBinding(PlayerAction.action, TargetTarget.Button, GamepadButton.East, DpadDir.Up);
|
||||
|
||||
// SafeTry(() => actionBindings.Add(new ActionBinding { action = PlayerAction.action, target = TargetTarget.Button, button = GamepadButton.South, dpadDirection = DpadDir.Up }));
|
||||
// SafeTry(() => actionBindings.Add(new ActionBinding { action = PlayerAction.extra, target = TargetTarget.Button, button = GamepadButton.East, dpadDirection = DpadDir.Up }));
|
||||
}
|
||||
|
||||
private void TryAddActionBinding(PlayerAction action, TargetTarget target, GamepadButton btn, DpadDir dir)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
using RR.Game2D.Core.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
public class COMinput : InputSource
|
||||
public class COMInput : InputSource
|
||||
{
|
||||
//Количество = цифровые + 2 датчика.
|
||||
//На момент написания количество цифровых входов 7*N.
|
||||
@ -19,7 +19,7 @@ public class In : MonoBehaviour
|
||||
[Header("Выбор источника управления")]
|
||||
[SerializeField] private InputSourceType inputType;
|
||||
|
||||
static InputSource source;
|
||||
private static InputSource source;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализирует систему ввода на основе выбранного типа.
|
||||
@ -35,11 +35,13 @@ public class In : MonoBehaviour
|
||||
source = inputType switch
|
||||
{
|
||||
InputSourceType.Keyboard => new KeyboardInput(),
|
||||
InputSourceType.COM => new COMinput(),
|
||||
_ => throw new System.NotImplementedException()
|
||||
InputSourceType.COM => new COMInput(),
|
||||
// _ => throw new System.NotImplementedException()
|
||||
_ => null
|
||||
};
|
||||
|
||||
var success = source.Initialize();
|
||||
|
||||
var success = source?.Initialize() ?? false;
|
||||
if (!success) Debug.LogWarning("Не удалось проинициалзировать источник управления.");
|
||||
}
|
||||
|
||||
@ -57,13 +59,13 @@ public class In : MonoBehaviour
|
||||
public static bool GetButtonUp(ButtonPinMapping button) => source.GetButtonUp(button);
|
||||
|
||||
/// <summary>Проверяет состояние кнопки по числовому индексу пина</summary>
|
||||
public static bool GetButton(int pinindex) => source.GetButton(pinindex);
|
||||
public static bool GetButton(int pinIndex) => source.GetButton(pinIndex);
|
||||
|
||||
/// <summary>Проверяет нажатие кнопки по индексу пина в текущем кадре</summary>
|
||||
public static bool GetButtonDown(int pinindex) => source.GetButtonDown(pinindex);
|
||||
public static bool GetButtonDown(int pinIndex) => source.GetButtonDown(pinIndex);
|
||||
|
||||
/// <summary>Проверяет отпускание кнопки по индексу пина в текущем кадре</summary>
|
||||
public static bool GetButtonUp(int pinindex) => source.GetButtonUp(pinindex);
|
||||
public static bool GetButtonUp(int pinIndex) => source.GetButtonUp(pinIndex);
|
||||
|
||||
// ================================================================================
|
||||
// СТАТИЧЕСКИЕ МЕТОДЫ ДЛЯ РАБОТЫ С АБСТРАКТНЫМИ ДЕЙСТВИЯМИ ИГРОКОВ
|
||||
@ -21,7 +21,7 @@ namespace RR.Game2D.Core.Managers
|
||||
// Globals
|
||||
[Header("Globals")]
|
||||
private GameObject globals;
|
||||
[SerializeField] private string globalsPrefabResourcePath = "Prefabs/Globals";
|
||||
[SerializeField] private string globalsPrefabResourcePath = "Prefabs/Global/Globals";
|
||||
|
||||
[Header("Пауза")]
|
||||
public bool IsPaused { get; private set; }
|
||||
@ -60,12 +60,10 @@ namespace RR.Game2D.Core.Managers
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void Bootstrap()
|
||||
{
|
||||
GameObject go;
|
||||
|
||||
if (Instance == null)
|
||||
{
|
||||
go = new GameObject(nameof(GameManager));
|
||||
Instance = go.AddComponent<GameManager>();
|
||||
GameObject go = new GameObject(nameof(GameManager));
|
||||
Instance = go.AddComponent<GameManager>();
|
||||
DontDestroyOnLoad(go);
|
||||
}
|
||||
// else
|
||||
|
||||
@ -9,12 +9,14 @@ namespace RR.Common.Managers
|
||||
private ComWrapper _comWrapper;
|
||||
private In _in;
|
||||
private PrizeSystem _prizeSystem;
|
||||
private ComInputToInputSystemAdapter _adapter;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_comWrapper = GetComponent<ComWrapper>();
|
||||
_in = GetComponent<In>();
|
||||
_prizeSystem = GetComponent<PrizeSystem>();
|
||||
_adapter = GetComponent<ComInputToInputSystemAdapter>();
|
||||
|
||||
if (_comWrapper == null) gameObject.AddComponent<ComWrapper>();
|
||||
if (_in == null) gameObject.AddComponent<In>();
|
||||
@ -23,6 +25,7 @@ namespace RR.Common.Managers
|
||||
_comWrapper.Initialize();
|
||||
_in.Initialize();
|
||||
_prizeSystem.Initialize();
|
||||
_adapter.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ using UnityEngine.UI;
|
||||
|
||||
using RR.Game2D.Core.Managers;
|
||||
using TMPro;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace RR.Common.UI
|
||||
{
|
||||
@ -71,19 +72,28 @@ namespace RR.Common.UI
|
||||
|
||||
private void OnGameWon(float gameTime)
|
||||
{
|
||||
WinBannerShown?.Invoke(gameTime);
|
||||
GameManager.Instance.SetPause(true);
|
||||
winText.text = $"Время игры: {GameEndUIController.FormatTime(gameTime)}";
|
||||
|
||||
GetComponent<Image>().color = new Color(0, 0,0, 100f/255f);
|
||||
|
||||
winText.text = $"Время игры: {GameEndUIController.FormatTime(gameTime)}";
|
||||
SetVisible(winPanel, true);
|
||||
|
||||
EventSystem.current.firstSelectedGameObject = mainMenuButtonWin.gameObject;
|
||||
EventSystem.current.SetSelectedGameObject(mainMenuButtonWin.gameObject);
|
||||
|
||||
WinBannerShown?.Invoke(gameTime);
|
||||
}
|
||||
|
||||
private void OnGameOver(float gameTime)
|
||||
{
|
||||
LoseBannerShown?.Invoke(gameTime);
|
||||
GameManager.Instance.SetPause(true);
|
||||
|
||||
GetComponent<Image>().color = new Color(0, 0,0, 100f/255f);
|
||||
|
||||
SetVisible(losePanel, true);
|
||||
|
||||
LoseBannerShown?.Invoke(gameTime);
|
||||
}
|
||||
|
||||
private void SetVisible(CanvasGroup canvasGroup, bool visible, bool instant = false)
|
||||
|
||||
@ -43,7 +43,7 @@ namespace RR.Common.UI
|
||||
/// <summary>
|
||||
/// Метод для закрытия модального окна
|
||||
/// </summary>
|
||||
public void Close()
|
||||
private void Close()
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(Fade(1f, 0f, fadeDuration, () => gameObject.SetActive(false)));
|
||||
@ -55,7 +55,7 @@ namespace RR.Common.UI
|
||||
/// </summary>
|
||||
void BuildIfNeeded()
|
||||
{
|
||||
// Очистим/пересоберём (можно кэшировать, но пересборка надёжнее при изменениях Build Settings)
|
||||
// Очистим/пересоберём
|
||||
foreach (var b in _levelsPool) if (b) Destroy(b.gameObject);
|
||||
_levelsPool.Clear();
|
||||
|
||||
@ -88,19 +88,19 @@ namespace RR.Common.UI
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
string path = SceneUtility.GetScenePathByBuildIndex(i);
|
||||
string name = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
string buttonName = System.IO.Path.GetFileNameWithoutExtension(path);
|
||||
|
||||
// фильтр "только уровни" по формату имени W-S:
|
||||
var parts = name.Split('-');
|
||||
var parts = buttonName.Split('-');
|
||||
if (parts.Length != 2) continue;
|
||||
if (!int.TryParse(parts[0], out int world)) continue;
|
||||
if (!int.TryParse(parts[1], out int stage)) continue;
|
||||
|
||||
// Исключим служебные сцены, даже если вдруг совпадут по формату (на всякий случай)
|
||||
if (name.Equals("Level UI", System.StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (name.Equals("MainMenu", System.StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (buttonName.Equals("Level UI", System.StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (buttonName.Equals("MainMenu", System.StringComparison.OrdinalIgnoreCase)) continue;
|
||||
|
||||
yield return new LevelEntry { name = name, world = world, stage = stage };
|
||||
yield return new LevelEntry { name = buttonName, world = world, stage = stage };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ using TMPro;
|
||||
|
||||
using RR.Common.UI;
|
||||
using RR.Game2D.Core.Managers;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class LoseBannerController : MonoBehaviour
|
||||
{
|
||||
@ -49,6 +50,9 @@ public class LoseBannerController : MonoBehaviour
|
||||
|
||||
private void OnLoseBannerShown(float gameTime)
|
||||
{
|
||||
// EventSystem.current.firstSelectedGameObject = continueButton.gameObject;
|
||||
EventSystem.current.SetSelectedGameObject(continueButton.gameObject);
|
||||
|
||||
loseText.text = $"Время игры: {GameEndUIController.FormatTime(gameTime)}";
|
||||
|
||||
if (continueButtonCountdown <= 0f)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
using RR.Game2D.Core.Managers;
|
||||
|
||||
@ -52,7 +53,7 @@ namespace RR.Common.UI
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (close.action.WasPressedThisFrame())
|
||||
if (close.action.WasPressedThisFrame() && !GameManager.Instance.IsPaused)
|
||||
GameManager.Instance.TogglePause();
|
||||
}
|
||||
|
||||
@ -63,6 +64,13 @@ namespace RR.Common.UI
|
||||
private void HandlePauseChanged(bool paused)
|
||||
{
|
||||
if (!isActive) return;
|
||||
|
||||
if (paused)
|
||||
{
|
||||
EventSystem.current.firstSelectedGameObject = resumeButton.gameObject;
|
||||
EventSystem.current.SetSelectedGameObject(resumeButton.gameObject);
|
||||
}
|
||||
|
||||
SetVisible(paused);
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +303,35 @@
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "ad8b71a2bbaa4decb561f019a08e8626"
|
||||
"m_Id": "7532ac6874ca4862bc00d22c83764a03"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "2557d04087964c2984053e91fb28be73"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "a82fe793d3ea49e79295b0692ecefdb2"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "2557d04087964c2984053e91fb28be73"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b2cc0d067ee24641a376219e21246f2c"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
@ -345,7 +373,7 @@
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "2557d04087964c2984053e91fb28be73"
|
||||
"m_Id": "ad8b71a2bbaa4decb561f019a08e8626"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
@ -723,35 +751,7 @@
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "7532ac6874ca4862bc00d22c83764a03"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "ad8b71a2bbaa4decb561f019a08e8626"
|
||||
},
|
||||
"m_SlotId": 1
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "a82fe793d3ea49e79295b0692ecefdb2"
|
||||
},
|
||||
"m_SlotId": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"m_OutputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "ad8b71a2bbaa4decb561f019a08e8626"
|
||||
},
|
||||
"m_SlotId": 1
|
||||
},
|
||||
"m_InputSlot": {
|
||||
"m_Node": {
|
||||
"m_Id": "b2cc0d067ee24641a376219e21246f2c"
|
||||
"m_Id": "2557d04087964c2984053e91fb28be73"
|
||||
},
|
||||
"m_SlotId": 0
|
||||
}
|
||||
@ -1841,9 +1841,9 @@
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": -1032.0001220703125,
|
||||
"y": 336.0000305175781,
|
||||
"width": 208.00006103515626,
|
||||
"x": -795.0001220703125,
|
||||
"y": 335.0000305175781,
|
||||
"width": 208.0,
|
||||
"height": 302.0000305175781
|
||||
}
|
||||
},
|
||||
@ -2073,7 +2073,7 @@
|
||||
"m_Title": "Outline",
|
||||
"m_Position": {
|
||||
"x": -1057.0,
|
||||
"y": 277.0
|
||||
"y": 276.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -4698,9 +4698,9 @@
|
||||
"m_Expanded": true,
|
||||
"m_Position": {
|
||||
"serializedVersion": "2",
|
||||
"x": -795.0000610351563,
|
||||
"y": 336.0000305175781,
|
||||
"width": 208.0,
|
||||
"x": -1032.0001220703125,
|
||||
"y": 335.0000305175781,
|
||||
"width": 207.99993896484376,
|
||||
"height": 278.0000305175781
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user