Merge remote-tracking branch 'origin/movement-dev' into Levels2
This commit is contained in:
commit
a5ce6e3165
147 files changed
+436331
-19506
No files matched your search
@@ -1,6 +1,9 @@
|
||||
using Code.App.StateMachine;
|
||||
using Code.App.StateMachine;
|
||||
using Code.Audio;
|
||||
using Code.Gameplay.Player;
|
||||
using Code.Input;
|
||||
using Code.Scenes;
|
||||
using Code.Scenes.SceneEnvironments;
|
||||
using Code.StateMachine;
|
||||
using Code.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
@@ -30,7 +33,11 @@ namespace Code.App.AppStates
|
||||
Context.InputService.EnableMap(ActionMappings.UI);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
|
||||
|
||||
GameOver();
|
||||
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Death);
|
||||
|
||||
Context.AudioService.ApplyStun(5000,0.5f);
|
||||
|
||||
GameOver().Forget();
|
||||
|
||||
base.EnterState();
|
||||
}
|
||||
@@ -45,7 +52,7 @@ namespace Code.App.AppStates
|
||||
await Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver);
|
||||
|
||||
_gameOverPanel = (GameOverPanel)Context.UIService.CurrentPanel;
|
||||
|
||||
_gameOverPanel.Show();
|
||||
}
|
||||
|
||||
private void ToMainMenu()
|
||||
@@ -71,6 +78,8 @@ namespace Code.App.AppStates
|
||||
Context.InputService.DisableMap(ActionMappings.UI);
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
|
||||
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Death, callback: Context.AudioFactory.ReleaseDeathMusic);
|
||||
Context.AudioService.TransitToSnapshot(AudioSnapshotState.None);
|
||||
base.ExitState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,12 @@ using Code.StateMachine;
|
||||
using Code.UI;
|
||||
using Code.UI.Panels;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Reflex.Core;
|
||||
using Reflex.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.App.AppStates
|
||||
@@ -42,27 +44,18 @@ namespace Code.App.AppStates
|
||||
.RegisterLoading(LoadingWork.LoadUI)
|
||||
.RegisterLoading(LoadingWork.LoadModelResource)
|
||||
.RegisterLoading(LoadingWork.LoadAudio);
|
||||
|
||||
//_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
|
||||
|
||||
//_playerHealth.OnDamage += PlayerDamageTaken;
|
||||
//_playerHealth.OnDeath += EndGame;
|
||||
|
||||
Context.AudioService.TransitToSnapshot(AudioSnapshotState.None);
|
||||
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, TakeGamageDEBUG);
|
||||
|
||||
// Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.DevGen);
|
||||
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.DevGen);
|
||||
Context.LoadingManager.OnLoadingEnded += AfterSceneLoaded;
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
WaitForLoad();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
|
||||
WaitForLoad().Forget();
|
||||
}
|
||||
private async UniTask WaitForPlayerCharacterLoad() => _playerCharacter = await Context.PlayerFactory.CreatePlayer();
|
||||
|
||||
@@ -71,6 +64,7 @@ namespace Code.App.AppStates
|
||||
await UniTask.WhenAll(
|
||||
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
|
||||
Context.AudioFactory.WarmGameplayMusic(),
|
||||
Context.AudioFactory.WarmDeathMusic(),
|
||||
Context.AudioFactory.WarmSFX(),
|
||||
Context.AudioFactory.WarmDispatcher(),
|
||||
Context.AudioFactory.WarmEnemies(),
|
||||
@@ -118,6 +112,8 @@ namespace Code.App.AppStates
|
||||
|
||||
GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer);
|
||||
|
||||
_volume = sceneEnvironment.volume;
|
||||
|
||||
PlayerInitialize(sceneEnvironment);
|
||||
|
||||
CameraInitialize();
|
||||
@@ -160,22 +156,30 @@ namespace Code.App.AppStates
|
||||
{
|
||||
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.TakeDamage1,(int)DispatcherSounds.TakeDamage4));
|
||||
Context.AudioService.PlayCourier((CourierSounds)Random.Range((int)CourierSounds.Damage1,(int)CourierSounds.Damage2));
|
||||
DamageEffectProcess().Forget();
|
||||
}
|
||||
|
||||
// TODO В конфиг
|
||||
private async UniTaskVoid DamageEffectProcess()
|
||||
{
|
||||
_damagePanel.Show();
|
||||
Context.AudioService.ApplyStun(200, 0.5f);
|
||||
|
||||
DOTween.To(() => _volume.weight, x => _volume.weight = x, 1f, 0.5f);
|
||||
await UniTask.WaitForSeconds(3f);
|
||||
DOTween.To(() => _volume.weight, x => _volume.weight = x, 0f, 1f);
|
||||
Context.AudioService.ApplyStun(5000, 1f);
|
||||
_damagePanel.Hide();
|
||||
}
|
||||
// DEBUG
|
||||
private void InstaKillDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_playerHealth.InstaKill();
|
||||
}
|
||||
private void RoomPassedDEBUG(InputAction.CallbackContext context)
|
||||
private void TakeGamageDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_orderService.RoomPassed();
|
||||
}
|
||||
private OrderDispenser _debugTube;
|
||||
|
||||
private void Tube(InputAction.CallbackContext context)
|
||||
{
|
||||
_debugTube.ThrowOrder();
|
||||
}
|
||||
_playerHealth.GetDamage(1);
|
||||
}
|
||||
// DEBUG
|
||||
private bool _tickEnabled;
|
||||
public override void Tick()
|
||||
@@ -208,8 +212,8 @@ namespace Code.App.AppStates
|
||||
Context.AudioService.OnDispatcherEnded -= _gameplayPanel.CloseDispatcher;
|
||||
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Action, callback: Context.AudioFactory.ReleaseActionMusic);
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, callback: Context.AudioFactory.ReleasePeacefulMusic);
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Action, time: 0f, callback: Context.AudioFactory.ReleaseActionMusic);
|
||||
Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, time: 0f, callback: Context.AudioFactory.ReleasePeacefulMusic);
|
||||
Context.AudioFactory.ReleaseCourier();
|
||||
Context.AudioFactory.ReleaseDispatcher();
|
||||
Context.AudioFactory.ReleaseEnemies();
|
||||
@@ -217,8 +221,7 @@ namespace Code.App.AppStates
|
||||
|
||||
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG);
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, TakeGamageDEBUG);
|
||||
|
||||
base.ExitState();
|
||||
}
|
||||
@@ -235,13 +238,15 @@ namespace Code.App.AppStates
|
||||
|
||||
private GameplayPanel _gameplayPanel;
|
||||
private ArmsMeshProvider _armsMesh;
|
||||
|
||||
private DamagePanel _damagePanel;
|
||||
private void UIInitialize()
|
||||
{
|
||||
_gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel;
|
||||
_gameplayPanel.Initialize(_playerScore, _playerHealth, _orderService);
|
||||
Context.AudioService.OnDispatcherStarted += _gameplayPanel.SummonDispatcher;
|
||||
Context.AudioService.OnDispatcherEnded += _gameplayPanel.CloseDispatcher;
|
||||
|
||||
_damagePanel = _gameplayPanel.DamagePanel;
|
||||
}
|
||||
private void MusicInitialize()
|
||||
{
|
||||
@@ -263,10 +268,11 @@ namespace Code.App.AppStates
|
||||
_orderService.OnOrderDelivered += OrderDelivered;
|
||||
_orderService.OnOrderFailure += OrderFailure;
|
||||
}
|
||||
|
||||
private Volume _volume;
|
||||
private GameplaySceneEnvironment SceneEnvironmentVariables(Container sceneContainer)
|
||||
{
|
||||
var sceneEnvironment = (GameplaySceneEnvironment)sceneContainer.Resolve<CurrentSceneEnvironment>();
|
||||
|
||||
|
||||
return sceneEnvironment;
|
||||
}
|
||||
|
||||
@@ -119,9 +119,7 @@ namespace Code.App
|
||||
AttributeInjector.Inject(cameraStateMachine.StateMachineContext, container);
|
||||
cameraStateMachine.Initialize();
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
BootstrapFinish(container);
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
BootstrapFinish(container).Forget();
|
||||
}
|
||||
private async UniTaskVoid BootstrapFinish(Container container)
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Code.Audio
|
||||
}
|
||||
public enum EnemiesSounds
|
||||
{
|
||||
Bastard,
|
||||
Bravo,
|
||||
GrandpaAttack,
|
||||
RoachAttack,
|
||||
RoachStep,
|
||||
GrandpaStep
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Code.Audio
|
||||
private AssetReference[] _audioTestClipsReferences;
|
||||
private AssetReference[] _peacefulSoundtrack;
|
||||
private AssetReference[] _actionSoundtrack;
|
||||
private AssetReference[] _deathSoundtrack;
|
||||
private AssetReference[] _menuSoundtrack;
|
||||
private AssetReference[] _SFX;
|
||||
private AssetReference[] _enemies;
|
||||
@@ -27,6 +28,7 @@ namespace Code.Audio
|
||||
|
||||
private AsyncOperationHandle<IList<AudioClip>> _audioTestClipsHandle;
|
||||
private AsyncOperationHandle<IList<AudioClip>> _menuMusicHandle;
|
||||
private AsyncOperationHandle<IList<AudioClip>> _deathMusicHandle;
|
||||
private AsyncOperationHandle<IList<AudioClip>> _actionMusicHandle;
|
||||
private AsyncOperationHandle<IList<AudioClip>> _peacefulMusicHandle;
|
||||
private AsyncOperationHandle<IList<AudioClip>> _SFXHandle;
|
||||
@@ -55,6 +57,7 @@ namespace Code.Audio
|
||||
|
||||
_peacefulSoundtrack = soundtrackListConfig.peacefulSoundtrack;
|
||||
_actionSoundtrack = soundtrackListConfig.actionSoundtrack;
|
||||
_deathSoundtrack = soundtrackListConfig.deathSoundtrack;
|
||||
_menuSoundtrack = soundtrackListConfig.menuSoundtrack;
|
||||
_SFX = sfxListConfig.SFX;
|
||||
_enemies = enemiesSoundListConfig.enemies;
|
||||
@@ -63,8 +66,9 @@ namespace Code.Audio
|
||||
_audioTestClipsReferences = audioTestClipsConfig.audioTestClips;
|
||||
|
||||
MusicDictionary.Add(MusicType.Menu, new ());
|
||||
MusicDictionary.Add(MusicType.Peaceful, new ());
|
||||
MusicDictionary.Add(MusicType.Death, new ());
|
||||
MusicDictionary.Add(MusicType.Action, new ());
|
||||
MusicDictionary.Add(MusicType.Peaceful, new ());
|
||||
}
|
||||
|
||||
public async UniTask LoadAudioSourcePrefab(Action<GameObject> callback) =>
|
||||
@@ -116,6 +120,16 @@ namespace Code.Audio
|
||||
// foreach (var assetReference in _menuSoundtrack) assetReference.ReleaseAsset();
|
||||
_menuMusicHandle.Release();
|
||||
}
|
||||
public async UniTask WarmDeathMusic()
|
||||
{
|
||||
_deathMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_deathSoundtrack, OnDeathTrackLoaded, Addressables.MergeMode.Union);
|
||||
await _deathMusicHandle.ToUniTask();
|
||||
}
|
||||
public void ReleaseDeathMusic()
|
||||
{
|
||||
MusicDictionary[MusicType.Death].Clear();
|
||||
_deathMusicHandle.Release();
|
||||
}
|
||||
public async UniTask WarmSFX( )
|
||||
{
|
||||
_SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.Union);
|
||||
@@ -172,6 +186,10 @@ namespace Code.Audio
|
||||
{
|
||||
MusicDictionary[MusicType.Menu].Add(audioClip);
|
||||
}
|
||||
private void OnDeathTrackLoaded(AudioClip audioClip)
|
||||
{
|
||||
MusicDictionary[MusicType.Death].Add(audioClip);
|
||||
}
|
||||
|
||||
// private int _audioTestClipCounter;
|
||||
private void OnAudioTestClipLoaded(AudioClip audioClip)
|
||||
|
||||
@@ -24,8 +24,7 @@ namespace Code.Audio
|
||||
|
||||
private Dictionary<AudioType, AudioMixerGroup> _audioMixerGroups = new();
|
||||
private readonly AudioSourcePool _audioSourcePool;
|
||||
|
||||
// private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new();
|
||||
|
||||
// Юнити не может - говнокод поможет.
|
||||
private Dictionary<AudioSnapshotState, Dictionary<AudioType, float>> _snapshotsVolumes = new();
|
||||
private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings;
|
||||
@@ -58,6 +57,7 @@ namespace Code.Audio
|
||||
float volume = Mathf.Log10(value) * 20;
|
||||
switch (type)
|
||||
{
|
||||
case AudioType.DeathMusic:
|
||||
case AudioType.Master:
|
||||
_snapshotsVolumes[AudioSnapshotState.Menu][type] = value;
|
||||
_snapshotsVolumes[AudioSnapshotState.Action][type] = value;
|
||||
@@ -92,14 +92,17 @@ namespace Code.Audio
|
||||
_mixer = _audioFactory.AudioMixer;
|
||||
|
||||
_musicAudioGroups.Add(MusicType.Menu, _mixer.FindMatchingGroups(AudioGroups.MenuMusicGroup)[0]);
|
||||
_musicAudioGroups.Add(MusicType.Death, _mixer.FindMatchingGroups(AudioGroups.DeathMusicGroup)[0]);
|
||||
_musicAudioGroups.Add(MusicType.Action, _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0]);
|
||||
_musicAudioGroups.Add(MusicType.Peaceful, _mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0]);
|
||||
|
||||
_cancellationTokenSources.Add(MusicType.Menu, new());
|
||||
_cancellationTokenSources.Add(MusicType.Death, new());
|
||||
_cancellationTokenSources.Add(MusicType.Action, new());
|
||||
_cancellationTokenSources.Add(MusicType.Peaceful, new());
|
||||
|
||||
_musicAudioSources.Add(MusicType.Menu, null);
|
||||
_musicAudioSources.Add(MusicType.Death, null);
|
||||
_musicAudioSources.Add(MusicType.Action, null);
|
||||
_musicAudioSources.Add(MusicType.Peaceful, null);
|
||||
|
||||
@@ -109,6 +112,7 @@ namespace Code.Audio
|
||||
_audioMixerGroups.Add(AudioType.Courier, _mixer.FindMatchingGroups(AudioGroups.CourierGroup)[0]);
|
||||
_audioMixerGroups.Add(AudioType.Enemies, _mixer.FindMatchingGroups(AudioGroups.EnemiesGroup)[0]);
|
||||
_audioMixerGroups.Add(AudioType.MenuMusic, _musicAudioGroups[MusicType.Menu]);
|
||||
_audioMixerGroups.Add(AudioType.DeathMusic, _musicAudioGroups[MusicType.Death]);
|
||||
_audioMixerGroups.Add(AudioType.ActionMusic, _musicAudioGroups[MusicType.Action]);
|
||||
_audioMixerGroups.Add(AudioType.PeacefulMusic, _musicAudioGroups[MusicType.Peaceful]);
|
||||
|
||||
@@ -157,7 +161,7 @@ namespace Code.Audio
|
||||
public async UniTaskVoid GladlyAskToStopMusic(MusicType musicType,
|
||||
AudioSnapshotState audioSnapshotState = AudioSnapshotState.None, float time = 1f, Action callback = null)
|
||||
{
|
||||
// TransitToSnapshot(audioSnapshotState, time);
|
||||
//TransitToSnapshot(audioSnapshotState, time);
|
||||
|
||||
await UniTask.WaitForSeconds(time);
|
||||
|
||||
@@ -170,6 +174,8 @@ namespace Code.Audio
|
||||
{
|
||||
_peacefulMusicSource.Stop();
|
||||
_actionMusicSource.Stop();
|
||||
_cancellationTokenSources[MusicType.Peaceful].Cancel();
|
||||
_cancellationTokenSources[MusicType.Action].Cancel();
|
||||
}
|
||||
|
||||
public void GladlyAskToStopMusic(Action callback = null)
|
||||
@@ -193,6 +199,10 @@ namespace Code.Audio
|
||||
_audioSourcePool
|
||||
.PlayOneShot(_audioFactory.SFXAudios[(int)sfxId], position, _audioMixerGroups[AudioType.SFX]).Forget();
|
||||
}
|
||||
public void ApplyStun(float value, float time)
|
||||
{
|
||||
_mixer.DOSetFloat("Stun", value, time);
|
||||
}
|
||||
|
||||
public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position)
|
||||
{
|
||||
|
||||
@@ -31,5 +31,7 @@ namespace Code.Audio
|
||||
void ReleaseDispatcher();
|
||||
UniTask WarmCourier();
|
||||
void ReleaseCourier();
|
||||
UniTask WarmDeathMusic( );
|
||||
void ReleaseDeathMusic();
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,6 @@ namespace Code.Audio
|
||||
AudioSource GetSourceOfGroup(AudioType group);
|
||||
void ReleaseSourceOfGroup(AudioSource source);
|
||||
void PlayCourier(CourierSounds range);
|
||||
void ApplyStun(float value, float time);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,8 @@ namespace Code.Audio
|
||||
{
|
||||
Menu,
|
||||
Peaceful,
|
||||
Action
|
||||
Action,
|
||||
Death
|
||||
}
|
||||
public enum AudioType
|
||||
{
|
||||
@@ -15,6 +16,7 @@ namespace Code.Audio
|
||||
Courier,
|
||||
Enemies,
|
||||
ActionMusic,
|
||||
PeacefulMusic
|
||||
PeacefulMusic,
|
||||
DeathMusic
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,42 @@ namespace Code.Configs
|
||||
[CreateAssetMenu(fileName = "CharacterConfig", menuName = "Config/CharacterConfig")]
|
||||
public class CharacterConfig : ScriptableObject
|
||||
{
|
||||
// Основное движение по земле
|
||||
public float
|
||||
maxStableMoveSpeed = 8f, // Максимальная скорость движения по устойчивой поверхности
|
||||
stableMovementSharpness = 15f, // Резкость изменения скорости движения (чем выше - тем резче)
|
||||
orientationSharpness = 10f, // Резкость изменения вращения персонажа (чем выше - тем резче)
|
||||
jumpSpeed = 10f; // Скорость прыжка
|
||||
maxStableMoveSpeed = 12f,
|
||||
stableMovementSharpness = 15f,
|
||||
orientationSharpness = 10f,
|
||||
jumpSpeed = 10f;
|
||||
|
||||
// Спринт
|
||||
public float
|
||||
sprintMoveSpeed = 12f, // Максимальная скорость спринта
|
||||
sprintAngleThreshold = 90f; // Максимальный угол (в градусах) от направления вперёд, при котором разрешён спринт
|
||||
public float
|
||||
dashSpeed = 20f,
|
||||
dashDuration = 0.35f,
|
||||
dashCooldown = 1.2f;
|
||||
|
||||
public AnimationCurve slideVelocityCurve = new(
|
||||
new Keyframe(0.0f, 1.0f),
|
||||
new Keyframe(0.3f, 1.4f),
|
||||
new Keyframe(1.0f, 0.2f)
|
||||
);
|
||||
public float
|
||||
slideMinVelocityThreshold = 3f,
|
||||
slideCooldown = 1.5f;
|
||||
|
||||
// Слайд
|
||||
public float
|
||||
slideSpeed = 20f, // Скорость слайда
|
||||
slideDuration = 0.8f, // Длительность слайда в секундах
|
||||
slideCooldown = 1.5f; // Время перезарядки слайда в секундах
|
||||
|
||||
// Наклон при залазании на стены
|
||||
public float
|
||||
leanAngle = 25f,
|
||||
leanThreshold = 0.3f,
|
||||
leanSmoothSpeed = 10f;
|
||||
|
||||
// Гравитация
|
||||
public Vector3 gravity = new(0f, -30f, 0f); // Вектор, отвечающий за применение гравитации
|
||||
public Vector3 gravity = new(0f, -30f, 0f);
|
||||
public float
|
||||
maxAirSpeed = 10f,
|
||||
airControlSharpness = 8f;
|
||||
|
||||
public float
|
||||
wallRunMaxTime = 1.75f,
|
||||
wallRunSpeed = 15f,
|
||||
wallRunAcceleration = 25f,
|
||||
wallRunGravityScale = 0.25f,
|
||||
wallDetachImpulse = 7f,
|
||||
wallContactAngleThreshold = 45f;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace Code.Configs
|
||||
{
|
||||
public AssetReference[] peacefulSoundtrack;
|
||||
public AssetReference[] actionSoundtrack;
|
||||
public AssetReference[] deathSoundtrack;
|
||||
public AssetReference[] menuSoundtrack;
|
||||
}
|
||||
}
|
||||
@@ -27,5 +27,6 @@ namespace Code.Constants
|
||||
public const string NoneSnapshot = "None";
|
||||
public const string MenuSnapshot = "Menu";
|
||||
public const string MenuMusicGroup = "Menu";
|
||||
public const string DeathMusicGroup = "Death";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
using Code.Gameplay.Camera;
|
||||
using KinematicCharacterController;
|
||||
|
||||
namespace Code.Gameplay.Character.Controller.Abilities
|
||||
{
|
||||
public class DashMechanic
|
||||
{
|
||||
private readonly float _dashSpeed;
|
||||
private readonly float _dashDuration;
|
||||
private readonly float _dashCooldown;
|
||||
|
||||
private float _dashTimer;
|
||||
private float _dashCooldownTimer;
|
||||
private Vector3 _dashDirection;
|
||||
private bool _dashRequested;
|
||||
|
||||
public bool IsDashing { get; private set; }
|
||||
|
||||
public DashMechanic(float dashSpeed, float dashDuration, float dashCooldown)
|
||||
{
|
||||
_dashSpeed = dashSpeed;
|
||||
_dashDuration = dashDuration;
|
||||
_dashCooldown = dashCooldown;
|
||||
}
|
||||
|
||||
public void TickCooldown(float deltaTime)
|
||||
{
|
||||
if (_dashCooldownTimer > 0f) _dashCooldownTimer -= deltaTime;
|
||||
}
|
||||
|
||||
public void RequestDash(bool dashPressed)
|
||||
{
|
||||
if (dashPressed && !_dashRequested && _dashCooldownTimer <= 0f)
|
||||
_dashRequested = true;
|
||||
}
|
||||
|
||||
public void TryStartDash(KinematicCharacterMotor motor,
|
||||
CameraMode currentCameraMode,
|
||||
Quaternion firstPersonCameraRotation,
|
||||
Vector3 lookInputVector)
|
||||
{
|
||||
if (!_dashRequested || !motor.GroundingStatus.IsStableOnGround || _dashCooldownTimer > 0f)
|
||||
{
|
||||
_dashRequested = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IsDashing = true;
|
||||
_dashTimer = _dashDuration;
|
||||
|
||||
var dir = currentCameraMode == CameraMode.FirstPerson
|
||||
? firstPersonCameraRotation * Vector3.forward
|
||||
: lookInputVector;
|
||||
|
||||
_dashDirection = Vector3.ProjectOnPlane(dir, motor.CharacterUp).normalized;
|
||||
if (_dashDirection.sqrMagnitude < 0.01f) _dashDirection = motor.CharacterForward;
|
||||
|
||||
_dashCooldownTimer = _dashCooldown;
|
||||
_dashRequested = false;
|
||||
}
|
||||
|
||||
public void HandleDash(ref Vector3 currentVelocity, float deltaTime, KinematicCharacterMotor motor)
|
||||
{
|
||||
_dashTimer -= deltaTime;
|
||||
if (_dashTimer <= 0f || !motor.GroundingStatus.IsStableOnGround)
|
||||
{
|
||||
EndDash();
|
||||
return;
|
||||
}
|
||||
|
||||
currentVelocity = _dashDirection * _dashSpeed;
|
||||
currentVelocity += motor.CharacterUp * 1.5f;
|
||||
}
|
||||
|
||||
public void EndDash()
|
||||
{
|
||||
IsDashing = false;
|
||||
_dashTimer = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d62efb53e0c4d49be9fc658484e2575
|
||||
timeCreated: 1764856437
|
||||
+41
-72
@@ -1,122 +1,91 @@
|
||||
using UnityEngine;
|
||||
using Code.Gameplay.Camera;
|
||||
using KinematicCharacterController;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Gameplay.Character.Controller.Abilities
|
||||
{
|
||||
/*
|
||||
* Механика слайда для персонажа
|
||||
* Отвечает за управление состоянием, таймерами и скоростью слайда
|
||||
*/
|
||||
public class SlideMechanic
|
||||
{
|
||||
// Скорость слайда
|
||||
private readonly float _slideSpeed;
|
||||
// Длительность слайда в секундах
|
||||
private readonly float _slideDuration;
|
||||
// Время перезарядки слайда
|
||||
private readonly float _slideCooldown;
|
||||
private readonly AnimationCurve _velocityCurve;
|
||||
private readonly float _minVelocityThreshold;
|
||||
private readonly float _cooldown;
|
||||
|
||||
// Таймер слайда
|
||||
private float _slideTimer;
|
||||
// Таймер перезарядки слайда
|
||||
private float _slideCooldownTimer;
|
||||
// Направление слайда
|
||||
private float _slideTime;
|
||||
private float _cooldownTimer;
|
||||
private Vector3 _slideDirection;
|
||||
// Флаг запроса слайда
|
||||
private bool _slideRequested;
|
||||
|
||||
// Свойство-флаг, активен ли слайд
|
||||
private float _initialSpeed;
|
||||
|
||||
public bool IsSliding { get; private set; }
|
||||
|
||||
// Конструктор механики слайда
|
||||
public SlideMechanic(float slideSpeed, float slideDuration, float slideCooldown)
|
||||
|
||||
public SlideMechanic(AnimationCurve velocityCurve, float minVelocityThreshold, float cooldown)
|
||||
{
|
||||
_slideSpeed = slideSpeed;
|
||||
_slideDuration = slideDuration;
|
||||
_slideCooldown = slideCooldown;
|
||||
_velocityCurve = velocityCurve;
|
||||
_minVelocityThreshold = minVelocityThreshold;
|
||||
_cooldown = cooldown;
|
||||
}
|
||||
|
||||
// Обновляем таймер перезарядки слайда
|
||||
public void TickCooldown(float deltaTime)
|
||||
{
|
||||
if (_slideCooldownTimer > 0f)
|
||||
{
|
||||
_slideCooldownTimer -= deltaTime;
|
||||
}
|
||||
if (_cooldownTimer > 0f) _cooldownTimer -= deltaTime;
|
||||
}
|
||||
|
||||
// Обработка слайда
|
||||
public void RequestSlide(bool slidePressed)
|
||||
{
|
||||
if (slidePressed && !_slideRequested && _slideCooldownTimer <= 0f)
|
||||
{
|
||||
if (slidePressed && !_slideRequested && _cooldownTimer <= 0f)
|
||||
_slideRequested = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Начало слайда
|
||||
public void TryStartSlide(KinematicCharacterMotor motor,
|
||||
CameraMode currentCameraMode,
|
||||
Quaternion firstPersonCameraRotation,
|
||||
Vector3 lookInputVector)
|
||||
{
|
||||
// Проверяем условия для старта слайда
|
||||
if (!_slideRequested || !motor.GroundingStatus.IsStableOnGround || _slideCooldownTimer > 0f)
|
||||
if (!_slideRequested || !motor.GroundingStatus.IsStableOnGround || _cooldownTimer > 0f)
|
||||
{
|
||||
_slideRequested = false;
|
||||
return;
|
||||
}
|
||||
|
||||
IsSliding = true;
|
||||
_slideTimer = _slideDuration;
|
||||
|
||||
// НАПРАВЛЕНИЕ СЛАЙДА - ВСЕГДА ВПЕРЕД ПО КАМЕРЕ
|
||||
// Используем направление камеры, но проецируем на горизонтальную плоскость
|
||||
var slideDir = currentCameraMode == CameraMode.FirstPerson ?
|
||||
firstPersonCameraRotation * Vector3.forward :
|
||||
lookInputVector;
|
||||
|
||||
// Проецируем на горизонтальную плоскость и нормализуем
|
||||
_slideDirection = Vector3.ProjectOnPlane(slideDir, motor.CharacterUp).normalized;
|
||||
|
||||
// Если направление нулевое (персонаж стоит на месте), используем направление вперед
|
||||
if (_slideDirection.sqrMagnitude < 0.01f)
|
||||
{
|
||||
_slideDirection = motor.CharacterForward;
|
||||
}
|
||||
_slideTime = 0f;
|
||||
|
||||
// Устанавливаем перезарядку
|
||||
_slideCooldownTimer = _slideCooldown;
|
||||
var dir = currentCameraMode == CameraMode.FirstPerson
|
||||
? firstPersonCameraRotation * Vector3.forward
|
||||
: lookInputVector;
|
||||
|
||||
_slideDirection = Vector3.ProjectOnPlane(dir, motor.CharacterUp).normalized;
|
||||
if (_slideDirection.sqrMagnitude < 0.01f) _slideDirection = motor.CharacterForward;
|
||||
|
||||
_initialSpeed = motor.Velocity.magnitude;
|
||||
if (_initialSpeed < 12f) _initialSpeed = 12f; // fallback
|
||||
|
||||
_cooldownTimer = _cooldown;
|
||||
_slideRequested = false;
|
||||
}
|
||||
|
||||
// Обработка слайда
|
||||
public void HandleSlide(ref Vector3 currentVelocity, float deltaTime, KinematicCharacterMotor motor)
|
||||
{
|
||||
// Уменьшаем таймер слайда
|
||||
_slideTimer -= deltaTime;
|
||||
if (!IsSliding) return;
|
||||
|
||||
_slideTime += deltaTime;
|
||||
|
||||
// Если время слайда вышло, персонаж в воздухе - заканчиваем слайд
|
||||
if (_slideTimer <= 0f || !motor.GroundingStatus.IsStableOnGround)
|
||||
{
|
||||
var t = Mathf.Clamp01(_slideTime / 2.5f);
|
||||
var speedMult = _velocityCurve.Evaluate(t);
|
||||
|
||||
var targetSpeed = _initialSpeed * speedMult;
|
||||
currentVelocity = _slideDirection * targetSpeed;
|
||||
|
||||
currentVelocity += motor.CharacterUp * 1f;
|
||||
|
||||
if (targetSpeed < _minVelocityThreshold || !motor.GroundingStatus.IsStableOnGround)
|
||||
EndSlide();
|
||||
return;
|
||||
}
|
||||
|
||||
// Устанавливаем скорость слайда вперед
|
||||
// Используем прямую установку скорости вместо сложных вычислений
|
||||
currentVelocity = _slideDirection * _slideSpeed;
|
||||
|
||||
// Добавляем небольшую вертикальную компоненту для лучшего скольжения по неровностям
|
||||
currentVelocity += motor.CharacterUp * 2f;
|
||||
}
|
||||
|
||||
// Завершение слайда
|
||||
public void EndSlide()
|
||||
{
|
||||
IsSliding = false;
|
||||
_slideTimer = 0f;
|
||||
_slideTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
-103
@@ -7,14 +7,13 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
{
|
||||
public class WallRunningMechanic
|
||||
{
|
||||
public float MaxWallRunTime = 1.75f;
|
||||
public float WallRunSpeed = 8.0f;
|
||||
public float WallRunAcceleration = 25.0f;
|
||||
public float WallRunGravityScale = 0.25f;
|
||||
public float WallDetachImpulse = 7.0f;
|
||||
public float WallContactAngleThreshold = 45.0f;
|
||||
private readonly float _maxWallRunTime;
|
||||
private readonly float _wallRunSpeed;
|
||||
private readonly float _wallRunAcceleration;
|
||||
private readonly float _wallRunGravityScale;
|
||||
private readonly float _wallDetachImpulse;
|
||||
private readonly float _wallContactAngleThreshold;
|
||||
|
||||
private bool _isWallRunning;
|
||||
private float _wallRunTimer;
|
||||
private Vector3 _wallNormal;
|
||||
private Vector3 _wallTangentRight;
|
||||
@@ -24,53 +23,58 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
|
||||
private float _surfaceAngleCos;
|
||||
private bool _canWallRun;
|
||||
public float WallContactHeight { get; private set; }
|
||||
|
||||
public Vector3 WallRunStartForward { get; private set; }
|
||||
|
||||
private KinematicCharacterMotor _motor;
|
||||
private CharacterInputHandler _inputHandler;
|
||||
|
||||
public bool IsWallRunning => _isWallRunning;
|
||||
public bool IsWallRunning { get; private set; }
|
||||
|
||||
public WallRunningMechanic(
|
||||
float maxWallRunTime,
|
||||
float wallRunSpeed,
|
||||
float wallRunAcceleration,
|
||||
float wallRunGravityScale,
|
||||
float wallDetachImpulse,
|
||||
float wallContactAngleThreshold)
|
||||
{
|
||||
_maxWallRunTime = maxWallRunTime;
|
||||
_wallRunSpeed = wallRunSpeed;
|
||||
_wallRunAcceleration = wallRunAcceleration;
|
||||
_wallRunGravityScale = wallRunGravityScale;
|
||||
_wallDetachImpulse = wallDetachImpulse;
|
||||
_wallContactAngleThreshold = wallContactAngleThreshold;
|
||||
}
|
||||
|
||||
public void Initialize(KinematicCharacterMotor motor, CharacterInputHandler inputHandler)
|
||||
{
|
||||
_motor = motor;
|
||||
_inputHandler = inputHandler;
|
||||
_surfaceAngleCos = Mathf.Cos(Mathf.Deg2Rad * WallContactAngleThreshold);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_isWallRunning = false;
|
||||
_wallRunTimer = 0f;
|
||||
_wallNormal = Vector3.zero;
|
||||
_surfaceAngleCos = Mathf.Cos(Mathf.Deg2Rad * _wallContactAngleThreshold);
|
||||
}
|
||||
|
||||
public void Tick(float deltaTime)
|
||||
{
|
||||
if (_isWallRunning)
|
||||
if (!IsWallRunning) return;
|
||||
|
||||
_wallRunTimer += deltaTime;
|
||||
if (_wallRunTimer > _maxWallRunTime)
|
||||
{
|
||||
_wallRunTimer += deltaTime;
|
||||
if (_wallRunTimer > MaxWallRunTime)
|
||||
{
|
||||
DetachFromWall(false);
|
||||
}
|
||||
DetachFromWall(false);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryStartWallRun(Vector3 hitNormal, Vector3 hitPoint)
|
||||
{
|
||||
if (_isWallRunning) return false;
|
||||
if (IsWallRunning) return false;
|
||||
|
||||
float dotWithUp = Vector3.Dot(hitNormal, _motor.CharacterUp);
|
||||
bool isWall = Mathf.Abs(dotWithUp) < _surfaceAngleCos;
|
||||
var dotWithUp = Vector3.Dot(hitNormal, _motor.CharacterUp);
|
||||
var isWall = Mathf.Abs(dotWithUp) < _surfaceAngleCos;
|
||||
|
||||
if (!isWall) return false;
|
||||
|
||||
if (_motor.GroundingStatus.IsStableOnGround) return false;
|
||||
|
||||
float velocityIntoWall = Vector3.Dot(_motor.Velocity, -hitNormal);
|
||||
var velocityIntoWall = Vector3.Dot(_motor.Velocity, -hitNormal);
|
||||
if (velocityIntoWall < 1f) return false;
|
||||
|
||||
StartWallRun(hitNormal, hitPoint);
|
||||
@@ -79,13 +83,11 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
|
||||
private void StartWallRun(Vector3 wallNormal, Vector3 contactPoint)
|
||||
{
|
||||
_isWallRunning = true;
|
||||
IsWallRunning = true;
|
||||
_wallRunTimer = 0f;
|
||||
_wallNormal = wallNormal.normalized;
|
||||
_wallContactPoint = contactPoint;
|
||||
WallContactHeight = contactPoint.y;
|
||||
|
||||
//_wallTangentUp = Vector3.ProjectOnPlane(_motor.CharacterUp, _wallNormal).normalized;
|
||||
if (_wallTangentUp.sqrMagnitude < 0.01f) _wallTangentUp = Vector3.up;
|
||||
|
||||
_wallTangentRight = Vector3.Cross(_wallNormal, _wallTangentUp).normalized;
|
||||
@@ -93,43 +95,42 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
_wallTangentUp = Vector3.Cross(_wallTangentRight, _wallNormal).normalized;
|
||||
if (Vector3.Dot(_wallTangentUp, Vector3.up) < 0)
|
||||
_wallTangentUp = -_wallTangentUp;
|
||||
|
||||
WallRunStartForward = _motor.CharacterForward;
|
||||
|
||||
_motor.ForceUnground();
|
||||
}
|
||||
|
||||
public void HandleWallRun(ref Vector3 currentVelocity, CharacterInputs inputs, float deltaTime)
|
||||
{
|
||||
if (!_isWallRunning) return;
|
||||
if (!IsWallRunning) return;
|
||||
if (!IsWallStillPresent()) { DetachFromWall(false); return; }
|
||||
|
||||
Vector3 moveInputWorld = _inputHandler.MoveInputVector;
|
||||
Vector3 moveInWallPlane = Vector3.ProjectOnPlane(moveInputWorld, _wallNormal);
|
||||
var moveInputWorld = _inputHandler.MoveInputVector;
|
||||
var moveInWallPlane = Vector3.ProjectOnPlane(moveInputWorld, _wallNormal);
|
||||
|
||||
Vector3 wsMove = Vector3.Project(moveInWallPlane, _wallTangentRight);
|
||||
var wsMove = Vector3.Project(moveInWallPlane, _wallTangentRight);
|
||||
|
||||
float ad = inputs.MoveAxisRight;
|
||||
var ad = inputs.MoveAxisRight;
|
||||
|
||||
float sideDot = Vector3.Dot(_wallNormal, _motor.CharacterRight);
|
||||
var sideDot = Vector3.Dot(_wallNormal, _motor.CharacterRight);
|
||||
if (sideDot < 0)
|
||||
ad = -ad;
|
||||
|
||||
Vector3 adMove = _wallTangentUp * (-ad);
|
||||
var adMove = _wallTangentUp * (-ad);
|
||||
|
||||
Vector3 finalMove = wsMove + adMove;
|
||||
var finalMove = wsMove + adMove;
|
||||
finalMove = finalMove.normalized * moveInputWorld.magnitude;
|
||||
|
||||
Vector3 targetVelocity = finalMove * WallRunSpeed;
|
||||
var targetVelocity = finalMove * _wallRunSpeed;
|
||||
|
||||
currentVelocity = Vector3.Lerp(
|
||||
currentVelocity,
|
||||
targetVelocity,
|
||||
1f - Mathf.Exp(-WallRunAcceleration * deltaTime)
|
||||
1f - Mathf.Exp(-_wallRunAcceleration * deltaTime)
|
||||
);
|
||||
|
||||
currentVelocity += Physics.gravity * (WallRunGravityScale * deltaTime);
|
||||
currentVelocity += Physics.gravity * (_wallRunGravityScale * deltaTime);
|
||||
|
||||
float distanceToWall = Vector3.Dot(_motor.TransientPosition - _wallContactPoint, _wallNormal);
|
||||
var distanceToWall = Vector3.Dot(_motor.TransientPosition - _wallContactPoint, _wallNormal);
|
||||
if (Mathf.Abs(distanceToWall) > 0.8f)
|
||||
{
|
||||
DetachFromWall(false);
|
||||
@@ -144,16 +145,15 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
|
||||
private bool IsWallStillPresent()
|
||||
{
|
||||
if (_motor == null) return false;
|
||||
if (!_motor) return false;
|
||||
|
||||
Vector3 characterCenter = _motor.TransientPosition;
|
||||
Vector3 characterForward = _motor.CharacterForward;
|
||||
Vector3 characterRight = _motor.CharacterRight;
|
||||
Vector3 characterUp = _motor.CharacterUp;
|
||||
var characterCenter = _motor.TransientPosition;
|
||||
var characterRight = _motor.CharacterRight;
|
||||
var characterUp = _motor.CharacterUp;
|
||||
|
||||
float checkDistance = 0.45f;
|
||||
Vector3 rayOrigin = characterCenter + characterUp * 0.2f;
|
||||
Vector3 rayDir = -_wallNormal;
|
||||
const float checkDistance = 0.45f;
|
||||
var rayOrigin = characterCenter + characterUp * 0.2f;
|
||||
var rayDir = -_wallNormal;
|
||||
|
||||
Vector3[] offsets = {
|
||||
Vector3.zero,
|
||||
@@ -165,83 +165,60 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
||||
|
||||
foreach (var offset in offsets)
|
||||
{
|
||||
if (Physics.Raycast(rayOrigin + offset, rayDir, out RaycastHit hit, checkDistance,
|
||||
_motor.CollidableLayers, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
float dotWithUp = Mathf.Abs(Vector3.Dot(hit.normal, characterUp));
|
||||
if (dotWithUp < _surfaceAngleCos)
|
||||
{
|
||||
_wallNormal = hit.normal.normalized;
|
||||
_wallContactPoint = hit.point;
|
||||
if (!Physics.Raycast(rayOrigin + offset, rayDir, out var hit, checkDistance,
|
||||
_motor.CollidableLayers, QueryTriggerInteraction.Ignore)) continue;
|
||||
|
||||
var dotWithUp = Mathf.Abs(Vector3.Dot(hit.normal, characterUp));
|
||||
|
||||
if (!(dotWithUp < _surfaceAngleCos)) continue;
|
||||
|
||||
_wallNormal = hit.normal.normalized;
|
||||
_wallContactPoint = hit.point;
|
||||
|
||||
/*_wallTangentUp = Vector3.ProjectOnPlane(_motor.CharacterUp, _wallNormal).normalized;
|
||||
if (_wallTangentUp.sqrMagnitude < 0.01f) _wallTangentUp = Vector3.up;
|
||||
_wallTangentRight = Vector3.Cross(_wallNormal, _wallTangentUp).normalized;
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DetachFromWall(bool withImpulse)
|
||||
private void DetachFromWall(bool withImpulse)
|
||||
{
|
||||
if (!_isWallRunning) return;
|
||||
if (!IsWallRunning) return;
|
||||
|
||||
_isWallRunning = false;
|
||||
IsWallRunning = false;
|
||||
|
||||
if (withImpulse && _motor != null)
|
||||
{
|
||||
Vector3 detachImpulse = -_wallNormal * WallDetachImpulse;
|
||||
_motor.BaseVelocity += detachImpulse;
|
||||
}
|
||||
if (!withImpulse || !_motor) return;
|
||||
|
||||
var detachImpulse = -_wallNormal * _wallDetachImpulse;
|
||||
_motor.BaseVelocity += detachImpulse;
|
||||
}
|
||||
|
||||
public Vector3 GetWallNormal() => _wallNormal;
|
||||
public bool TryGetWallTangents(out Vector3 up, out Vector3 right)
|
||||
{
|
||||
if (!_isWallRunning)
|
||||
{
|
||||
up = right = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
up = _wallTangentUp;
|
||||
right = _wallTangentRight;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CanWallRun()
|
||||
{
|
||||
return !_isWallRunning && !_motor.GroundingStatus.IsStableOnGround;
|
||||
}
|
||||
|
||||
public void PerformWallJump(CharacterInputs inputs, Quaternion cameraRotation)
|
||||
{
|
||||
if (!_isWallRunning || _motor == null) return;
|
||||
if (!IsWallRunning || !_motor) return;
|
||||
|
||||
_isWallRunning = false;
|
||||
IsWallRunning = false;
|
||||
|
||||
Vector3 wallAway = _wallNormal;
|
||||
Vector3 wallUp = _wallTangentUp;
|
||||
var wallAway = _wallNormal;
|
||||
var wallUp = _wallTangentUp;
|
||||
|
||||
Vector3 playerForward = cameraRotation * Vector3.forward;
|
||||
var playerForward = cameraRotation * Vector3.forward;
|
||||
|
||||
Vector3 forwardInWallPlane = Vector3.ProjectOnPlane(playerForward, _wallNormal).normalized;
|
||||
var forwardInWallPlane = Vector3.ProjectOnPlane(playerForward, _wallNormal).normalized;
|
||||
if (forwardInWallPlane.sqrMagnitude < 0.01f) forwardInWallPlane = _wallTangentRight;
|
||||
|
||||
Vector3 jumpDirection =
|
||||
var jumpDirection =
|
||||
forwardInWallPlane * 0.2f +
|
||||
wallAway * 0.4f +
|
||||
wallUp * 0.4f;
|
||||
|
||||
jumpDirection = jumpDirection.normalized;
|
||||
|
||||
float wallJumpForce = WallDetachImpulse * 2f;
|
||||
var wallJumpForce = _wallDetachImpulse * 2f;
|
||||
|
||||
Vector3 jumpImpulse = jumpDirection * wallJumpForce;
|
||||
var jumpImpulse = jumpDirection * wallJumpForce;
|
||||
|
||||
_motor.BaseVelocity += jumpImpulse;
|
||||
|
||||
|
||||
+39
-35
@@ -27,6 +27,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
|
||||
// Подсистемы
|
||||
private CharacterInputHandler _inputHandler;
|
||||
private DashMechanic _dashMechanic;
|
||||
private SlideMechanic _slideMechanic;
|
||||
// private WallClimbMechanic _wallClimbMechanic;
|
||||
private WallRunningMechanic _wallRunningMechanic;
|
||||
@@ -35,6 +36,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
private AirMovementSystem _airMovement;
|
||||
|
||||
public bool IsSliding => _slideMechanic.IsSliding;
|
||||
public bool IsDashing => _dashMechanic.IsDashing;
|
||||
public bool IsWallRunning => _wallRunningMechanic.IsWallRunning;
|
||||
|
||||
private float abilityBlockTimer;
|
||||
@@ -50,28 +52,25 @@ namespace Code.Gameplay.Character.Controller
|
||||
{
|
||||
_characterConfig = characterConfig;
|
||||
// Инициализация подсистем с параметрами из конфига
|
||||
_inputHandler = new CharacterInputHandler(
|
||||
_characterConfig.sprintAngleThreshold
|
||||
_inputHandler = new CharacterInputHandler();
|
||||
_dashMechanic = new DashMechanic(
|
||||
_characterConfig.dashSpeed,
|
||||
_characterConfig.dashDuration,
|
||||
_characterConfig.dashCooldown
|
||||
);
|
||||
_slideMechanic = new SlideMechanic(
|
||||
_characterConfig.slideSpeed,
|
||||
_characterConfig.slideDuration,
|
||||
_characterConfig.slideVelocityCurve,
|
||||
_characterConfig.slideMinVelocityThreshold,
|
||||
_characterConfig.slideCooldown
|
||||
);
|
||||
// _wallClimbMechanic = new WallClimbMechanic(
|
||||
// _characterConfig.wallClimbSpeedFactor,
|
||||
// _characterConfig.minWallClimbSpeed,
|
||||
// _characterConfig.wallDetectionAngleThreshold
|
||||
// );
|
||||
_wallRunningMechanic = new WallRunningMechanic();
|
||||
// Настройка параметров WallRunningMechanic (можно вынести в конфиг позже)
|
||||
_wallRunningMechanic.MaxWallRunTime = 1.75f;
|
||||
_wallRunningMechanic.WallRunSpeed = 15.0f;
|
||||
_wallRunningMechanic.WallRunAcceleration = 25.0f;
|
||||
_wallRunningMechanic.WallRunGravityScale = 0.25f;
|
||||
_wallRunningMechanic.WallDetachImpulse = 7.0f;
|
||||
_wallRunningMechanic.WallContactAngleThreshold = 45.0f;
|
||||
|
||||
_wallRunningMechanic = new WallRunningMechanic(
|
||||
_characterConfig.wallRunMaxTime,
|
||||
_characterConfig.wallRunSpeed,
|
||||
_characterConfig.wallRunAcceleration,
|
||||
_characterConfig.wallRunGravityScale,
|
||||
_characterConfig.wallDetachImpulse,
|
||||
_characterConfig.wallContactAngleThreshold
|
||||
);
|
||||
_wallLeanMechanic = new WallLeanMechanic(
|
||||
_characterConfig.leanAngle,
|
||||
_characterConfig.leanThreshold,
|
||||
@@ -79,12 +78,14 @@ namespace Code.Gameplay.Character.Controller
|
||||
);
|
||||
_groundMovement = new GroundMovementSystem(
|
||||
_characterConfig.maxStableMoveSpeed,
|
||||
_characterConfig.sprintMoveSpeed,
|
||||
_characterConfig.stableMovementSharpness,
|
||||
_characterConfig.jumpSpeed
|
||||
);
|
||||
_airMovement = new AirMovementSystem(_characterConfig.gravity);
|
||||
|
||||
_airMovement = new AirMovementSystem(
|
||||
_characterConfig.gravity,
|
||||
_characterConfig.maxAirSpeed,
|
||||
_characterConfig.airControlSharpness
|
||||
);
|
||||
|
||||
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
||||
_inputHandler.FirstPersonCameraRotation =
|
||||
@@ -99,17 +100,15 @@ namespace Code.Gameplay.Character.Controller
|
||||
public void SetInputs(ref CharacterInputs inputs)
|
||||
{
|
||||
_lastInputs = inputs;
|
||||
// Обновляем таймеры механик
|
||||
_dashMechanic.TickCooldown(Time.deltaTime);
|
||||
_slideMechanic.TickCooldown(Time.deltaTime);
|
||||
// _wallClimbMechanic.TickCooldown(Time.deltaTime);
|
||||
_wallRunningMechanic.Tick(Time.deltaTime);
|
||||
|
||||
// Если активен слайд - игнорируем весь остальной ввод
|
||||
if (_slideMechanic.IsSliding)
|
||||
if (_dashMechanic.IsDashing || _slideMechanic.IsSliding)
|
||||
{
|
||||
_inputHandler.MoveInputVector = Vector3.zero;
|
||||
_inputHandler.LookInputVector = Vector3.one;
|
||||
_inputHandler.IsSprinting = false;
|
||||
_groundMovement.RequestJump(inputs.JumpPressed);
|
||||
return;
|
||||
}
|
||||
@@ -125,12 +124,12 @@ namespace Code.Gameplay.Character.Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
inputs.SprintPressed = false;
|
||||
inputs.DashPressed = false;
|
||||
inputs.SlidePressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Обработка слайда
|
||||
_dashMechanic.RequestDash(inputs.DashPressed);
|
||||
_slideMechanic.RequestSlide(inputs.SlidePressed);
|
||||
|
||||
// Обработка остального ввода
|
||||
@@ -172,16 +171,21 @@ namespace Code.Gameplay.Character.Controller
|
||||
|
||||
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||
{
|
||||
if (_dashMechanic.IsDashing && _groundMovement.JumpRequested)
|
||||
_dashMechanic.EndDash();
|
||||
if (_slideMechanic.IsSliding && _groundMovement.JumpRequested)
|
||||
{
|
||||
_slideMechanic.EndSlide();
|
||||
|
||||
if (!_dashMechanic.IsDashing)
|
||||
_dashMechanic.TryStartDash(motor, _currentCameraMode, _inputHandler.FirstPersonCameraRotation, _inputHandler.LookInputVector);
|
||||
else
|
||||
{
|
||||
_dashMechanic.HandleDash(ref currentVelocity, deltaTime, motor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_slideMechanic.IsSliding)
|
||||
{
|
||||
_slideMechanic.TryStartSlide(motor, _currentCameraMode, _inputHandler.FirstPersonCameraRotation,
|
||||
_inputHandler.LookInputVector);
|
||||
}
|
||||
_slideMechanic.TryStartSlide(motor, _currentCameraMode, _inputHandler.FirstPersonCameraRotation, _inputHandler.LookInputVector);
|
||||
else
|
||||
{
|
||||
_slideMechanic.HandleSlide(ref currentVelocity, deltaTime, motor);
|
||||
@@ -212,7 +216,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
// Если персонаж не на земле — стандартное воздушное движение
|
||||
else
|
||||
{
|
||||
_airMovement.UpdateVelocity(ref currentVelocity, deltaTime);
|
||||
_airMovement.UpdateVelocity(ref currentVelocity, _inputHandler, motor, deltaTime);
|
||||
_groundMovement.CancelJumpRequest();
|
||||
}
|
||||
}
|
||||
@@ -229,10 +233,10 @@ namespace Code.Gameplay.Character.Controller
|
||||
|
||||
public void PostGroundingUpdate(float deltaTime)
|
||||
{
|
||||
if (_dashMechanic.IsDashing && !motor.GroundingStatus.IsStableOnGround)
|
||||
_dashMechanic.EndDash();
|
||||
if (_slideMechanic.IsSliding && !motor.GroundingStatus.IsStableOnGround)
|
||||
{
|
||||
_slideMechanic.EndSlide();
|
||||
}
|
||||
}
|
||||
|
||||
public void AfterCharacterUpdate(float deltaTime)
|
||||
|
||||
+1
-18
@@ -11,40 +11,23 @@ namespace Code.Gameplay.Character.Controller.Input
|
||||
*/
|
||||
public class CharacterInputHandler
|
||||
{
|
||||
// Косинус порогового угла для спринта (предвычислен)
|
||||
private readonly float _sprintAngleThresholdCos;
|
||||
|
||||
// Векторы движения и направления взгляда
|
||||
public Vector3 MoveInputVector { get; set; }
|
||||
public Vector3 LookInputVector { get; set; }
|
||||
|
||||
// Флаг-свойство указывающий, что активен режим спринта
|
||||
public bool IsSprinting { get; set; }
|
||||
|
||||
// Вращение камеры в FirstPerson режиме для синхронизации (только горизонтальная компонента)
|
||||
public Quaternion FirstPersonCameraRotation { get; set; }
|
||||
|
||||
// Флаг-свойство указывающий, что нужно применить вращение камеры к персонажу
|
||||
public bool ShouldApplyCameraRotation { get; private set; }
|
||||
|
||||
// Конструктор с пороговым углом
|
||||
public CharacterInputHandler(float sprintAngleThreshold)
|
||||
{
|
||||
// Предвычисляем косинус порогового угла для эффективности
|
||||
// Угол в градусах → радианы → косинус
|
||||
// Чем меньше угол — тем строже условие
|
||||
_sprintAngleThresholdCos = Mathf.Cos(Mathf.Deg2Rad * sprintAngleThreshold);
|
||||
}
|
||||
|
||||
|
||||
// Обработка и преобразование входных данных от персонажа
|
||||
public void ProcessInputs(ref CharacterInputs inputs, KinematicCharacterMotor motor)
|
||||
{
|
||||
// Сохраняем текущий режим камеры
|
||||
var currentCameraMode = inputs.CameraMode;
|
||||
|
||||
// Обработка спринта
|
||||
IsSprinting = inputs.SprintPressed && inputs.MoveAxisForward > _sprintAngleThresholdCos; // Спринт только при движении на заданный в конфиге угол
|
||||
|
||||
// Нормализация вектора движения и ограничение его величины до 1
|
||||
var moveInputVector =
|
||||
Vector3.ClampMagnitude(new Vector3(inputs.MoveAxisRight, 0, inputs.MoveAxisForward), 1f);
|
||||
|
||||
+23
-11
@@ -1,26 +1,38 @@
|
||||
using UnityEngine;
|
||||
using Code.Gameplay.Character.Controller.Input;
|
||||
using KinematicCharacterController;
|
||||
|
||||
namespace Code.Gameplay.Character.Controller.Movement
|
||||
{
|
||||
/*
|
||||
* Система движения персонажа в воздухе
|
||||
*/
|
||||
public class AirMovementSystem
|
||||
{
|
||||
// Вектор, отвечающий за применение гравитации
|
||||
private readonly Vector3 _gravity;
|
||||
|
||||
// Конструктор системы движения в воздухе
|
||||
public AirMovementSystem(Vector3 gravity)
|
||||
private readonly float _maxAirSpeed;
|
||||
private readonly float _airControlSharpness;
|
||||
|
||||
public AirMovementSystem(Vector3 gravity, float maxAirSpeed, float airControlSharpness)
|
||||
{
|
||||
_gravity = gravity;
|
||||
_maxAirSpeed = maxAirSpeed;
|
||||
_airControlSharpness = airControlSharpness;
|
||||
}
|
||||
|
||||
// Обновление скорости движения персонажа в воздухе
|
||||
public void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime)
|
||||
|
||||
public void UpdateVelocity(ref Vector3 currentVelocity, CharacterInputHandler inputHandler, KinematicCharacterMotor motor, float deltaTime)
|
||||
{
|
||||
// Применяем гравитацию
|
||||
currentVelocity += _gravity * deltaTime;
|
||||
|
||||
var horizontalVelocity = Vector3.ProjectOnPlane(currentVelocity, motor.CharacterUp);
|
||||
var verticalVelocity = Vector3.Dot(currentVelocity, motor.CharacterUp) * motor.CharacterUp;
|
||||
|
||||
var desiredHorizontalMovement = Vector3.ProjectOnPlane(inputHandler.MoveInputVector, motor.CharacterUp).normalized * _maxAirSpeed;
|
||||
|
||||
horizontalVelocity = Vector3.Lerp(
|
||||
horizontalVelocity,
|
||||
desiredHorizontalMovement,
|
||||
1f - Mathf.Exp(-_airControlSharpness * deltaTime)
|
||||
);
|
||||
|
||||
currentVelocity = horizontalVelocity + verticalVelocity;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -11,8 +11,6 @@ namespace Code.Gameplay.Character.Controller.Movement
|
||||
{
|
||||
// Максимальная скорость движения по устойчивой поверхности
|
||||
private readonly float _maxStableMoveSpeed;
|
||||
// Максимальная скорость спринта
|
||||
private readonly float _sprintMoveSpeed;
|
||||
// Резкость изменения скорости движения (чем выше - тем резче)
|
||||
private readonly float _stableMovementSharpness;
|
||||
// Скорость прыжка
|
||||
@@ -22,10 +20,9 @@ namespace Code.Gameplay.Character.Controller.Movement
|
||||
public bool JumpRequested { get; private set; }
|
||||
|
||||
// Конструктор системы движения на земле
|
||||
public GroundMovementSystem(float maxStableMoveSpeed, float sprintMoveSpeed, float stableMovementSharpness, float jumpSpeed)
|
||||
public GroundMovementSystem(float maxStableMoveSpeed, float stableMovementSharpness, float jumpSpeed)
|
||||
{
|
||||
_maxStableMoveSpeed = maxStableMoveSpeed;
|
||||
_sprintMoveSpeed = sprintMoveSpeed;
|
||||
_stableMovementSharpness = stableMovementSharpness;
|
||||
_jumpSpeed = jumpSpeed;
|
||||
}
|
||||
@@ -66,8 +63,7 @@ namespace Code.Gameplay.Character.Controller.Movement
|
||||
inputHandler.MoveInputVector.magnitude;
|
||||
|
||||
// Расчет целевой скорости движения с учетом ограничения максимальной скорости и спринта
|
||||
var targetSpeed = inputHandler.IsSprinting ? _sprintMoveSpeed : _maxStableMoveSpeed;
|
||||
var targetMovementVelocity = reorientedInput * targetSpeed;
|
||||
var targetMovementVelocity = reorientedInput * _maxStableMoveSpeed;
|
||||
|
||||
// Плавная интерполяция текущей скорости к целевой с экспоненциальным сглаживанием
|
||||
currentVelocity = Vector3.Lerp(
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace Code.Gameplay.Character.Core
|
||||
inputs.MoveAxisForward = moveInput.y; // Vertical ось (W/S или Up/Down)
|
||||
inputs.MoveAxisRight = moveInput.x; // Horizontal ось (A/D или Left/Right)
|
||||
inputs.JumpPressed = _inputService.JumpPressed; // Прыжки (Space)
|
||||
inputs.SprintPressed = _inputService.SprintPressed; // Спринт (Shift)
|
||||
inputs.SlidePressed = _inputService.SlidePressed; // Слайд (Ctrl)
|
||||
inputs.DashPressed = _inputService.DashPressed; // Слайд (Ctrl)
|
||||
inputs.CameraMode = ((ICameraState)_cameraStateMachine.CurrentBaseState).GetCameraMode();
|
||||
|
||||
// Передаем информацию о камере для адаптивного поведения
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Code.Gameplay.Character.Core
|
||||
public CameraMode CameraMode; // Текущий режим камеры для адаптации поведения
|
||||
public Vector3 CameraPlanarDirection; // Направление камеры в горизонтальной плоскости
|
||||
public bool JumpPressed; // Флаг указывающий, нажата ли кнопка прыжка
|
||||
public bool SprintPressed; // Флаг указывающий, нажата ли кнопка спринта
|
||||
public bool DashPressed;
|
||||
public bool SlidePressed; // Флаг указывающий, нажата ли кнопка слайда
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace Code.Gameplay.Character.Core
|
||||
inputs.MoveAxisForward = moveInput.y; // Vertical ось (W/S или Up/Down)
|
||||
inputs.MoveAxisRight = moveInput.x; // Horizontal ось (A/D или Left/Right)
|
||||
inputs.JumpPressed = _inputService.JumpPressed; // Прыжки (Space)
|
||||
inputs.SprintPressed = true;//_inputService.SprintPressed; // Спринт (Shift)
|
||||
inputs.DashPressed = _inputService.DashPressed;
|
||||
inputs.SlidePressed = _inputService.SlidePressed; // Слайд (Ctrl)
|
||||
inputs.CameraMode = ((ICameraState)_cameraStateMachine.CurrentBaseState).GetCameraMode();
|
||||
|
||||
|
||||
@@ -188,11 +188,10 @@ namespace Code.Gameplay.Enemies
|
||||
_canAttack = false;
|
||||
_attackCooldownTimer = AttackCooldown;
|
||||
}
|
||||
|
||||
protected virtual void ApplyEffectsToPlayer()
|
||||
{
|
||||
if (PlayerController)
|
||||
PlayerController.BlockAbilities(3f);
|
||||
PlayerController.BlockAbilities(3f); // TODO в конфиг
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Code.Gameplay.Enemies
|
||||
|
||||
if (!(distance <= AttackRange)) return;
|
||||
|
||||
audioService.PlayEnemy(EnemiesSounds.Bravo,agent.transform.position);
|
||||
audioService.PlayEnemy(EnemiesSounds.RoachAttack, agent.transform.position);
|
||||
|
||||
DealDamage();
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace Code.Gameplay.Enemies
|
||||
|
||||
if (!(distance <= AttackRange)) return;
|
||||
|
||||
audioService.PlayEnemy(EnemiesSounds.Bastard,agent.transform.position);
|
||||
audioService.PlayEnemy(EnemiesSounds.GrandpaAttack,agent.transform.position);
|
||||
|
||||
if (Player.CustomCharacterController.IsSliding)
|
||||
if (Player.CustomCharacterController.IsDashing || Player.CustomCharacterController.IsSliding)
|
||||
ApplyStun();
|
||||
else
|
||||
DealDamage();
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Code.Gameplay.Enemies
|
||||
|
||||
public void PlayStep()
|
||||
{
|
||||
Debug.Log("Play Step");
|
||||
_audioSource.transform.position = transform.position;
|
||||
_audioSource.PlayOneShot(_audioFactory.EnemiesAudios[(int)stepId]);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Gameplay.Orders.Order;
|
||||
using Code.Scenes;
|
||||
using Code.Scenes.SceneEnvironments;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Code.Scenes.SceneEnvironments;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -36,19 +35,10 @@ namespace Code.Generator
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
// _orderService.OrderGive();
|
||||
|
||||
_spawnedRooms = new List<Room>();
|
||||
_roomIndexesStack = new();
|
||||
|
||||
Debug.LogWarning($"КОТЛЫ ГЕНЕРАЛЬСКИЕ{_orderService.DeliveryTimer}");
|
||||
|
||||
// CreateRoomsStack();
|
||||
|
||||
// SpawnInitialRoomsAsync();
|
||||
_orderService.OnOrderGiven += CreateRoomsStack;
|
||||
// RoomTrigger.PlayerEnteredRoom += OnPlayerEntered;
|
||||
|
||||
CreateInitialRoom();
|
||||
}
|
||||
|
||||
@@ -61,7 +51,6 @@ namespace Code.Generator
|
||||
Room roomToRemove = _spawnedRooms[0];
|
||||
_spawnedRooms.RemoveAt(0);
|
||||
|
||||
// _factory.ReleaseRoom(roomToRemove);
|
||||
Object.Destroy(roomToRemove.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -81,16 +70,12 @@ namespace Code.Generator
|
||||
|
||||
_roomIndexesStack.Add(new(RoomType.Basic, roomIndex));
|
||||
remainingTime -= room.RoomTimer;
|
||||
Debug.Log($"комната {room.name} время {room.RoomTimer} осталось: {remainingTime}");
|
||||
}
|
||||
|
||||
AddPickupRoom();
|
||||
Debug.Log($"добавлена зона заказа");
|
||||
|
||||
AddSaveRoom();
|
||||
Debug.Log($"добавлена сейв зона");
|
||||
|
||||
Debug.Log($"стек комнат: {_roomIndexesStack.Count}");
|
||||
SpawnNextRoom();
|
||||
}
|
||||
|
||||
@@ -125,8 +110,6 @@ namespace Code.Generator
|
||||
|
||||
gameplaySceneEnvironment.playerSpawnPoint = instantiated.playerSpawn;
|
||||
instantiated.Initialize(_orderService);
|
||||
|
||||
Debug.Log($"Первая комната: {instantiated.name}");
|
||||
}
|
||||
private void SpawnNextRoom()
|
||||
{
|
||||
@@ -205,18 +188,8 @@ namespace Code.Generator
|
||||
|
||||
segmentOriginPosition.y -= randomDoorOriginPosition.y;
|
||||
current.transform.position = segmentOriginPosition;
|
||||
current.transform.rotation = Quaternion.Euler(0, segmentOriginYRotation, 0);
|
||||
// locationSegment.isNeedSomeDoors = true;
|
||||
// locationSegment.AddBadDoorId(locationSegment.LocationSegment.GetDoorOrigins.IndexOf(randomDoorOrigin));
|
||||
current.Initialize(_orderService);
|
||||
|
||||
// float frameOnTheBallRotation = segmentOriginYRotation + randomDoorOriginRotation.eulerAngles.y;
|
||||
// if (frameOnTheBallRotation > 305f) frameOnTheBallRotation -= 360f;
|
||||
// else if (frameOnTheBallRotation < -45f) frameOnTheBallRotation += 360f;
|
||||
|
||||
// heOnTheBall.AddSlaveLocationSegment(locationSegment.Id);
|
||||
// heOnTheBall.ReplaceSlaveSegmentDoorOriginYRotation(frameOnTheBallRotation);
|
||||
// heOnTheBall.isGotOnTheBall = false;
|
||||
current.transform.rotation = Quaternion.Euler(0, segmentOriginYRotation, 0);
|
||||
current.Initialize(_orderService);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Code.Input
|
||||
// Для управления движением персонажа
|
||||
Vector2 MoveInput { get; }
|
||||
bool JumpPressed { get; }
|
||||
bool SprintPressed { get; }
|
||||
bool SlidePressed { get; }
|
||||
bool DashPressed { get; }
|
||||
|
||||
// Для переключения режима камеры
|
||||
bool ToggleCameraModePressed { get; }
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace Code.Input
|
||||
public float ZoomInput { get; private set; }
|
||||
public Vector2 MoveInput { get; private set; }
|
||||
public bool JumpPressed { get; private set; }
|
||||
public bool SprintPressed { get; private set; }
|
||||
public bool SlidePressed { get; private set; }
|
||||
public bool DashPressed { get; private set; }
|
||||
public bool ToggleCameraModePressed { get; private set; }
|
||||
|
||||
public InputService(InputActionAsset inputActionAsset)
|
||||
@@ -69,14 +69,6 @@ namespace Code.Input
|
||||
jumpAction.canceled += OnJumpCanceled;
|
||||
}
|
||||
|
||||
// Обработка спринта (персонаж)
|
||||
var sprintAction = gameplayMap.FindAction("Sprint");
|
||||
if (sprintAction != null)
|
||||
{
|
||||
sprintAction.performed += OnSprintPerformed;
|
||||
sprintAction.canceled += OnSprintCanceled;
|
||||
}
|
||||
|
||||
// Обработка слайда (персонаж)
|
||||
var slideAction = gameplayMap.FindAction("Slide");
|
||||
if (slideAction != null)
|
||||
@@ -85,6 +77,14 @@ namespace Code.Input
|
||||
slideAction.canceled += OnSlideCanceled;
|
||||
}
|
||||
|
||||
// Обработка слайда (персонаж)
|
||||
var dashAction = gameplayMap.FindAction("Dash");
|
||||
if (dashAction != null)
|
||||
{
|
||||
dashAction.performed += OnDashPerformed;
|
||||
dashAction.canceled += OnDashCanceled;
|
||||
}
|
||||
|
||||
// Обработка переключения режима камеры
|
||||
var toggleCameraModeAction = gameplayMap.FindAction("ToggleCameraMode");
|
||||
if (toggleCameraModeAction != null)
|
||||
@@ -134,16 +134,6 @@ namespace Code.Input
|
||||
JumpPressed = false;
|
||||
}
|
||||
|
||||
private void OnSprintPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
SprintPressed = true;
|
||||
}
|
||||
|
||||
private void OnSprintCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
SprintPressed = false;
|
||||
}
|
||||
|
||||
private void OnSlidePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
SlidePressed = true;
|
||||
@@ -154,6 +144,16 @@ namespace Code.Input
|
||||
SlidePressed = false;
|
||||
}
|
||||
|
||||
private void OnDashPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
DashPressed = true;
|
||||
}
|
||||
|
||||
private void OnDashCanceled(InputAction.CallbackContext context)
|
||||
{
|
||||
DashPressed = false;
|
||||
}
|
||||
|
||||
private void OnToggleCameraModePerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
ToggleCameraModePressed = true;
|
||||
@@ -189,12 +189,12 @@ namespace Code.Input
|
||||
gameplayMap.FindAction("Jump").performed -= OnJumpPerformed;
|
||||
gameplayMap.FindAction("Jump").canceled -= OnJumpCanceled;
|
||||
|
||||
gameplayMap.FindAction("Sprint").performed -= OnSprintPerformed;
|
||||
gameplayMap.FindAction("Sprint").canceled -= OnSprintCanceled;
|
||||
|
||||
gameplayMap.FindAction("Slide").performed -= OnSlidePerformed;
|
||||
gameplayMap.FindAction("Slide").canceled -= OnSlideCanceled;
|
||||
|
||||
gameplayMap.FindAction("Dash").performed -= OnDashPerformed;
|
||||
gameplayMap.FindAction("Dash").canceled -= OnDashCanceled;
|
||||
|
||||
gameplayMap.FindAction("ToggleCameraMode").performed -= OnToggleCameraModePerformed;
|
||||
gameplayMap.FindAction("ToggleCameraMode").canceled -= OnToggleCameraModeCanceled;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Code.Gameplay.Orders.Order;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Code.Scenes.SceneEnvironments
|
||||
@@ -7,11 +8,13 @@ namespace Code.Scenes.SceneEnvironments
|
||||
[System.Serializable]
|
||||
public class GameplaySceneEnvironment : CurrentSceneEnvironment
|
||||
{
|
||||
public Transform playerSpawnPoint;
|
||||
public Transform playerSpawnPoint;
|
||||
public Volume volume;
|
||||
|
||||
public void TransitVariables(GameplaySceneEnvironment env)
|
||||
{
|
||||
playerSpawnPoint = env.playerSpawnPoint;
|
||||
volume = env.volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.UI.Panels
|
||||
{
|
||||
public class DamagePanel : UIElement
|
||||
{
|
||||
[SerializeField] private Image background;
|
||||
[SerializeField] private Color shownColor;
|
||||
[SerializeField] private Color hiddenColor;
|
||||
public override void Hide()
|
||||
{
|
||||
Shown = false;
|
||||
// background.enabled = false;
|
||||
background.DOColor(hiddenColor, 2f);
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
Shown = true;
|
||||
// background.enabled = true;
|
||||
background.DOColor(shownColor, 0.3f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b586dbc292c44261892460f578a38e50
|
||||
timeCreated: 1764769541
|
||||
@@ -1,3 +1,4 @@
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -9,21 +10,27 @@ namespace Code.UI
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text gameOverText;
|
||||
[SerializeField] private Image _background;
|
||||
[SerializeField] private Color shownColor;
|
||||
[SerializeField] private Color hiddenColor;
|
||||
|
||||
public void UpdateScoreText(int score) => scoreText.text = score.ToString();
|
||||
|
||||
public override void Hide()
|
||||
{
|
||||
_background.enabled = false;
|
||||
scoreText.enabled = false;
|
||||
gameOverText.enabled = false;
|
||||
// scoreText.enabled = true;
|
||||
// gameOverText.enabled = false;
|
||||
scoreText.DOColor(hiddenColor, 3f);
|
||||
// gameOverText.DOColor(hiddenColor, 3f);
|
||||
base.Hide();
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
_background.enabled = true;
|
||||
scoreText.enabled = true;
|
||||
gameOverText.enabled = true;
|
||||
// _background.enabled = true;
|
||||
// scoreText.enabled = true;
|
||||
// gameOverText.enabled = true;
|
||||
scoreText.DOColor(shownColor, 5f);
|
||||
// gameOverText.DOColor(shownColor, 5f);
|
||||
base.Show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ namespace Code.UI.Panels
|
||||
[Header("MoneyBar")]
|
||||
[SerializeField] private TMP_Text moneyText;
|
||||
|
||||
[SerializeField] private DamagePanel damagePanel;
|
||||
public DamagePanel DamagePanel => damagePanel;
|
||||
|
||||
private void ScoreUpdate(int count, int money)
|
||||
{
|
||||
// TODO Анимация получения\потери
|
||||
|
||||
@@ -7,21 +7,24 @@ namespace Code.UI.Panels
|
||||
public class LoadingScreen : UIElement
|
||||
{
|
||||
[SerializeField] private Image background;
|
||||
[SerializeField] private TMP_Text loadingTitle;
|
||||
[SerializeField] private TMP_Text vyapWatermark;
|
||||
[SerializeField] private Image loadingImage;
|
||||
// [SerializeField] private TMP_Text loadingTitle;
|
||||
// [SerializeField] private TMP_Text vyapWatermark;
|
||||
public override void Hide()
|
||||
{
|
||||
Shown = false;
|
||||
background.enabled = false;
|
||||
loadingTitle.enabled = false;
|
||||
vyapWatermark.enabled = false;
|
||||
loadingImage.enabled = false;
|
||||
// loadingTitle.enabled = false;
|
||||
// vyapWatermark.enabled = false;
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
Shown = true;
|
||||
background.enabled = true;
|
||||
loadingTitle.enabled = true;
|
||||
vyapWatermark.enabled = true;
|
||||
loadingImage.enabled = true;
|
||||
// loadingTitle.enabled = true;
|
||||
// vyapWatermark.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ namespace Code.UI
|
||||
private void OnMenuMusicUpdate(float value)
|
||||
{
|
||||
_audioService.ChangeSetting(AudioType.MenuMusic, value);
|
||||
_audioService.ChangeSetting(AudioType.DeathMusic, value);
|
||||
_audioService.PlayTestClip(AudioType.MenuMusic);
|
||||
}
|
||||
private void OnGameplayUpdate(float value)
|
||||
|
||||
Reference in new issue
Block a user