/// <summary> /// Method called when the BuffPickup is picked up. /// </summary> /// <param name="other">The Player GameObject collision information.</param> public override sealed void OnPickup(Collider2D other) { //Debug.Log("Pickup Event on Buffpickup"); if (_activeBuff != null) //if a buff is already active { //Debug.Log("On pickup, buff was already active"); _activeBuff._cancelBuffInternal(); //get that buff object, and cancel any invokation it's scheduled } _activeBuff = this; //assign active buff to be the current buffPickup that's just been collected OnApply(); //do whatever actions that specific buff needs you to do, defined by the specific buffs Invoke("_disableBuffInternal", buffDuration); //set the disableBuffInternal function to be called in Buff Duration seconds }
public void setBuff(BuffPickup buff, float duration) { if (buff.gameObject.GetComponent <FocusBuff> () != null) //if buff of component type focusBuff, then set image to be blue one //buffImage = buff.GetComponent<SpriteRenderer> ().sprite; { buffImage.GetComponent <Image>().overrideSprite = buffImages[0]; buffImage.color = new Color(1f, 1f, 1f, 1f); } else if (buff.gameObject.GetComponent <PointBuff> () != null) { buffImage.GetComponent <Image>().overrideSprite = buffImages[1]; buffImage.color = new Color(1f, 1f, 1f, 1f); } else { Debug.Log("Wasnt the right buff bro"); } buffDurationText.color = new Color(1f, 1f, 1f, 1f); buffDurationCounter = duration; //else if it is a points buff, set it to be the green one //else debug log //set buffduration as duration }
/// <summary> /// Internal method for managing buff disabling and reset of timer. /// </summary> internal void _disableBuffInternal() //THIS ONLY GETS CALLED WHEN A BUFF COMES TO ITS NATURAL END (NOT PREMATURELY CANCELLED) { _activeBuff = null; OnExpire(); }