Monster Approach and react audio
This commit is contained in:
@@ -135,4 +135,11 @@ AnimationClip:
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: PlayAudio
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
|
||||
@@ -138,4 +138,11 @@ AnimationClip:
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: PlayAudio
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 3
|
||||
messageOptions: 0
|
||||
|
||||
@@ -192,4 +192,11 @@ AnimationClip:
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: PlayAudio
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 1
|
||||
messageOptions: 0
|
||||
|
||||
@@ -102,4 +102,11 @@ AnimationClip:
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
||||
m_Events:
|
||||
- time: 0
|
||||
functionName: PlayAudio
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 2
|
||||
messageOptions: 0
|
||||
|
||||
@@ -14,6 +14,7 @@ GameObject:
|
||||
- component: {fileID: 3714732064953161914}
|
||||
- component: {fileID: 8725474797166928194}
|
||||
- component: {fileID: 5319963476921229849}
|
||||
- component: {fileID: 7651201180287724754}
|
||||
m_Layer: 12
|
||||
m_Name: QuarryMonster
|
||||
m_TagString: Untagged
|
||||
@@ -150,6 +151,15 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
detectionCollider: {fileID: 4998672042618199381}
|
||||
monsterClips:
|
||||
- {fileID: 8300000, guid: 30abed376d8a6914191b1bf3fcf60ad4, type: 3}
|
||||
- {fileID: 8300000, guid: d8af9afe04d49fe45aa8b92d26a8bb9e, type: 3}
|
||||
- {fileID: 8300000, guid: 89374607d2d3fbd40bed58cb4a1f4089, type: 3}
|
||||
- {fileID: 8300000, guid: 6ff3fbda41c71d941aec69b7056b8341, type: 3}
|
||||
- {fileID: 8300000, guid: 3d0c4641496e430449ec0538f89cac29, type: 3}
|
||||
- {fileID: 8300000, guid: 1bfc562c713739c408d220a9de9a5240, type: 3}
|
||||
playerAudioSource: {fileID: 0}
|
||||
monsterSpottedAudio: {fileID: 6418180475301049370, guid: 552945b348ea52749a29b5e327b8eab1, type: 2}
|
||||
--- !u!222 &8725474797166928194
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -180,6 +190,130 @@ Animator:
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorStateOnDisable: 0
|
||||
m_WriteDefaultValuesOnDisable: 0
|
||||
--- !u!82 &7651201180287724754
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2015720985618639356}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 3533147658878909314, guid: 727a7e4b6df4b0d47897f7d8ee7fa323, type: 2}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_Resource: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 15
|
||||
Pan2D: 0
|
||||
rolloffMode: 2
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0.06496913
|
||||
value: 1
|
||||
inSlope: -15.005997
|
||||
outSlope: -15.005997
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 0.13333334
|
||||
value: 0.5748291
|
||||
inSlope: -3.7514992
|
||||
outSlope: -3.7514992
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 0.26666668
|
||||
value: 0.3248291
|
||||
inSlope: -0.9378748
|
||||
outSlope: -0.9378748
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 0.70310265
|
||||
value: 0.06512451
|
||||
inSlope: -0.2344687
|
||||
outSlope: -0.2344687
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0.06669331
|
||||
outSlope: -0.06669331
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
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 &2867277187014497771
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -342,17 +342,17 @@ LineRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Positions:
|
||||
- {x: -0.15602553, y: 4.0749445, z: 0}
|
||||
- {x: -0.1566351, y: 3.9736378, z: 0}
|
||||
- {x: -0.1572447, y: 3.8729858, z: 0}
|
||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||
- {x: -0.1566351, y: 3.973638, z: 0}
|
||||
- {x: -0.1572447, y: 3.8729856, z: 0}
|
||||
- {x: -0.15785426, y: 3.7729874, z: 0}
|
||||
- {x: -0.15846384, y: 3.6736438, z: 0}
|
||||
- {x: -0.15907341, y: 3.5749543, z: 0}
|
||||
- {x: -0.15968299, y: 3.4769194, z: 0}
|
||||
- {x: -0.15846384, y: 3.6736436, z: 0}
|
||||
- {x: -0.15907341, y: 3.574954, z: 0}
|
||||
- {x: -0.15968299, y: 3.4769192, z: 0}
|
||||
- {x: -0.16029257, y: 3.3795385, z: 0}
|
||||
- {x: -0.16090216, y: 3.2828126, z: 0}
|
||||
- {x: -0.16151173, y: 3.1867406, z: 0}
|
||||
- {x: -0.16212131, y: 3.0913231, z: 0}
|
||||
- {x: -0.16151173, y: 3.1867409, z: 0}
|
||||
- {x: -0.16212131, y: 3.0913236, z: 0}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
@@ -1047,7 +1047,7 @@ Transform:
|
||||
m_GameObject: {fileID: 747976396}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 3.1975174, z: 0}
|
||||
m_LocalPosition: {x: 0, y: 3.197517, z: 0}
|
||||
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
@@ -1598,17 +1598,17 @@ LineRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Positions:
|
||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||
- {x: -0.11662118, y: 3.8796225, z: 0}
|
||||
- {x: -0.15602553, y: 4.0749445, z: 0}
|
||||
- {x: -0.11662118, y: 3.879622, z: 0}
|
||||
- {x: -0.07721684, y: 3.7057445, z: 0}
|
||||
- {x: -0.03781248, y: 3.5533106, z: 0}
|
||||
- {x: 0.0015918687, y: 3.4223216, z: 0}
|
||||
- {x: 0.040996216, y: 3.3127766, z: 0}
|
||||
- {x: 0.08040057, y: 3.2246757, z: 0}
|
||||
- {x: 0.11980491, y: 3.1580195, z: 0}
|
||||
- {x: 0.15920927, y: 3.1128078, z: 0}
|
||||
- {x: 0.1986136, y: 3.0890403, z: 0}
|
||||
- {x: 0.23801796, y: 3.0867171, z: 0}
|
||||
- {x: 0.08040057, y: 3.2246761, z: 0}
|
||||
- {x: 0.11980491, y: 3.15802, z: 0}
|
||||
- {x: 0.15920927, y: 3.1128082, z: 0}
|
||||
- {x: 0.1986136, y: 3.0890405, z: 0}
|
||||
- {x: 0.23801796, y: 3.0867176, z: 0}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
@@ -2447,17 +2447,17 @@ LineRenderer:
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Positions:
|
||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||
- {x: -0.18956745, y: 3.8764977, z: 0}
|
||||
- {x: -0.15602553, y: 4.0749445, z: 0}
|
||||
- {x: -0.18956745, y: 3.8764973, z: 0}
|
||||
- {x: -0.22310936, y: 3.7000232, z: 0}
|
||||
- {x: -0.25665125, y: 3.5455205, z: 0}
|
||||
- {x: -0.29019317, y: 3.4129908, z: 0}
|
||||
- {x: -0.32373506, y: 3.3024333, z: 0}
|
||||
- {x: -0.35727698, y: 3.213848, z: 0}
|
||||
- {x: -0.39081886, y: 3.1472356, z: 0}
|
||||
- {x: -0.4243608, y: 3.1025953, z: 0}
|
||||
- {x: -0.45790267, y: 3.0799277, z: 0}
|
||||
- {x: -0.4914446, y: 3.0792325, z: 0}
|
||||
- {x: -0.25665125, y: 3.5455203, z: 0}
|
||||
- {x: -0.29019317, y: 3.412991, z: 0}
|
||||
- {x: -0.32373506, y: 3.3024335, z: 0}
|
||||
- {x: -0.35727698, y: 3.2138484, z: 0}
|
||||
- {x: -0.39081886, y: 3.1472359, z: 0}
|
||||
- {x: -0.4243608, y: 3.1025958, z: 0}
|
||||
- {x: -0.45790267, y: 3.0799282, z: 0}
|
||||
- {x: -0.4914446, y: 3.079233, z: 0}
|
||||
m_Parameters:
|
||||
serializedVersion: 3
|
||||
widthMultiplier: 1
|
||||
@@ -3230,7 +3230,7 @@ Transform:
|
||||
m_GameObject: {fileID: 2106431001}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.165, y: 2.697517, z: 0}
|
||||
m_LocalPosition: {x: -0.165, y: 2.6975174, z: 0}
|
||||
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using UnityEngine;
|
||||
using AudioSourceEvents;
|
||||
using Core;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Core;
|
||||
using UnityEditor.Experimental.GraphView;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
namespace Minigames.DivingForPictures
|
||||
{
|
||||
@@ -28,6 +31,15 @@ namespace Minigames.DivingForPictures
|
||||
public bool IsPlayerInDetectionRange => playerInDetectionRange;
|
||||
public bool IsPictureTaken => pictureAlreadyTaken;
|
||||
|
||||
public enum MonsterSounds
|
||||
{Hello, RareBeast, Pooping,Smile,Whatsup1, Whatsup2}
|
||||
private AudioSource _audioSource;
|
||||
public AudioResource[] monsterClips;
|
||||
private AudioSource playerAudioSource;
|
||||
public AudioResource monsterSpottedAudio;
|
||||
private IAudioEventSource _eventSource;
|
||||
private GameObject playerObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Logging.Debug("Monster created: " + gameObject.name);
|
||||
@@ -36,13 +48,28 @@ namespace Minigames.DivingForPictures
|
||||
detectionCollider = GetComponent<CircleCollider2D>();
|
||||
|
||||
mainCamera = UnityEngine.Camera.main;
|
||||
_audioSource = GetComponent<AudioSource>();
|
||||
|
||||
|
||||
playerObject = GameObject.FindGameObjectsWithTag("Player")[0];
|
||||
playerAudioSource = playerObject.GetComponent<AudioSource>();
|
||||
_eventSource = playerAudioSource.RequestEventHandlers();
|
||||
_eventSource.AudioStopped += playerAudioDone;
|
||||
|
||||
|
||||
// Start checking if monster is off-screen
|
||||
StartCoroutine(CheckIfOffScreen());
|
||||
}
|
||||
|
||||
private void playerAudioDone(object sender, EventArgs e)
|
||||
{
|
||||
_audioSource.Play();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
playerAudioSource.resource = monsterSpottedAudio;
|
||||
playerAudioSource.Play();
|
||||
pictureAlreadyTaken = false;
|
||||
photoSequenceInProgress = false;
|
||||
}
|
||||
@@ -50,6 +77,7 @@ namespace Minigames.DivingForPictures
|
||||
private void OnDestroy()
|
||||
{
|
||||
Logging.Debug("Monster destroyed: " + gameObject.name);
|
||||
_eventSource.AudioStopped -= playerAudioDone;
|
||||
}
|
||||
|
||||
private IEnumerator CheckIfOffScreen()
|
||||
@@ -180,6 +208,37 @@ namespace Minigames.DivingForPictures
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayAudio(MonsterSounds soundToPlay)
|
||||
{
|
||||
switch (soundToPlay)
|
||||
{
|
||||
case MonsterSounds.Hello:
|
||||
_audioSource.resource = monsterClips[0];
|
||||
|
||||
break;
|
||||
case MonsterSounds.RareBeast:
|
||||
_audioSource.resource = monsterClips[1];
|
||||
|
||||
break;
|
||||
case MonsterSounds.Pooping:
|
||||
|
||||
break;
|
||||
case MonsterSounds.Smile:
|
||||
_audioSource.resource = monsterClips[3];
|
||||
|
||||
break;
|
||||
case MonsterSounds.Whatsup1:
|
||||
_audioSource.resource = monsterClips[4];
|
||||
|
||||
break;
|
||||
case MonsterSounds.Whatsup2:
|
||||
_audioSource.resource = monsterClips[5];
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
// Update collider radius in editor
|
||||
|
||||
60
Assets/Sound/Quarry/Voices/AnneLise/MonsterSpotted.asset
Normal file
60
Assets/Sound/Quarry/Voices/AnneLise/MonsterSpotted.asset
Normal file
@@ -0,0 +1,60 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1233149941 &-6718603706224789100
|
||||
AudioContainerElement:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: monsterSpot1_{-6718603706224789100}
|
||||
m_AudioClip: {fileID: 8300000, guid: dce2d4ee0600c3c40bc462bae54e8f7e, type: 3}
|
||||
m_Volume: 0
|
||||
m_Enabled: 1
|
||||
--- !u!1233149941 &4620811824381853308
|
||||
AudioContainerElement:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MonsterSpot2_{4620811824381853308}
|
||||
m_AudioClip: {fileID: 8300000, guid: 1f17a81387fc48b428dde813abbbb96b, type: 3}
|
||||
m_Volume: 0
|
||||
m_Enabled: 1
|
||||
--- !u!1307931743 &6418180475301049370
|
||||
AudioRandomContainer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MonsterSpotted
|
||||
m_Volume: 0
|
||||
m_Pitch: 0
|
||||
m_AutomaticTriggerTime: 0
|
||||
m_LoopCount: 1
|
||||
m_VolumeRandomizationRange: {x: 0, y: 0}
|
||||
m_PitchRandomizationRange: {x: 0, y: 0}
|
||||
m_AutomaticTriggerTimeRandomizationRange: {x: 0, y: 0}
|
||||
m_LoopCountRandomizationRange: {x: 0, y: 0}
|
||||
m_Elements:
|
||||
- {fileID: -6718603706224789100}
|
||||
- {fileID: 4620811824381853308}
|
||||
- {fileID: 9011493545975767723}
|
||||
m_AvoidRepeatingLast: 1
|
||||
m_PlaybackMode: 2
|
||||
m_TriggerMode: 0
|
||||
m_AutomaticTriggerMode: 1
|
||||
m_LoopMode: 2
|
||||
m_VolumeRandomizationEnabled: 0
|
||||
m_PitchRandomizationEnabled: 0
|
||||
m_AutomaticTriggerTimeRandomizationEnabled: 0
|
||||
m_LoopCountRandomizationEnabled: 0
|
||||
--- !u!1233149941 &9011493545975767723
|
||||
AudioContainerElement:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: monsterSpot3_{9011493545975767723}
|
||||
m_AudioClip: {fileID: 8300000, guid: 37903602bdde1384482c490db2b1bd42, type: 3}
|
||||
m_Volume: 0
|
||||
m_Enabled: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 552945b348ea52749a29b5e327b8eab1
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 6418180475301049370
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user