Настраивается звук голосов.

This commit is contained in:
DyatelO 2021-11-29 18:32:30 +03:00
parent 06a6427cbb
commit 5e0988f085
6 changed files with 178 additions and 44 deletions

View File

@ -520,6 +520,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6204da1a1285ccf469ff66d606c6b9bf, type: 3}
m_Name:
m_EditorClassIdentifier:
_healthHit: {fileID: 8834890311105204200}
--- !u!1001 &8834890310216622063
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -114,7 +114,6 @@ GameObject:
- component: {fileID: 1406732623307280272}
- component: {fileID: 8834890311105204203}
- component: {fileID: 8834890311105204223}
- component: {fileID: -1011735873211555839}
- component: {fileID: 8834890311105204220}
- component: {fileID: 8834890311105204219}
- component: {fileID: 8884806831970511687}
@ -343,35 +342,6 @@ MonoBehaviour:
_currentEnemy: {fileID: 0}
_currentTargetTile: {fileID: 0}
_currentFollowingPath: []
--- !u!114 &-1011735873211555839
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8834890311105204202}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a99dc0f9656d2241b5ada4edc0765ee, type: 3}
m_Name:
m_EditorClassIdentifier:
state: {fileID: 8834890311105204208}
hit_LightingAudio: {fileID: 8300000, guid: 6c42231c18643dc4d9d8f8d15bc4735b, type: 3}
hit_LaserAudio: {fileID: 8300000, guid: 75cd25f85e881bc458b1dd2f2bd8d84a, type: 3}
hit_TowerFireballAudio: {fileID: 8300000, guid: ab5fd4a38b69eb84f8ca0b8919cedd9c,
type: 3}
hit_SFX:
- {fileID: 8300000, guid: 6c42231c18643dc4d9d8f8d15bc4735b, type: 3}
- {fileID: 8300000, guid: 75cd25f85e881bc458b1dd2f2bd8d84a, type: 3}
- {fileID: 8300000, guid: ab5fd4a38b69eb84f8ca0b8919cedd9c, type: 3}
throw_SFX:
- {fileID: 8300000, guid: 9ea918c6c23577f4e885a8490d2f2046, type: 3}
- {fileID: 8300000, guid: 4af8bb0096e5d15489b02be84b6ce2a4, type: 3}
- {fileID: 8300000, guid: dbba45d74994bff4e8b406722fc8f468, type: 3}
bonusSound: {fileID: 8300000, guid: e9d3f46b0b5ba9f4cada050219138aac, type: 3}
_startGame: {fileID: 0}
_controller: {fileID: 8834890311105204220}
aSourse: {fileID: 0}
--- !u!114 &8834890311105204220
MonoBehaviour:
m_ObjectHideFlags: 0
@ -519,6 +489,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6204da1a1285ccf469ff66d606c6b9bf, type: 3}
m_Name:
m_EditorClassIdentifier:
_healthHit: {fileID: 0}
--- !u!1001 &415671957117863138
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -4639,7 +4639,17 @@ MonoBehaviour:
volume: 0.75
pitch: 1
source: {fileID: 0}
phrases: []
phrases:
- nmae: WellDone
clip: {fileID: 8300000, guid: 2a383482135175741bfbff39772edaee, type: 3}
volume: 1
pitch: 1
source: {fileID: 0}
- nmae: Unstoppable
clip: {fileID: 8300000, guid: 4fdd725a2355b3448b7e2b98e4527532, type: 3}
volume: 1
pitch: 1
source: {fileID: 0}
--- !u!4 &1743009246
Transform:
m_ObjectHideFlags: 0
@ -5150,6 +5160,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6204da1a1285ccf469ff66d606c6b9bf, type: 3}
m_Name:
m_EditorClassIdentifier:
_healthHit: {fileID: 1801060027}
--- !u!1001 &1850245407
PrefabInstance:
m_ObjectHideFlags: 0
@ -55657,16 +55668,106 @@ PrefabInstance:
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1801060021}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3195387929267588557, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5557455103468811314, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: bonusController
value:
objectReference: {fileID: 1801060033}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5643681896748709694, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5861359707769992997, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: playerHealth
value:
objectReference: {fileID: 1801060027}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6305254850507510473, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7117637457801964014, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: health
@ -55812,6 +55913,36 @@ PrefabInstance:
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 185995048}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8859217424454144084, guid: a72be70db1163c14b8b7a3cb1c00a59d,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a72be70db1163c14b8b7a3cb1c00a59d, type: 3}
--- !u!1 &7121823489171206717

View File

@ -7,7 +7,7 @@ using UnityEngine.Audio;
public class AudioSwitcher : MonoBehaviour
{
public Sounds[] sounds;
public Phrases[] phrases;
public Sounds[] phrases;
private void Awake() {
foreach(Sounds s in sounds)
@ -19,7 +19,7 @@ public class AudioSwitcher : MonoBehaviour
s.source.pitch = s.pitch;
}
foreach(Phrases p in phrases)
foreach(Sounds p in phrases)
{
p.source = gameObject.AddComponent<AudioSource>();
p.source.clip = p.clip;
@ -36,9 +36,9 @@ public class AudioSwitcher : MonoBehaviour
return;
s.source.Play();
}
public void PlayPhrase(string index)
public void PlayPhrase(string name)
{
Phrases s = Array.Find(phrases, sound => sound.nmae == index);
Sounds s = Array.Find(phrases, sound => sound.nmae == name);
if(s == null)
return;
s.source.Play();

View File

@ -1,25 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using System;
using UnityEngine.Audio;
public class SaySomething : MonoBehaviour
{
[SerializeField] private List<HealthController> playerHealths;
//[SerializeField] private List<HealthController> playerHealths;
[SerializeField] private List<Sounds> prases;
[SerializeField] private HealthController health;
void Start()
{
playerHealths = new List<HealthController>( FindObjectsOfType<HealthController>());
//playerHealths.AddRange( );
foreach(HealthController hc in playerHealths)
health = FindObjectOfType<HealthController>();
foreach(Sounds p in prases)
{
if(hc.currentHealth <= 0)
{
FindObjectOfType<AudioSwitcher>().PlayPhrase(Random.Range(0, 15).ToString());
}
p.source = gameObject.AddComponent<AudioSource>();
p.source.clip = p.clip;
p.source.volume = p.volume;
p.source.pitch = p.pitch;
}
// playerHealths = new List<HealthController>( FindObjectsOfType<HealthController>());
// //playerHealths.AddRange( );
// foreach(HealthController hc in playerHealths)
// {
// if(hc.currentHealth <= 0)
// {
// //FindObjectOfType<AudioSwitcher>().PlayPhrase(Random.Range(0, 15));
// }
// }
}
// Update is called once per frame
private void Update() {
if(health.currentHealth <= 0)
{
Say();
}
}
public void Say()
{
if()
}
}

View File

@ -7,6 +7,8 @@ public class PlayerTrigger : MonoBehaviour
//[SerializeField] private HealthController _healthHit;
//[SerializeField] private AudioSwitcher
private void OnTriggerEnter(Collider other) {
if(other.gameObject.GetComponent<ProjectileController>().damage == 1000)
{