public void ApplyStim(GameObject other, Stimulant stim) { StimResponseObject SRObj = other.gameObject.GetComponent <StimResponseObject>(); if (SRObj != null) // Does the other gameobject potentially possess stims? { if (GlobalStims.ContainsKey(stim)) { GlobalStims[stim](); } } }
public IEnumerator addStimDelayed(float delayInSecs, Stimulant stim) { yield return(new WaitForSeconds(delayInSecs)); Stims.Add(stim); // Apply the delayed Stim to our touching adjacent GameObjects StimResponseObject srObj; foreach (GameObject gObj in gameObjectsTouching) { srObj = gObj.GetComponent <StimResponseObject>(); if (srObj != null) { srObj.ApplyStim(this.gameObject, stim); } } }