Внедрил панель

This commit is contained in:
vladislav 2026-09-22 21:30:29 +03:00
parent f12b4aef0d
commit e11ce6a0b0
6 changed files with 226 additions and 255 deletions

View File

@ -416,7 +416,7 @@ MonoBehaviour:
m_EditorClassIdentifier: Assembly-CSharp::SensitivitySettings
sensSlider: {fileID: 1132307725}
sensInputField: {fileID: 1484500464}
playerController: {fileID: 4981087443884052949}
playerController: {fileID: 0}
minSens: 0.01
maxSens: 3
defaultSens: 0.1
@ -1139,135 +1139,6 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &56642862
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 56642863}
- component: {fileID: 56642864}
m_Layer: 0
m_Name: Audio Source
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &56642863
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 56642862}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 579782704305556181}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &56642864
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 56642862}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1001 &57146242
PrefabInstance:
m_ObjectHideFlags: 0
@ -4657,7 +4528,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.UIPanel
panel: {fileID: 474561344}
playerController: {fileID: 4981087443884052949}
playerController: {fileID: 0}
--- !u!4 &217181662
Transform:
m_ObjectHideFlags: 0
@ -41728,7 +41599,6 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5685763764745351606}
- {fileID: 56642863}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &658088287044371806 stripped
@ -41870,13 +41740,19 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 579782704305556181}
- component: {fileID: 4300447627476761733}
- component: {fileID: 4981087443884052950}
- component: {fileID: 4981087443884052956}
- component: {fileID: 4981087443884052955}
- component: {fileID: 4981087443884052954}
- component: {fileID: 4981087443884052953}
- component: {fileID: 4981087443884052952}
- component: {fileID: 488871142510447707}
- component: {fileID: 4981087443884052949}
- component: {fileID: 4300447627476761733}
- component: {fileID: 4981087443884052951}
m_Layer: 0
m_Name: Capsule
m_Name: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_Icon: {fileID: -5442936267250999957, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
@ -42963,7 +42839,7 @@ Transform:
m_CorrespondingSourceObject: {fileID: 1672666446545052606, guid: 51510de34f82041149d25090ec962e10, type: 3}
m_PrefabInstance: {fileID: 638907945}
m_PrefabAsset: {fileID: 0}
--- !u!114 &4981087443884052949
--- !u!114 &4981087443884052950
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@ -42972,12 +42848,118 @@ MonoBehaviour:
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ccd7be85b667fd167ba4d40900740d07, type: 3}
m_Script: {fileID: 11500000, guid: 75b0375d82064442a50d4b6cf42048bb, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::PlayerController
cameraPosition: {fileID: 5685763764745351606}
mouseSensitivity: 0.1
maxLookAngle: 80
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.Player
--- !u!82 &4981087443884052951
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!114 &4981087443884052952
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d9d6178191654e72a147db739b22275f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.PlayerUtils.PlayerCombat
damage: 25
fireRate: 0.12
weaponRange: 100
@ -42988,14 +42970,50 @@ MonoBehaviour:
recoilKick: 1.2
muzzleFlash: {fileID: 0}
impactPrefab: {fileID: 0}
shootSound: {fileID: 0}
cameraPosition: {fileID: 5685763764745351606}
--- !u!114 &4981087443884052953
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbe0b1999f6642cdb1f20dadcd7c0934, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.PlayerUtils.PlayerCamera
cameraPosition: {fileID: 5685763764745351606}
mouseSensitivity: 0.1
maxLookAngle: 80
standingCameraY: 1.6
crouchingCameraY: 0.8
crouchTransitionSpeed: 15
slideCameraTiltAngle: 4
enableHeadBob: 1
walkBobSpeed: 10
walkBobAmount: 0.1
sprintBobSpeed: 18
sprintBobAmount: 0.07
impactRecoverySpeed: 6
--- !u!114 &4981087443884052954
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51301269a09843b8af775b231056fa86, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.PlayerUtils.PlayerMovement
moveSpeed: 10
sprintSpeed: 18
crouchSpeed: 5
slideInitialSpeed: 50
slideDuration: 0.85
slideFriction: 2.8
slideCameraTiltAngle: 4
slideCooldown: 0.35
groundFriction: 5
groundAcceleration: 10
@ -43010,18 +43028,22 @@ MonoBehaviour:
m_Bits: 8
groundCheckDistance: 0.1
jumpBufferTime: 0.12
standingHeight: 1.8
crouchingHeight: 1
standingCameraY: 1.7
crouchingCameraY: 0.8
crouchTransitionSpeed: 10
enableHeadBob: 1
walkBobSpeed: 10
walkBobAmount: 0.1
sprintBobSpeed: 15
sprintBobAmount: 0.07
impactRecoverySpeed: 6
audioSource: {fileID: 56642864}
standingHeight: 2
crouchingHeight: 1.05
crouchTransitionSpeed: 15
--- !u!114 &4981087443884052955
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 995d210808ca417ca08ca58fab7f8624, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.PlayerUtils.PlayerSound
audioSource: {fileID: 4981087443884052951}
footstepSounds:
- {fileID: 8300000, guid: 08c17b453ac53b802a4b8e15746a2da9, type: 3}
- {fileID: 8300000, guid: 18afd667ba6e9a4e8b516f0ff35791ff, type: 3}
@ -43036,6 +43058,20 @@ MonoBehaviour:
jumpSound: {fileID: 0}
landSound: {fileID: 0}
slideSound: {fileID: 0}
shootSound: {fileID: 0}
--- !u!114 &4981087443884052956
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1033791869251556189}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8184cc49f30946f4802bbf1bbe841e2f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::_Project.Scripts.PlayerUtils.PlayerUI
showSpeedometer: 1
--- !u!4 &5016588167603968964 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 1672666446545052606, guid: 51510de34f82041149d25090ec962e10, type: 3}

