private void ApplyEffects(GameObject player) { if (healing) { origin.GetComponent <Health>().Heal(healingAmount); } if (poison) { if (currentDot) { currentDot.Reapply(); } else { currentDot = player.AddComponent <DotDamage>(); currentDot.SetInitial(null, Random.Range(3f, 5f)); currentDot.SetStats(1, damageMultiplier, 1f); } } if (slowing) { SlowingEffect newDebuff = player.AddComponent <SlowingEffect>(); newDebuff.SetInitial(null, Random.Range(1f, 2f)); newDebuff.SetStats(Random.Range(0f, 0.3f)); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.Equals(player.gameObject) && player.speedMultiplier >= 1) { playerHealth.TakeDamage(damage); SlowingEffect newDebuff = player.gameObject.AddComponent <SlowingEffect>(); newDebuff.SetInitial(null, slowTime); newDebuff.SetStats(slowingEffect); } }
protected override void OnCollisionEnter2D(Collision2D collision) { base.OnCollisionEnter2D(collision); if (collision.gameObject.CompareTag(playerTag)) { SlowingEffect newDebuff = collision.gameObject.AddComponent <SlowingEffect>(); newDebuff.SetInitial(null, Random.Range(1f, 2f)); newDebuff.SetStats(Random.Range(0f, 0.3f)); } }
// The player can avoid being slowed by roots // if they i-frame into them but they cannot i-frame out. // There is a slight quirk where i-framing at the same // time as the root is destroyed which causes the debuff // component to not be removed but its effects are removed. // // Doesn't really cause problems except cluttering the inspector, so whatever. private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.Equals(playerObject)) { // Adds a slow debuff to the player if the effect is either: // Temporary, OR // Permanent AND the player does not already have a slow debuff if (!permanentEffect || (permanentEffect && playerObject.GetComponent <SlowingEffect>() == null)) { debuff = playerObject.AddComponent <SlowingEffect>(); debuff.SetInitial(slowingVFX, forever); debuff.SetStats(slowingEffect, slowingCap); } } }
private const float slowRatio = 1; // Set to 1 for 100% slow protected override void EnterEffect() { if (generateRoots) { Vector3 trapPos = transform.position; Vector3 rootPos = new Vector3(trapPos.x, trapPos.y, trapPos.z - 1); Root newRoot = Instantiate(root, rootPos, transform.rotation).GetComponent <Root>(); newRoot.SetUp(player.GetComponent <Player>(), false, debuffTime, slowRatio); } else { SlowingEffect newDebuff = player.AddComponent <SlowingEffect>(); newDebuff.SetInitial(slowVFX, debuffTime); newDebuff.SetStats(slowRatio, slowRatio); } }
private void OnTriggerEnter2D(Collider2D collision) { if (!active && collision.CompareTag(wallTag)) { flightTime = 0; } else if (active && collision.gameObject.CompareTag(playerTag)) { GameObject player = collision.gameObject; player.GetComponent <Health>().TakeDamage(damage); SlowingEffect newDebuff = player.AddComponent <SlowingEffect>(); newDebuff.SetInitial(null, lifeTime); newDebuff.SetStats(1, 1); origin.GetComponent <Health>().Heal(damage); StartCoroutine(delayedDeath()); } }