player can only access items in correct scenes

This commit is contained in:
Sam 2023-05-01 01:52:42 -07:00
parent d3893d3f0e
commit 932af31dc9
12 changed files with 406 additions and 22 deletions

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 4018407283885727215} - component: {fileID: 4018407283885727215}
- component: {fileID: 5337163787054360807} - component: {fileID: 5337163787054360807}
- component: {fileID: 4224870664944535266} - component: {fileID: 4224870664944535266}
- component: {fileID: -4084164937358032629}
m_Layer: 0 m_Layer: 0
m_Name: Bat m_Name: Bat
m_TagString: Enemy m_TagString: Enemy
@ -178,6 +179,102 @@ BoxCollider2D:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1.1846523, y: 1.521285} m_Size: {x: 1.1846523, y: 1.521285}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!82 &-4084164937358032629
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 493245979038171997}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 2a260b816c5584e4bbdc58ca862a5286, 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
--- !u!1 &2874897583829168077 --- !u!1 &2874897583829168077
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -242,7 +339,7 @@ BoxCollider2D:
m_IsTrigger: 1 m_IsTrigger: 1
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: 0.058219433, y: 1.1354268} m_Offset: {x: 0.058219433, y: 1.6015409}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0} pivot: {x: 0, y: 0}
@ -253,5 +350,5 @@ BoxCollider2D:
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 2.125578, y: 2.1344056} m_Size: {x: 2.125578, y: 1.656923}
m_EdgeRadius: 0 m_EdgeRadius: 0

View File

@ -146,6 +146,7 @@ GameObject:
- component: {fileID: 5559747613460074786} - component: {fileID: 5559747613460074786}
- component: {fileID: 2772748892378701928} - component: {fileID: 2772748892378701928}
- component: {fileID: 1842747687311249101} - component: {fileID: 1842747687311249101}
- component: {fileID: 7723079812236791708}
m_Layer: 2 m_Layer: 2
m_Name: Player m_Name: Player
m_TagString: Player m_TagString: Player
@ -457,6 +458,102 @@ BoxCollider2D:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.34375, y: 0.4375} m_Size: {x: 0.34375, y: 0.4375}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!82 &7723079812236791708
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5885597207104481991}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 3498b07b14bc248cdbc50aa434f962c2, 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
--- !u!1 &5885597207531562995 --- !u!1 &5885597207531562995
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 4018407283885727215} - component: {fileID: 4018407283885727215}
- component: {fileID: 5337163787054360807} - component: {fileID: 5337163787054360807}
- component: {fileID: 4224870664944535266} - component: {fileID: 4224870664944535266}
- component: {fileID: 432379776948736043}
m_Layer: 0 m_Layer: 0
m_Name: Snake m_Name: Snake
m_TagString: Enemy m_TagString: Enemy
@ -178,6 +179,102 @@ BoxCollider2D:
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 1, y: 0.875} m_Size: {x: 1, y: 0.875}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!82 &432379776948736043
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 493245979038171997}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 2a260b816c5584e4bbdc58ca862a5286, 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
--- !u!1 &6199841205034961327 --- !u!1 &6199841205034961327
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

BIN
Assets/SFX/enemy_defeat.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 2a260b816c5584e4bbdc58ca862a5286
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 3498b07b14bc248cdbc50aa434f962c2
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5174,7 +5174,7 @@ Tilemap:
second: second:
serializedVersion: 2 serializedVersion: 2
m_TileIndex: 11 m_TileIndex: 11
m_TileSpriteIndex: 8 m_TileSpriteIndex: 9
m_TileMatrixIndex: 0 m_TileMatrixIndex: 0
m_TileColorIndex: 0 m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535 m_TileObjectToInstantiateIndex: 65535
@ -5244,7 +5244,7 @@ Tilemap:
second: second:
serializedVersion: 2 serializedVersion: 2
m_TileIndex: 10 m_TileIndex: 10
m_TileSpriteIndex: 7 m_TileSpriteIndex: 8
m_TileMatrixIndex: 0 m_TileMatrixIndex: 0
m_TileColorIndex: 0 m_TileColorIndex: 0
m_TileObjectToInstantiateIndex: 65535 m_TileObjectToInstantiateIndex: 65535
@ -5345,12 +5345,12 @@ Tilemap:
m_Data: {fileID: 0} m_Data: {fileID: 0}
- m_RefCount: 0 - m_RefCount: 0
m_Data: {fileID: 0} m_Data: {fileID: 0}
- m_RefCount: 0
m_Data: {fileID: 0}
- m_RefCount: 1 - m_RefCount: 1
m_Data: {fileID: -1680641961, guid: 2097266264e574d71a38da279b45c7c0, type: 3} m_Data: {fileID: -1680641961, guid: 2097266264e574d71a38da279b45c7c0, type: 3}
- m_RefCount: 1 - m_RefCount: 1
m_Data: {fileID: -610258227, guid: 2097266264e574d71a38da279b45c7c0, type: 3} m_Data: {fileID: -610258227, guid: 2097266264e574d71a38da279b45c7c0, type: 3}
- m_RefCount: 0
m_Data: {fileID: 0}
- m_RefCount: 2 - m_RefCount: 2
m_Data: {fileID: 1096025109, guid: 2097266264e574d71a38da279b45c7c0, type: 3} m_Data: {fileID: 1096025109, guid: 2097266264e574d71a38da279b45c7c0, type: 3}
- m_RefCount: 2 - m_RefCount: 2
@ -5874,7 +5874,7 @@ AudioSource:
OutputAudioMixerGroup: {fileID: 0} OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 8300000, guid: 9567c15965a4246e0bd2f434e2d6fac6, type: 3} m_audioClip: {fileID: 8300000, guid: 9567c15965a4246e0bd2f434e2d6fac6, type: 3}
m_PlayOnAwake: 1 m_PlayOnAwake: 1
m_Volume: 1 m_Volume: 0.75
m_Pitch: 1 m_Pitch: 1
Loop: 1 Loop: 1
Mute: 0 Mute: 0

