Commit 9eaf4bfd authored by Abdulrahman Mohammed's avatar Abdulrahman Mohammed

Add effect when player only triggers obstacle

parent 738b438a
...@@ -199,7 +199,7 @@ MonoBehaviour: ...@@ -199,7 +199,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 90d407e88a00e3747a2a730f56ab8436, type: 3} m_Script: {fileID: 11500000, guid: 90d407e88a00e3747a2a730f56ab8436, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
randomQuestionEveryRound: 0 randomQuestionEveryRound: 1
areaLength: 30 areaLength: 30
QuestionParent: {fileID: 1448207616} QuestionParent: {fileID: 1448207616}
questionAreaPrefab: {fileID: 4538400059142529437, guid: 3db7dbd8c06879542881cceaa4d90f40, questionAreaPrefab: {fileID: 4538400059142529437, guid: 3db7dbd8c06879542881cceaa4d90f40,
......
...@@ -17,8 +17,8 @@ public class NPCsEffects : MonoBehaviour ...@@ -17,8 +17,8 @@ public class NPCsEffects : MonoBehaviour
} }
private void OnDisable() private void OnDisable()
{ {
if (EffectsManager._playersAndNPCsMeshRenderer.Contains(GetComponentInChildren<MeshRenderer>())) if (EffectsManager.Instance._playersAndNPCsMeshRenderer.Contains(GetComponentInChildren<MeshRenderer>()))
EffectsManager._playersAndNPCsMeshRenderer.Remove(GetComponentInChildren<MeshRenderer>()); EffectsManager.Instance._playersAndNPCsMeshRenderer.Remove(GetComponentInChildren<MeshRenderer>());
if (OnDisableEffect != null) if (OnDisableEffect != null)
{ {
OnDisableEffect.transform.position = transform.position + transform.forward; OnDisableEffect.transform.position = transform.position + transform.forward;
...@@ -32,8 +32,8 @@ public class NPCsEffects : MonoBehaviour ...@@ -32,8 +32,8 @@ public class NPCsEffects : MonoBehaviour
} }
private void OnEnable() private void OnEnable()
{ {
if(!EffectsManager._playersAndNPCsMeshRenderer.Contains(GetComponentInChildren<MeshRenderer>())) if(!EffectsManager.Instance._playersAndNPCsMeshRenderer.Contains(GetComponentInChildren<MeshRenderer>()))
EffectsManager._playersAndNPCsMeshRenderer.Add(GetComponentInChildren<MeshRenderer>()); EffectsManager.Instance._playersAndNPCsMeshRenderer.Add(GetComponentInChildren<MeshRenderer>());
if (OnEnableEffect != null) if (OnEnableEffect != null)
{ {
......
...@@ -10,5 +10,9 @@ public class Obstacles : MonoBehaviour ...@@ -10,5 +10,9 @@ public class Obstacles : MonoBehaviour
other.gameObject.SetActive(false); other.gameObject.SetActive(false);
SpwanManager.Instance.ChangeCurrentNPCsInGame(); SpwanManager.Instance.ChangeCurrentNPCsInGame();
} }
if (other.CompareTag("Player"))
{
EffectsManager.Instance.PlayVFX(false);
}
} }
} }
...@@ -55,15 +55,16 @@ public class SpawnQuestion : MonoBehaviour ...@@ -55,15 +55,16 @@ public class SpawnQuestion : MonoBehaviour
} }
Instantiate(enemyAreaPrefab, new Vector3(0, 0, currentLenght), Quaternion.identity, QuestionParent); Instantiate(enemyAreaPrefab, new Vector3(0, 0, currentLenght), Quaternion.identity, QuestionParent);
} }
void ShuffleArray(Question[] array) // Fisher-Yates Shuffle Algorithm
private void ShuffleArray(Question[] array)
{ {
for (int i = array.Length - 1; i > 0; i--) for (int i = questionScriptableObjects.Length - 1; i > 1; i--)
{ {
int randomIndex = Random.Range(1, i + 1); int randomIndex = Random.Range(1, i + 1);
Question temp = array[i]; Question tmp = array[i];
array[i] = array[randomIndex]; array[i] = array[randomIndex];
array[randomIndex] = temp; array[randomIndex] = tmp;
} }
} }
private void DestroyChild() private void DestroyChild()
......
...@@ -5,6 +5,8 @@ using UnityEngine; ...@@ -5,6 +5,8 @@ using UnityEngine;
public class EffectsManager : MonoBehaviour public class EffectsManager : MonoBehaviour
{ {
public static EffectsManager Instance;
[SerializeField] Transform player; [SerializeField] Transform player;
[SerializeField] ParticleSystem correctAnswerVFX; [SerializeField] ParticleSystem correctAnswerVFX;
[SerializeField] ParticleSystem incorrectAnswerVFX; [SerializeField] ParticleSystem incorrectAnswerVFX;
...@@ -19,7 +21,16 @@ public class EffectsManager : MonoBehaviour ...@@ -19,7 +21,16 @@ public class EffectsManager : MonoBehaviour
AudioSource _audioSource; AudioSource _audioSource;
Camera _cam; Camera _cam;
public static List<MeshRenderer> _playersAndNPCsMeshRenderer = new List<MeshRenderer>();
private void Awake()
{
if(Instance == null)
Instance = this;
else
Destroy(this);
}
public List<MeshRenderer> _playersAndNPCsMeshRenderer = new List<MeshRenderer>();
private void Start() private void Start()
{ {
_playersAndNPCsMeshRenderer.Add(player.GetComponentInChildren<MeshRenderer>()); _playersAndNPCsMeshRenderer.Add(player.GetComponentInChildren<MeshRenderer>());
...@@ -41,7 +52,7 @@ public class EffectsManager : MonoBehaviour ...@@ -41,7 +52,7 @@ public class EffectsManager : MonoBehaviour
QuestionArea.OnPlayerTriggerTheQuestion -= PlaySFX; QuestionArea.OnPlayerTriggerTheQuestion -= PlaySFX;
} }
private void PlayVFX(bool status) public void PlayVFX(bool status)
{ {
DOTween.To(() => curvedDefaultBendHorizontalSize,x => { curvedDefaultBendHorizontalSize = x; curved.SetBendHorizontalSize(x); },-curvedDefaultBendHorizontalSize, DOTween.To(() => curvedDefaultBendHorizontalSize,x => { curvedDefaultBendHorizontalSize = x; curved.SetBendHorizontalSize(x); },-curvedDefaultBendHorizontalSize,
durationCurved durationCurved
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment