Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajout d'effets FX Sound sur les Targets OnDestroy #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added VRPRoject/Assets/370209__jugraf__fail-down.wav
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/370209__jugraf__fail-down.wav.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions VRPRoject/Assets/DestroyScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class DestroyScript : MonoBehaviour
{
[SerializeField]
private float timeToDestroy;

// Start is called before the first frame update
void Start()
{
Expand Down
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/399354__romariogrande__eastandw.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/Uro_Uro.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/Uro_Uro.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_1.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_1.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_2.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_2.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_3.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_3.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_4.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_4.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_5.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_5.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_6.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_6.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added VRPRoject/Assets/FX/target_7.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions VRPRoject/Assets/FX/target_7.mp3.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions VRPRoject/Assets/FXManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FXManager : MonoBehaviour
{

public AudioClip[] targetDestroyed;
public AudioSource audioSource;
public AudioClip failSound;

// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
}

public void PlayRandomTargetDestroyed()
{
audioSource.clip = targetDestroyed[Random.Range(0, targetDestroyed.Length)];
audioSource.Play();
}

public void PlayFailSound()
{
audioSource.clip = failSound;
audioSource.Play();
}
}
11 changes: 11 additions & 0 deletions VRPRoject/Assets/FXManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion VRPRoject/Assets/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ private void Awake()
public int scoreMultiplier = 1;

public float gameCounterIncrease;
public float gameCounterDecrease;

[SerializeField]
GameObject startTarget;

[SerializeField]
private float gameTime = 180f;
private float gameTime = 120f;

private float gameCounter;

Expand All @@ -41,6 +42,8 @@ private void Awake()

public int bestScore = 0;

public MusicManager music;


[Header("Playable Zone")]

Expand Down Expand Up @@ -77,6 +80,11 @@ private void Awake()

public static float MaxZPlayableZone => _instance.maxZPlayableZone;

[SerializeField]
private float throwingShurikenSpeed = 20f;

public static float ThrowingShurikenSpeed => _instance.throwingShurikenSpeed;

// Start is called before the first frame update
void Start()
{
Expand All @@ -88,6 +96,7 @@ void Start()

ResetScore();
gameCounter = gameTime;
music = GameObject.FindGameObjectWithTag("MusicGenerator").GetComponent<MusicManager>();

//GameObject.FindGameObjectWithTag("Spawner").SendMessage("StartInstantiating");
}
Expand All @@ -112,6 +121,11 @@ public void IncreaseTime()
this.gameCounter += gameCounterIncrease;
}

public void DecreaseTime()
{
this.gameCounter -= gameCounterDecrease;
}

public bool FillAndCompare(TargetColors color)
{

Expand Down Expand Up @@ -157,6 +171,8 @@ private void Update()
bestScore = score;
}
GameObject.FindGameObjectWithTag("InGameCanvas").SendMessage("SetScoreText", this.bestScore);
GameObject.FindGameObjectWithTag("MusicGenerator").GetComponent<MusicManager>().SendMessage("StopMusic");
GameObject.FindGameObjectWithTag("MusicGenerator").GetComponent<MusicManager>().SendMessage("PlayWaiting");
startTarget.SetActive(true);
gameStarted = false;
}
Expand Down
53 changes: 53 additions & 0 deletions VRPRoject/Assets/MusicManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MusicManager : MonoBehaviour
{
public AudioClip[] ambianceClip;
public AudioSource audioSource;

// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
PlayWaiting();
}

public void PlayAmbiance()
{
audioSource.clip = ambianceClip[0];
audioSource.Play();
}

public void StopMusic()
{
audioSource.Stop();
audioSource.clip = null;
}

public void PlayWaiting()
{
audioSource.clip = ambianceClip[1];
audioSource.Play();
}

public void FadeOut(float duration)
{
audioSource.GetComponent<MonoBehaviour>().StartCoroutine(FadeOutCore(audioSource, duration));
}

private IEnumerator FadeOutCore(AudioSource a, float duration)
{
float startVolume = a.volume;

while (a.volume > 0)
{
a.volume -= startVolume * Time.deltaTime / duration;
yield return new WaitForEndOfFrame();
}

a.Stop();
a.volume = startVolume;
}
}
Loading