View File

@ -75,6 +75,7 @@ public class EnemyPatrol : MonoBehaviour {
IEnumerator Defeat() { IEnumerator Defeat() {
this.gameObject.GetComponent<BoxCollider2D>().enabled = false; this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
animator.Play("Explosion"); animator.Play("Explosion");
this.gameObject.GetComponent<AudioSource>().Play();
yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length); yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
this.gameObject.GetComponent<BoxCollider2D>().enabled = true; this.gameObject.GetComponent<BoxCollider2D>().enabled = true;
this.gameObject.SetActive(false); this.gameObject.SetActive(false);

View File

@ -16,6 +16,7 @@ public class PlayerBehavior : MonoBehaviour
[SerializeField] private Launch launcher; [SerializeField] private Launch launcher;
[HideInInspector] public bool hasTambourine = true; [HideInInspector] public bool hasTambourine = true;
GameObject tambourine; GameObject tambourine;
bool unlockedTambourine;
[Header("Grappling:")] [Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun; [SerializeField] public Tutorial_GrapplingGun grapplingGun;
@ -41,6 +42,7 @@ public class PlayerBehavior : MonoBehaviour
void Update() void Update()
{ {
unlockedTambourine = stateController.unlockedTambourine;
if (playerIsAlive) { if (playerIsAlive) {
// throw tambourine // throw tambourine
// if (Input.GetKeyDown(KeyCode.K)) { // if (Input.GetKeyDown(KeyCode.K)) {
@ -110,7 +112,7 @@ public class PlayerBehavior : MonoBehaviour
} }
void ThrowTambourine() { void ThrowTambourine() {
if (hasTambourine && !grapplingRope.isGrappling) if (unlockedTambourine && hasTambourine && !grapplingRope.isGrappling)
{ {
launcher.ThrowTambourine(forward); launcher.ThrowTambourine(forward);
hasTambourine = false; hasTambourine = false;
@ -155,6 +157,7 @@ public class PlayerBehavior : MonoBehaviour
} }
else if (col.tag == "instaDeath") else if (col.tag == "instaDeath")
{ {
print("player fell in spikes");
StartCoroutine(DestroyPlayer()); StartCoroutine(DestroyPlayer());
} }
else if (col.tag == "spawnPoint") { else if (col.tag == "spawnPoint") {
@ -188,6 +191,7 @@ public class PlayerBehavior : MonoBehaviour
collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy(); collision.gameObject.GetComponent<EnemyPatrol>().DefeatEnemy();
} else { } else {
StartCoroutine(DestroyPlayer()); StartCoroutine(DestroyPlayer());
print("enemy defeated player");
} }
} }
else if (collision.gameObject.tag == "Projectile") { else if (collision.gameObject.tag == "Projectile") {
@ -197,18 +201,27 @@ public class PlayerBehavior : MonoBehaviour
} }
IEnumerator DestroyPlayer() { IEnumerator DestroyPlayer() {
playerIsAlive = false; if (playerIsAlive) {
print("destroyPlayer called");
playerIsAlive = false;
AudioSource audio = this.gameObject.GetComponent<AudioSource>();
audio.Play();
// animate // animate
animator.Play("Die"); animator.Play("Die");
yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length); // yield return new WaitForSeconds(animator.GetCurrentAnimatorStateInfo(0).length);
yield return new WaitForSeconds(audio.clip.length);
this.stateController.SetDeathCanvasActive(true); // this.stateController.SetDeathCanvasActive(true);
// destroy all tambourines // destroy all tambourines
GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine"); GameObject[] currentTambourines = GameObject.FindGameObjectsWithTag("tambourine");
foreach (GameObject tambourine in currentTambourines) { foreach (GameObject tambourine in currentTambourines) {
tambourine.GetComponent<TambourineBehavior>().DestroySelf(); // tambourine.GetComponent<TambourineBehavior>().DestroySelf();
Destroy(tambourine);
}
this.stateController.RespawnPlayer();
} }
} }
} }

View File

@ -47,6 +47,7 @@ public class PlayerMovement : MonoBehaviour
Tutorial_GrapplingRope grapplingRope; Tutorial_GrapplingRope grapplingRope;
bool wasGrappling = false; bool wasGrappling = false;
bool unlockedTrumpet;
//Set all of these up in the inspector //Set all of these up in the inspector
[Header("Checks")] [Header("Checks")]
@ -60,6 +61,7 @@ public class PlayerMovement : MonoBehaviour
[SerializeField] private LayerMask _groundLayer; [SerializeField] private LayerMask _groundLayer;
[HideInInspector] private PlayerBehavior playerBehavior; [HideInInspector] private PlayerBehavior playerBehavior;
[HideInInspector] private StateController stateController;
#endregion #endregion
private void Awake() private void Awake()
@ -67,7 +69,7 @@ public class PlayerMovement : MonoBehaviour
RB = GetComponent<Rigidbody2D>(); RB = GetComponent<Rigidbody2D>();
playerBehavior = this.gameObject.GetComponent<PlayerBehavior>(); playerBehavior = this.gameObject.GetComponent<PlayerBehavior>();
grapplingRope = playerBehavior.grapplingRope; grapplingRope = playerBehavior.grapplingRope;
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
} }
private void Start() private void Start()
@ -94,6 +96,7 @@ public class PlayerMovement : MonoBehaviour
private void Update() private void Update()
{ {
unlockedTrumpet = stateController.unlockedTrumpet;
#region TIMERS #region TIMERS
LastOnGroundTime -= Time.deltaTime; LastOnGroundTime -= Time.deltaTime;
LastOnWallTime -= Time.deltaTime; LastOnWallTime -= Time.deltaTime;
@ -125,7 +128,11 @@ public class PlayerMovement : MonoBehaviour
if (IsGrounded()) //checks if set box overlaps with ground if (IsGrounded()) //checks if set box overlaps with ground
{ {
LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
trumpet = 2; if (unlockedTrumpet) {
trumpet = 2;
} else {
trumpet = 0;
}
wasGrappling = false; wasGrappling = false;
} }

View File

@ -22,9 +22,14 @@ public class StateController : MonoBehaviour {
[Header("Enemies")] [Header("Enemies")]
GameObject[] enemiesInScene; GameObject[] enemiesInScene;
[Header("LevelProgression")] [Header("Level Progression")]
GameObject victoryCanvas; GameObject victoryCanvas;
[Header("Unlocked Items")]
[SerializeField] public bool unlockedTrumpet = false;
[SerializeField] public bool unlockedTambourine = false;
[SerializeField] public bool unlockedClarinet = false;
void Awake() { void Awake() {
// check to see if a state controller already exists // check to see if a state controller already exists
if (GameObject.FindGameObjectWithTag("StateController") != null) { if (GameObject.FindGameObjectWithTag("StateController") != null) {
@ -42,6 +47,8 @@ public class StateController : MonoBehaviour {
} }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
#region FIND OBJECTS
deathCanvas = GameObject.Find("DeathUICanvas"); deathCanvas = GameObject.Find("DeathUICanvas");
if (deathCanvas != null) { if (deathCanvas != null) {
Button respawnButton = GameObject.Find("RespawnButton").GetComponent<Button>(); Button respawnButton = GameObject.Find("RespawnButton").GetComponent<Button>();
@ -73,6 +80,25 @@ public class StateController : MonoBehaviour {
if (isPaused) { if (isPaused) {
Unpause(); Unpause();
} }
#endregion
#region UNLOCK ITEMS
if (SceneManager.GetActiveScene().name == "GrenouilleVillage") {
unlockedTrumpet = false;
unlockedTambourine = false;
unlockedClarinet = false;
}
else if (SceneManager.GetActiveScene().name == "GrappleScene") {
unlockedTrumpet = true;
unlockedTambourine = true;
unlockedClarinet = false;
}
else if (SceneManager.GetActiveScene().name == "ClarinetScene") {
unlockedTrumpet = true;
unlockedTambourine = true;
unlockedClarinet = true;
}
#endregion
} }
void OnToggleDebugMenu() { void OnToggleDebugMenu() {