cards/CardGuideDog.cs
using Sandbox;
using System.Threading.Tasks;
public class CardGuideDog : Card
{
public override bool IsAlive => true;
public override bool ShouldHandleEvent( EventType eventType )
{
return eventType == EventType.Mismatch
&& Manager.Instance.ChosenCards[0].CardType != CardType.GuideDog && Manager.Instance.ChosenCards[1].CardType != CardType.GuideDog
&& !Manager.Instance.IsMismatchALockedMatch && Manager.Instance.Stats[StatType.TurnNum] % CardTypeID == 0 && Game.Random.Float(0f, 1f) < 0.5f;
}
public override async Task HandleEventAsync( EventType eventType )
{
var card = Manager.Instance.ChosenCards[Game.Random.Int( 0, 1 )];
var matches = Manager.Instance.GetCardsOfType( card.CardType, except: card );
if ( matches.Count == 0 )
return;
var match = matches[Game.Random.Int( 0, matches.Count - 1 )];
Manager.Instance.PushEventMessage( this, eventType );
await Task.DelayRealtime( 50 );
if ( !IsRevealed )
await Manager.Instance.RevealCard( this );
await Task.DelayRealtime( 300 );
MoveToPos( LocalPosition + (match.LocalPosition - LocalPosition).Normal * 5f, 0.25f, EasingType.QuadInOut, removeControlAfter: true );
Manager.Instance.PlayCardSfx( "service_dog", this, volume: 1.2f, pitch: Game.Random.Float( 0.95f, 1.05f ) );
await Task.DelayRealtime( 500 );
Manager.Instance.HideCard( this );
await Task.DelayRealtime( 150 );
Manager.Instance.PopEventMessage();
}
}