View File

@ -1,7 +1,8 @@
using UnityEngine;
using _Project.Scripts.PlayerUtils;
using _Project.Scripts.Utilities;
using UnityEngine;
namespace _Project.Scripts.PlayerUtils
namespace _Project.Scripts
{
public class Player : MonoSingleton<Player>
{
@ -11,7 +12,7 @@ namespace _Project.Scripts.PlayerUtils
public PlayerCamera CameraController { get; private set; }
public PlayerCombat Combat { get; private set; }
public PlayerSound Sound { get; private set; }
public PlayerUI UI { get; private set; } // Новый модуль
public PlayerUI UI { get; private set; }
protected override void Awake()
{
@ -23,7 +24,7 @@ namespace _Project.Scripts.PlayerUtils
CameraController = GetComponent<PlayerCamera>();
Combat = GetComponent<PlayerCombat>();
Sound = GetComponent<PlayerSound>();
UI = GetComponent<PlayerUI>(); // Инициализация
UI = GetComponent<PlayerUI>();
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;

View File

@ -1,56 +0,0 @@
using UnityEngine;
public class PlayerStats : MonoBehaviour
{
[Header("Камера и Мышь")]
public float mouseSensitivity = 0.1f;
public float maxLookAngle = 80f;
[Header("Скорости передвижения (м/с)")]
public float moveSpeed = 6.5f;
public float sprintSpeed = 9.5f;
public float crouchSpeed = 3f;
[Header("Параметры Подката (Slide)")]
public float slideInitialSpeed = 15f;
public float slideDuration = 0.85f;
public float slideFriction = 2.8f;
public float slideCameraTiltAngle = 4f;
public float slideCooldown = 0.35f;
[Header("Физика CS / Source (Bunnyhop & Strafe)")]
public float groundFriction = 5f;
public float groundAcceleration = 10f;
public float airAcceleration = 80f;
public float airCap = 2.0f;
public bool showSpeedometer = true;
[Header("Гравитация и Прыжок")]
public float jumpHeight = 1.35f;
public float gravity = -25f;
public float fallMultiplier = 1.8f;
public LayerMask groundLayer;
public float groundCheckDistance = 0.12f;
public float jumpBufferTime = 0.12f;
[Header("Параметры приседания")]
public float standingHeight = 2f;
public float crouchingHeight = 1.05f;
public float standingCameraY = 1.6f;
public float crouchingCameraY = 0.8f;
public float crouchTransitionSpeed = 15f;
[Header("Тряска Камеры (Headbob)")]
public bool enableHeadBob = true;
public float walkBobSpeed = 12f;
public float walkBobAmount = 0.04f;
public float sprintBobSpeed = 15f;
public float sprintBobAmount = 0.07f;
public float impactRecoverySpeed = 6f;
private void Awake()
{
// Загружаем чувствительность мыши при старте
mouseSensitivity = PlayerPrefs.GetFloat("MouseSensitivity", mouseSensitivity);
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 288fef68efe942f1bae865374c8fed93
timeCreated: 1789994991

View File

@ -3,7 +3,7 @@ using UnityEngine.UI;
using TMPro;
using System.Globalization;
public class SensitivitySettings : MonoBehaviour
public class SensitivitySettingsk : MonoBehaviour
{
[Header("UI элементы")]
[SerializeField] private Slider sensSlider;

View File

@ -1,5 +1,6 @@
using UnityEngine;
using UnityEngine.InputSystem;
using _Project.Scripts.PlayerUtils; // Подключаем пространство имен с нашими модулями игрока
namespace _Project.Scripts
{
@ -8,42 +9,26 @@ namespace _Project.Scripts
[Header("UI элементы")]
[SerializeField] private GameObject panel;
[Header("Игрок (чтобы отключить вращение камеры в паузе)")]
[SerializeField] private PlayerController playerController;
private PlayerControls controls;
private bool isInMenu = false;
private void Awake()
private void Start()
{
controls = new PlayerControls();
// Подписываемся на кнопку меню через главный класс Игрока.
// Теперь нам не нужно создавать свои controls, мы используем общие.
Player.Instance.Controls.Player.EnterMenu.performed += ctx => ToggleMenu();
// Подписываемся ОДИН раз при создании, а не в Update
controls.Player.EnterMenu.performed += ctx => ToggleMenu();
}
private void OnEnable()
{
// Обязательно включаем карту действий
controls.Player.Enable();
}
private void OnDisable()
{
// Отключаем ввод при деактивации объекта
controls.Player.Disable();
// Гарантируем, что на старте игры меню закрыто
CloseMenu();
}
private void OnDestroy()
{
// Отписываемся во избежание утечек памяти
controls.Player.EnterMenu.performed -= ctx => ToggleMenu();
}
private void Start()
{
// Гарантируем, что на старте игры меню закрыто
CloseMenu();
// Проверка на null нужна на случай закрытия игры, когда Player уже уничтожен
if (Player.Instance != null && Player.Instance.Controls != null)
{
Player.Instance.Controls.Player.EnterMenu.performed -= ctx => ToggleMenu();
}
}
/// <summary>
@ -71,16 +56,21 @@ namespace _Project.Scripts
if (panel != null)
panel.SetActive(true);
// Останавливаем игровое время (физика, таймеры)
// Останавливаем игровое время (физика и FixedUpdate останавливаются автоматически)
Time.timeScale = 0f;
// Освобождаем курсор для кликов по кнопкам и слайдерам
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
// Отключаем скрипт игрока, чтобы мышь не вертела камеру во время настройки
if (playerController != null)
playerController.enabled = false;
// ОТКЛЮЧАЕМ ТОЛЬКО НУЖНЫЕ МОДУЛИ
// Input System продолжает работать при Time.timeScale = 0,
// поэтому нам нужно отключить камеру (чтобы не вращалась) и стрельбу (чтобы не стрелял).
if (Player.Instance != null)
{
Player.Instance.CameraController.enabled = false;
Player.Instance.Combat.enabled = false;
}
}
/// <summary>
@ -100,9 +90,12 @@ namespace _Project.Scripts
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
// Возвращаем управление игроку
if (playerController != null)
playerController.enabled = true;
// Включаем модули обратно
if (Player.Instance != null)
{
Player.Instance.CameraController.enabled = true;
Player.Instance.Combat.enabled = true;
}
}
}
}