cards/CardRose.cs
using Sandbox;
using System.Threading.Tasks;
public class CardRose : Card
{
public override bool ShouldHandleEvent( EventType eventType )
{
if ( CardType == CardType.RoseWilted )
return false;
if(eventType == EventType.Mismatch && Manager.Instance.Cards.Count == 2)
{
var otherCard = Manager.Instance.ChosenCards[0] == this ? Manager.Instance.ChosenCards[1] : Manager.Instance.ChosenCards[0];
if ( otherCard.CardType == CardType.RoseWilted )
return true;
}
return (eventType == EventType.MoveCard && Manager.Instance.MovedCard == this) || (eventType == EventType.SwapCards && Manager.Instance.SwappedCards.Contains( this ));
}
public override async Task HandleEventAsync( EventType eventType )
{
if(eventType == EventType.MoveCard || eventType == EventType.SwapCards )
{
if ( IsRevealed )
Manager.Instance.PushEventMessage( this, eventType );
await Task.DelayRealtime( 300 );
SetCardType( CardType.RoseWilted );
if ( IsRevealed )
{
Manager.Instance.PlayCardSfx( "rose_wilt", this, volume: 1.4f, pitch: Game.Random.Float( 1f, 1.1f ) );
await Manager.Instance.ShakeCard( this, playSfx: false );
await Task.DelayRealtime( 350 );
}
else
{
await Manager.Instance.ShakeCard( this );
}
await Task.DelayRealtime( 300 );
if ( IsRevealed )
Manager.Instance.PopEventMessage();
}
else if (eventType == EventType.Mismatch)
{
await Task.DelayRealtime( 300 );
SetCardType( CardType.RoseWilted );
Manager.Instance.PlayCardSfx( "rose_wilt", this, volume: 1.4f, pitch: Game.Random.Float( 1f, 1.1f ) );
await Manager.Instance.ShakeCard( this, playSfx: false );
await Task.DelayRealtime( 300 );
}
}
public override string GetEventText( EventType eventType )
{
return GetCardDescription( CardType.Rose );
}
}