relics/RelicTelescope.cs
using Sandbox;
using System.Reflection.PortableExecutable;
using System.Runtime.Versioning;
using System.Threading.Tasks;
public class RelicTelescope : Relic
{
public override void Init()
{
base.Init();
MaxLevel = 1;
}
public override bool ShouldHandleEvent( EventType eventType )
{
return eventType == EventType.Choose && Manager.Instance.ChosenCards.Count == 1;
}
public override async Task HandleEventAsync( EventType eventType )
{
var card0 = Manager.Instance.ChosenCards[0];
var matches = Manager.Instance.GetCardsOfType( card0.CardType, except: card0 );
if ( matches.Count == 0 )
return;
bool isMatchClose = false;
foreach(var match in matches)
{
int xDiff = Math.Abs( card0.GridPos.x - match.GridPos.x );
int yDiff = Math.Abs( card0.GridPos.y - match.GridPos.y );
//Log.Info( $"xDiff: {xDiff} yDiff: {yDiff}" );
if( xDiff <= 2 && yDiff <= 2 )
{
isMatchClose = true;
break;
}
}
if ( isMatchClose )
return;
Manager.Instance.PushEventMessage( this, eventType );
await Task.DelayRealtime( 300 );
await Manager.Instance.ShakeCard( card0 );
await Task.DelayRealtime( 850 );
Manager.Instance.PopEventMessage();
}
}