Refactor player death handling; update enemy exit positions; adjust jump pad scale and light dimmer logic
This commit is contained in:
parent
46b8ed61cb
commit
5e7b1c4cdd
@ -51,7 +51,7 @@ AnimatorStateMachine:
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 310, y: 120, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 310, y: 250, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -1233016841924035968}
|
||||
--- !u!1102 &-1233016841924035968
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -116,34 +116,35 @@ AnimatorStateMachine:
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 3687052423515968881}
|
||||
m_Position: {x: 750, y: 60, z: 0}
|
||||
m_Position: {x: 1040, y: -280, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 5568672277228065884}
|
||||
m_Position: {x: 750, y: -10, z: 0}
|
||||
m_Position: {x: 790, y: -280, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 1964106236550896814}
|
||||
m_Position: {x: 520, y: -70, z: 0}
|
||||
m_Position: {x: 520, y: -420, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 4892115860334434523}
|
||||
m_Position: {x: 290, y: -10, z: 0}
|
||||
m_Position: {x: 520, y: -280, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -7985827421827872045}
|
||||
m_Position: {x: 520, y: -10, z: 0}
|
||||
m_Position: {x: 520, y: -160, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -234086058997577863}
|
||||
m_Position: {x: 520, y: 60, z: 0}
|
||||
m_Position: {x: 520, y: -60, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -4551320674845357304}
|
||||
m_Position: {x: 520, y: 120, z: 0}
|
||||
m_Position: {x: 260, y: -420, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions:
|
||||
- {fileID: -4357743603330148193}
|
||||
- {fileID: 4264613523883012702}
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 310, y: -70, z: 0}
|
||||
m_EntryPosition: {x: 770, y: 130, z: 0}
|
||||
m_ExitPosition: {x: 540, y: -120, z: 0}
|
||||
m_AnyStatePosition: {x: 540, y: -600, z: 0}
|
||||
m_EntryPosition: {x: 1280, y: -270, z: 0}
|
||||
m_ExitPosition: {x: 890, y: -420, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 3687052423515968881}
|
||||
--- !u!1102 &-4551320674845357304
|
||||
@ -364,6 +365,12 @@ AnimatorController:
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Death
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
@ -482,6 +489,31 @@ AnimatorState:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &4264613523883012702
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Death
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -4551320674845357304}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.75
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &4892115860334434523
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2629,6 +2629,7 @@ GameObject:
|
||||
- component: {fileID: 5723917688524288437}
|
||||
- component: {fileID: 9068111837403598740}
|
||||
- component: {fileID: 6106630833600239313}
|
||||
- component: {fileID: -953906007136484429}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@ -2867,6 +2868,20 @@ MonoBehaviour:
|
||||
launchAxis: {x: 1, y: 0}
|
||||
launchPoint: {fileID: 6550761234582043067}
|
||||
attachPoint: {fileID: 6550761234593413718}
|
||||
--- !u!114 &-953906007136484429
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6550761235523395909}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f4612beb3ca33c4b9e2a6a2068977ab, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::PayerAnimationEvents
|
||||
callRespawnOnDeathEnd: 1
|
||||
disableRootMotionDuringDeath: 0
|
||||
--- !u!1 &6550761235546795891
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using RR.Game2D.Behaviour;
|
||||
using UnityEngine;
|
||||
|
||||
public class PayerAnimationEvents : MonoBehaviour
|
||||
{
|
||||
private Rigidbody2D _rigidbody;
|
||||
private Collider2D _collider;
|
||||
private PlayerController _controller;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody2D>();
|
||||
_collider = GetComponent<Collider2D>();
|
||||
}
|
||||
|
||||
public void OnDeathBegin()
|
||||
{
|
||||
if (_collider) _collider.isTrigger = true;
|
||||
if (!_rigidbody) return;
|
||||
_rigidbody.linearVelocity = Vector2.zero;
|
||||
// _rigidbody.bodyType = RigidbodyType2D.Kinematic;
|
||||
}
|
||||
|
||||
// private void OnDeathByEnemy()
|
||||
// {
|
||||
// // Custom logic for when the player dies by an enemy
|
||||
// Debug.Log("Player has died by an enemy.");
|
||||
// }
|
||||
//
|
||||
// private void OnDeathByHazard()
|
||||
// {
|
||||
// // Custom logic for when the player dies by a hazard
|
||||
// Debug.Log("Player has died by a hazard.");
|
||||
// }
|
||||
//
|
||||
// private void OnDeathByVoid()
|
||||
// {
|
||||
// // Custom logic for when the player dies by falling into the void
|
||||
// Debug.Log("Player has died by falling into the void.");
|
||||
// }
|
||||
|
||||
public void OnDeathEnd()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
23
Assets/Scripts/Behaviour/Animations/PlayerAnimationEvents.cs
Normal file
23
Assets/Scripts/Behaviour/Animations/PlayerAnimationEvents.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using RR.Game2D.Behaviour;
|
||||
using RR.Game2D.Core;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerAnimationEvents : MonoBehaviour
|
||||
{
|
||||
private PlayerController _controller;
|
||||
private Rigidbody2D _rb;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_controller = GetComponent<PlayerController>();
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
}
|
||||
|
||||
public void OnDeathEnd()
|
||||
{
|
||||
Animator animator = GetComponent<Animator>();
|
||||
animator.ResetTrigger("Death");
|
||||
gameObject.layer = LayerMask.NameToLayer("Default");
|
||||
GameManager.Instance.RespawnPlayer();
|
||||
}
|
||||
}
|
||||
@ -42,19 +42,19 @@ namespace RR.Game2D.Behaviour
|
||||
public float MaxHealth => health?.MaxHealth ?? 0;
|
||||
|
||||
private Rigidbody2D rb;
|
||||
//private Collider2D col;
|
||||
// private Collider2D col;
|
||||
|
||||
private float inputX;
|
||||
private bool jumpPressed, jumpReleased, jumpHold;
|
||||
|
||||
private float _fallSpeedYDampingChangeThreshold;
|
||||
|
||||
|
||||
// Аниматор
|
||||
private static readonly int Jump = Animator.StringToHash("Jump");
|
||||
private static readonly int Speed = Animator.StringToHash("Speed");
|
||||
private static readonly int VSpeed = Animator.StringToHash("VSpeed");
|
||||
private static readonly int GroundedAnimator = Animator.StringToHash("Grounded");
|
||||
private static readonly int Death = Animator.StringToHash("Death");
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
@ -179,7 +179,8 @@ namespace RR.Game2D.Behaviour
|
||||
|
||||
public void Die()
|
||||
{
|
||||
GameManager.Instance.RespawnPlayer();
|
||||
gameObject.layer = LayerMask.NameToLayer("No Collision");
|
||||
animator.SetTrigger(Death);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using RR.Game2D.Core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
@ -111,7 +112,7 @@ public class LightDimmer : MonoBehaviour
|
||||
|
||||
UpdateBounds();
|
||||
|
||||
if (string.IsNullOrEmpty(playerTag)) playerTag = "Player";
|
||||
if (playerTransform == null) playerTransform = GameManager.Instance.PlayerObj.transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -123,21 +124,28 @@ public class LightDimmer : MonoBehaviour
|
||||
// Требуем наличие: playerTransform, массив lights и targetCollider
|
||||
if (!playerTransform || lights == null || lights.Length == 0 || targetCollider == null)
|
||||
return;
|
||||
|
||||
// Debug.Log($"{name}: Player Transform Detected");
|
||||
|
||||
// Проверяем, что игрок действительно внутри триггера, учитываем все коллайдеры (на случай CompositeCollider/мультиколлайдеров)
|
||||
bool playerInside = playerColliders.Count > 0;
|
||||
if (!playerInside)
|
||||
return;
|
||||
|
||||
// Debug.Log($"{name}: Player Inside Trigger");
|
||||
|
||||
Vector3 playerPos = playerTransform.position;
|
||||
|
||||
// Дополнительная проверка: AABB bounds коллайдера (быстрая фильтрация), чтобы избежать лишних вычислений
|
||||
if (!targetCollider.bounds.Contains(playerPos))
|
||||
return;
|
||||
|
||||
// if (!targetCollider.bounds.Contains(playerPos))
|
||||
// return;
|
||||
|
||||
// Debug.Log($"{name}: Player Position: {playerPos}");
|
||||
|
||||
// Выбираем координату для прогресса: X или Y
|
||||
float playerCurrent = useYProgress ? playerPos.y : playerPos.x;
|
||||
|
||||
|
||||
// Debug.Log($"{name}: Player Current Coordinate: {playerCurrent}");
|
||||
|
||||
float t = 0f;
|
||||
// Если boundsMin==boundsMax — делить нельзя, поэтому проверяем приблизительное равенство
|
||||
if (!Mathf.Approximately(boundsMax, boundsMin))
|
||||
@ -146,7 +154,9 @@ public class LightDimmer : MonoBehaviour
|
||||
t = Mathf.InverseLerp(boundsMin, boundsMax, playerCurrent);
|
||||
t = Mathf.Clamp01(t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Интерполируем целевые значения интенсивности и bloom в зависимости от нормализованной позиции t
|
||||
float desiredForPosition = Mathf.Lerp(startIntensity, endIntensity, t);
|
||||
float desiredForBloom = Mathf.Lerp(startBloomIntensity, targetBloomIntensity, t);
|
||||
|
||||
@ -226,7 +226,7 @@ namespace RR.Game2D.Core
|
||||
{
|
||||
// отнимем жизнь (оставляем текущее поведение); монеты не сбрасываем
|
||||
Lives--;
|
||||
LivesChanged?.Invoke(Lives);
|
||||
LivesChanged?.Invoke(Lives);
|
||||
|
||||
if (Lives <= 0)
|
||||
{
|
||||
|
||||
@ -95,6 +95,7 @@ namespace RR.Game2D.Entities.Projectiles
|
||||
Vector3 jumpPadScale = jumpPad.transform.localScale;
|
||||
// Уменьшаем по высоте — платформа тонкая
|
||||
jumpPadScale.y = 0.1f;
|
||||
jumpPadScale.x = 2f;
|
||||
jumpPad.transform.localScale = jumpPadScale;
|
||||
jumpPad.SetActive(false);
|
||||
// Подписываемся на событие прыжка с платформы
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user