public override void Tick() { if (!manfred.playerInput.GetIsHoldingSiphon()) { TransitionToSiphonRecovery(); return; } Collider2D[] colliders = Physics2D.OverlapCircleAll(manfred.siphonSinkTransform.position, siphonRadius, siphonLayerMask); for (int i = 0; i < colliders.Length; i++) { Collider2D collider = colliders[i]; SiphonSource source = collider.GetComponentInParent <SiphonSource>(); if (source != null) { source.OnSiphoned(manfred.siphonSinkTransform.position, attractForce); SiphonDroplet droplet = source as SiphonDroplet; if (droplet != null && ShouldCollectDroplet(droplet)) { CollectDroplet(droplet); Debug.Log("generating impulse"); impulseSource.GenerateImpulse(); } } } }
public void OnSiphoned(Vector3 siphonPosition, float siphonForce) { if (state == State.STUNNED) { ChangeState(State.PAINED); } else if (state == State.PAINED) { if (timeSinceSpawnedDroplet > spawnDropletCooldown) { health -= 1; SiphonDroplet droplet = GameObject.Instantiate(dropletPrototype, siphonSourcePosition.position, Quaternion.identity).GetComponent <SiphonDroplet>(); droplets.Add(droplet); droplet.SetInitialVelocity(Random.insideUnitCircle * 5); timeSinceSpawnedDroplet = 0f; if (hasBossRetreated) { droplet.givesJudgment = true; } if (health <= bossRetreatThreshold / 2 && isBoss && !hasBossRetreated) { ChangeState(State.RETREATING); NotifyDropletsStopSiphoning(); hasBossRetreated = true; } } } if (health <= 0 && state != State.DYING) { NotifyDropletsStopSiphoning(); ChangeState(State.DYING); if (!isBoss) { enemyManager.DecrementTrashEnemies(); } if (listeners != null) { foreach (Listener listener in listeners) { listener.OnDeath(); } } } }
private void CollectDroplet(SiphonDroplet droplet) { droplet.OnCollected(); manfred.cardManager.AddPercentToCard(droplet.GetPercentContained(), droplet.givesJudgment); }
private bool ShouldCollectDroplet(SiphonDroplet droplet) { float distance = (droplet.transform.position - manfred.siphonSinkTransform.position).magnitude; return(distance < collectDistanceRadius); }