OnAttack.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can trigger [On Attack] effect
  9. public static bool CanTriggerOnAttack(Hashtable hashtable, CardSource card)
  10. {
  11. return CanTriggerOnPermanentAttack(hashtable, (permanent) => permanent.cardSources.Contains(card));
  12. }
  13. #endregion
  14. #region Can trigger "when permanent attacks" effect
  15. public static bool CanTriggerOnPermanentAttack(Hashtable hashtable, Func<Permanent, bool> permanentCondition)
  16. {
  17. if (hashtable != null)
  18. {
  19. if (hashtable.ContainsKey("AttackingPermanent"))
  20. {
  21. if (hashtable["AttackingPermanent"] is Permanent)
  22. {
  23. Permanent AttackingPermanent = (Permanent)hashtable["AttackingPermanent"];
  24. if (AttackingPermanent != null)
  25. {
  26. if (AttackingPermanent.TopCard != null)
  27. {
  28. if (permanentCondition != null)
  29. {
  30. if (permanentCondition(AttackingPermanent))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. #endregion
  43. }