Death added

This commit is contained in:
Syntriax 2022-02-26 18:31:19 +03:00
parent 3ccc7a24b8
commit 5b9d219464
7 changed files with 283 additions and 8 deletions

View File

@ -28,6 +28,20 @@ AudioMixerEffectController:
m_SendTarget: {fileID: 0} m_SendTarget: {fileID: 0}
m_EnableWetMix: 0 m_EnableWetMix: 0
m_Bypass: 0 m_Bypass: 0
--- !u!244 &-5232129410300169738
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 8ac3a9269f49f264abc2b0c5013e1aa5
m_EffectName: Attenuation
m_MixLevel: b1610f56bf7cf4543915d51c413eb143
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!243 &-2600467795151966735 --- !u!243 &-2600467795151966735
AudioMixerGroupController: AudioMixerGroupController:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -69,6 +83,7 @@ AudioMixerController:
- 5c6c050f48fa1cf418601041c7d6c16f - 5c6c050f48fa1cf418601041c7d6c16f
- aec3f58549ce7b4478c453c40c434318 - aec3f58549ce7b4478c453c40c434318
- 88391c573bd80364c916040d855538c8 - 88391c573bd80364c916040d855538c8
- 08116dbf9979b7b4d8fcce772ec5ebfc
name: View name: View
m_CurrentViewIndex: 0 m_CurrentViewIndex: 0
m_TargetSnapshot: {fileID: 24500006} m_TargetSnapshot: {fileID: 24500006}
@ -85,6 +100,7 @@ AudioMixerGroupController:
- {fileID: -2600467795151966735} - {fileID: -2600467795151966735}
- {fileID: 8913006207396984383} - {fileID: 8913006207396984383}
- {fileID: 8377903610078173799} - {fileID: 8377903610078173799}
- {fileID: 6090405236815604520}
m_Volume: c8ed3e32c19202b4daadc5c4fb90bf76 m_Volume: c8ed3e32c19202b4daadc5c4fb90bf76
m_Pitch: d51ab31c176e6894b94b24c01f74415f m_Pitch: d51ab31c176e6894b94b24c01f74415f
m_Send: 00000000000000000000000000000000 m_Send: 00000000000000000000000000000000
@ -119,6 +135,25 @@ AudioMixerSnapshotController:
m_SnapshotID: 7b03920a55d36f54bac08488dc018422 m_SnapshotID: 7b03920a55d36f54bac08488dc018422
m_FloatValues: {} m_FloatValues: {}
m_TransitionOverrides: {} m_TransitionOverrides: {}
--- !u!243 &6090405236815604520
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Death
m_AudioMixer: {fileID: 24100000}
m_GroupID: 08116dbf9979b7b4d8fcce772ec5ebfc
m_Children: []
m_Volume: 23a0004fa1be74144ad5d7029d584609
m_Pitch: 43f3175ec3407354bb8c0e63d6d1dde9
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: -5232129410300169738}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &6357565719084711451 --- !u!244 &6357565719084711451
AudioMixerEffectController: AudioMixerEffectController:
m_ObjectHideFlags: 3 m_ObjectHideFlags: 3

View File

@ -290,7 +290,7 @@ Rigidbody2D:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Interpolate: 0 m_Interpolate: 0
m_SleepingMode: 1 m_SleepingMode: 1
m_CollisionDetection: 0 m_CollisionDetection: 1
m_Constraints: 4 m_Constraints: 4
--- !u!114 &8503951513957676288 --- !u!114 &8503951513957676288
MonoBehaviour: MonoBehaviour:

View File

