public override void OnStartEvent(GameObject src, OnStartData data) { StatusComponent status = src.AddComponent <StatusComponent>() as StatusComponent; status.SetMaxHealth(data.m_StatusComponentData.m_Health); status.Heal(data.m_StatusComponentData.m_Health, GameplayStatics.DamageType.Null); status.m_CanUseIFrames = data.m_StatusComponentData.m_Health > 0; status.m_IFrameTime = data.m_StatusComponentData.m_IFrameTime; status.m_DamagePopupOverride = data.m_StatusComponentData.m_OverrideDmgType; status.AddOnDeath(() => Destroy(src)); }
public override void PickupItem(Collider2D target, GameObject src) { GameObject obj = target.gameObject; if (obj.CompareTag("Player")) // Check if it was the player that tried to pic the item { //get player status component StatusComponent comp = obj.GetComponent <StatusComponent>(); comp.Heal(m_HealAmount); // heal the player Debug.Log("Current Health = " + comp.GetCurrentHealth()); if (m_OnPickup != null) { m_OnPickup.Invoke(target, obj); // call auxiliary m_OnPickup function if there's one } DestroyItem(); // destroy the potion, since it was used } }