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(); } } } }
private void TransitionToSiphonRecovery() { // This is a hack and should be done smarter by storing the currently attracted droplets and notifying them without finding them again. Collider2D[] colliders = Physics2D.OverlapCircleAll(manfred.siphonSinkTransform.position, siphonRadius * 2, siphonLayerMask); for (int i = 0; i < colliders.Length; i++) { Collider2D collider = colliders[i]; SiphonSource source = collider.GetComponentInParent <SiphonSource>(); if (source != null) { source.OnSiphonStopped(); } } manfred.fsm.ChangeState(manfred.stateSiphonRecovery, manfred.stateSiphonRecovery); }