@ -46,7 +46,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask: layerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 4294967103 m_Bits: 4294966335
--- !u!1 &2083070160 --- !u!1 &2083070160
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -93,7 +93,54 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask: layerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 4294967103 m_Bits: 4294966335
--- !u!1 &2460162872455742730
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5380164631756810673}
- component: {fileID: 3193203585355150635}
m_Layer: 6
m_Name: Enemy Trigger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5380164631756810673
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2460162872455742730}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -0.25, z: 0}
m_LocalScale: {x: 1.6, y: 1.6, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7008207192594766311}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3193203585355150635
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2460162872455742730}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7000c8c0eb91b2d4cb9a0e3ee1b609a7, type: 3}
m_Name:
m_EditorClassIdentifier:
layerMask:
serializedVersion: 2
m_Bits: 4294966912
--- !u!1 &7008207192594766305 --- !u!1 &7008207192594766305
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -109,6 +156,7 @@ GameObject:
- component: {fileID: 7008207192594766308} - component: {fileID: 7008207192594766308}
- component: {fileID: 4083120737150353938} - component: {fileID: 4083120737150353938}
- component: {fileID: 2092414857397911188} - component: {fileID: 2092414857397911188}
- component: {fileID: 7892559024328115078}
m_Layer: 6 m_Layer: 6
m_Name: Player m_Name: Player
m_TagString: Player m_TagString: Player
@ -131,6 +179,8 @@ Transform:
- {fileID: 7008207193600475140} - {fileID: 7008207193600475140}
- {fileID: 698768805} - {fileID: 698768805}
- {fileID: 2083070161} - {fileID: 2083070161}
- {fileID: 5380164631756810673}
- {fileID: 5932034958742124507}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -198,7 +248,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1e9f5de2199c4784abce74247804ce87, type: 3} m_Script: {fileID: 11500000, guid: 1e9f5de2199c4784abce74247804ce87, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
jumpAudioClip: {fileID: 8300000, guid: c366515880a212d45aad5408ce027da3, type: 3}
--- !u!50 &7008207192594766309 --- !u!50 &7008207192594766309
Rigidbody2D: Rigidbody2D:
serializedVersion: 4 serializedVersion: 4
@ -362,6 +411,18 @@ AudioSource:
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
--- !u!114 &7892559024328115078
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7008207192594766305}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c16e6ed26e877e42ba1955f39094ddf, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &7008207193600475141 --- !u!1 &7008207193600475141
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -408,4 +469,145 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
layerMask: layerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 4294967048 m_Bits: 4294966280
--- !u!1 &7718275112619760423
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5932034958742124507}
- component: {fileID: 341567328791663827}
- component: {fileID: 8364197196962726582}
m_Layer: 6
m_Name: Death
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5932034958742124507
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7718275112619760423}
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: 7008207192594766311}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &341567328791663827
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7718275112619760423}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7c16e6ed26e877e42ba1955f39094ddf, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!82 &8364197196962726582
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7718275112619760423}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 6090405236815604520, guid: 55dad93ba7816e44c83798006fa0a277, type: 2}
m_audioClip: {fileID: 8300000, guid: 45157062ea57f1f4fb2271380bb846e4, type: 3}
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

View File

@ -6,7 +6,6 @@ namespace AI
[RequireComponent(typeof(Rigidbody2D))] [RequireComponent(typeof(Rigidbody2D))]
public class Projectile : MonoBehaviour, IPausable public class Projectile : MonoBehaviour, IPausable
{ {
[SerializeField] protected float damageOnContact = 50f;
private Rigidbody2D _rigidbody = null; private Rigidbody2D _rigidbody = null;
private void Awake() private void Awake()
@ -22,6 +21,9 @@ namespace AI
private void OnCollisionEnter2D(Collision2D other) private void OnCollisionEnter2D(Collision2D other)
{ {
ProjectilePool.Instance.Return(this); ProjectilePool.Instance.Return(this);
if (other.transform.CompareTag("Player"))
other.gameObject.GetComponent<Player.Death>().Die();
} }
public bool IsPaused { get; protected set; } = false; public bool IsPaused { get; protected set; } = false;

View File

@ -0,0 +1,19 @@
using Level;
using UnityEngine;
namespace Player
{
public class Death : MonoBehaviour
{
private AudioSource audioSource = null;
private void Start() => audioSource = GetComponent<AudioSource>();
public void Die()
{
LevelManager.Instance.CurrentLevel.Restart();
// Playing it after the restart because when the player gets deactivated the sound stops so it doesn't play the sound at all
audioSource.Play();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c16e6ed26e877e42ba1955f39094ddf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2,7 +2,6 @@ using System;
using Movement; using Movement;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using PlayerInput = Input.PlayerInput; using PlayerInput = Input.PlayerInput;
namespace Player namespace Player
@ -50,6 +49,8 @@ namespace Player
private const string IsGroundedParameter = "IsGrounded"; private const string IsGroundedParameter = "IsGrounded";
private const string IsWalledParameter = "IsWalled"; private const string IsWalledParameter = "IsWalled";
private Animator animator = null; private Animator animator = null;
private Death death = null;
private CollisionChecker enemyTrigger = null;
private void Awake() private void Awake()
{ {
@ -75,6 +76,8 @@ namespace Player
animator = GetComponent<Animator>(); animator = GetComponent<Animator>();
audioSource = GetComponent<AudioSource>(); audioSource = GetComponent<AudioSource>();
death = transform.Find("Death").gameObject.GetComponent<Death>();
enemyTrigger = GameObject.Find("Enemy Trigger").GetComponent<CollisionChecker>();
BaseSpeed = 0.0f; BaseSpeed = 0.0f;
} }
@ -133,12 +136,15 @@ namespace Player
{ {
_isOnAir = !_playerGroundTrigger.IsCollided; _isOnAir = !_playerGroundTrigger.IsCollided;
RespawnCheck(); RespawnCheck();
if (enemyTrigger.IsCollided)
death.Die();
} }
private void RespawnCheck() private void RespawnCheck()
{ {
if (gameObject.transform.position.y < RespawnLimit) if (gameObject.transform.position.y < RespawnLimit)
SceneManager.LoadScene(SceneManager.GetActiveScene().name); death.Die();
} }
// PAUSE METHODS // PAUSE METHODS