/* * Removes the input effector, returns whether it was removed. If it returns false it * means that the input effector was not in the players list */ public bool RemoveEffector(PlayerEffector effector) { bool removed = effectors.Remove(effector); if (removed) { effector.OnRemoved(this); } return(removed); }
/* * Adds the input effector type, with the input lifetime. if timelimit is 0.0f, the effector will * not be removed automatically, so it must remove itself. * * returns true only if the effector was actually added to the list. */ public bool AddEffector(PlayerEffector effector, float timelimit) { // cehck that the effector is not already added foreach (PlayerEffector currentEffector in effectors) { if (currentEffector.GetType() == effector.GetType()) { return(false); } } effector.lifeTime = timelimit; effectors.Add(effector); effector.OnApplied(this); return(true); }
public void OnCollision(GameObject other) { PlayerEffector effector = other != null?other.GetComponent <PlayerEffector>() : null; EffectorApplier applyer = other != null?other.GetComponent <EffectorApplier>() : null; if (effector == null && applyer == null && !destroyOnOthers) { return; } if (effector != null) { effector.SetEffector(Instantiate(this.effector) as Effector); } if (applyer != null) { applyer.destroy(); } destroy(); }
/* * Removes the input effector, returns whether it was removed. If it returns false it * means that the input effector was not in the players list */ public bool RemoveEffector(PlayerEffector effector) { bool removed = effectors.Remove(effector); if(removed) { effector.OnRemoved(this); } return removed; }
/* * Adds the input effector type, with the input lifetime. if timelimit is 0.0f, the effector will * not be removed automatically, so it must remove itself. * * returns true only if the effector was actually added to the list. */ public bool AddEffector(PlayerEffector effector, float timelimit) { // cehck that the effector is not already added foreach(PlayerEffector currentEffector in effectors) { if(currentEffector.GetType() == effector.GetType()) { return false; } } effector.lifeTime = timelimit; effectors.Add(effector); effector.OnApplied(this); return true; }