|
Post by Jasom on Feb 6, 2015 9:52:46 GMT
Hi Quick Question. This is working fine but I want to have the two different pools have differing points value and sound effects.
One is Coin 25pts the other crystal 50 pts. Any pointers welcomed.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
[AddComponentMenu("Dark Tonic/Core GameKit/Listeners/Triggered Despawner Listener")]
public class TriggeredDespawnerListener : MonoBehaviour {
public string sourceDespawnerName;
public AudioClip gotCoin;
private AudioSource source;
void Awake(){
source = GetComponent<AudioSource> ();
}
void Reset() {
var src = this.GetComponent<TriggeredDespawner>();
if (src != null) {
src.listener = this;
this.sourceDespawnerName = this.name;
}
}
public virtual void Despawning(TriggeredSpawner.EventType eType, Transform transDespawning) {
source = GetComponent<AudioSource> ();
source.PlayOneShot (gotCoin, 1F);
coinScore.myCoinScore += 25;
}
}
}
|
|
|
Post by DarkTonic Dev on Feb 6, 2015 23:36:50 GMT
Add a public int variable that defaults to 25 for the score part, just like you did for the Audio Clip.
Then you just assign different values for the clip and score for each Listener. You could do as many variations as you like. I'd put this script directly onto the prefab of the game object it's listening to.
|
|