cards/CardStethoscope.cs
using Sandbox;
using System.Threading.Tasks;
public class CardStethoscope : Card
{
public override bool ShouldHandleEvent( EventType eventType )
{
return (eventType == EventType.Match || (eventType == EventType.Mismatch && !Manager.Instance.IsMismatchALockedMatch)) && Manager.Instance.ChosenCards.Contains( this );
}
public override async Task HandleEventAsync( EventType eventType )
{
var nearbyCards = Manager.Instance.GetNearbyCards( GridPos );
if ( nearbyCards.Count == 0 )
return;
Manager.Instance.PushEventMessage( this, eventType );
await Task.DelayRealtime( 250 );
bool shouldPlaySfx = false;
foreach ( var card in nearbyCards )
{
if ( card.IsAlive )
{
shouldPlaySfx = true;
break;
}
}
if ( shouldPlaySfx )
{
Manager.Instance.PlayCardSfx( "stethoscope", this, volume: 1.9f, pitch: Game.Random.Float( 1.05f, 1.08f ) );
await Task.DelayRealtime( 800 );
}
else
{
await Task.DelayRealtime( 200 );
}
foreach (var card in nearbyCards)
{
if(card.IsAlive)
{
await Manager.Instance.ShakeCard( card );
await Task.DelayRealtime( Game.Random.Int( 300, 450 ) );
}
}
await Task.DelayRealtime( 250 );
Manager.Instance.PopEventMessage();
}
//public override string GetEventText( EventType eventType )
//{
// if ( eventType == EventType.TurnStart )
// {
// return "✅Match: shake nearby cards with a heartbeat";
// }
// else
// {
// return "❌Mismatch: shake nearby cards with a heartbeat";
// }
//}
}