private void OnTriggerEnter2D(Collider2D collision) { TimeFactors tf = collision.GetComponent <TimeFactors>(); if (tf != null) { int index = tf.Add(timeFactor); indices.Add(tf, index); } }
public void SetTimeFactor(float timeFactor) { this.timeFactor = timeFactor; // Update all of the time factors for objects already within the trigger. foreach (KeyValuePair <TimeFactors, int> pair in indices) { TimeFactors tf = pair.Key; int index = pair.Value; tf.Set(index, timeFactor); } }
private void OnTriggerExit2D(Collider2D collision) { TimeFactors tf = collision.GetComponent <TimeFactors>(); if (tf != null) { int index; if (indices.TryGetValue(tf, out index)) { tf.Remove(index); indices.Remove(tf); } } }