using System.Collections; using System.Collections.Generic; using UnityEngine; using System; using Unity.Mathematics; public class ChangeSAttackClass : ICardEffect, IChangeSAttackEffect { public void SetUpChangeSAttackClass(Func changeSAttackFunc, Func permanentCondition, Func isUpDown) { _changeSAttackFunc = changeSAttackFunc; _permanentCondition = permanentCondition; _isUpDown = isUpDown; } Func _changeSAttackFunc = null; Func _permanentCondition = null; Func _isUpDown = null; public int GetSAttack(int SAttack, Permanent permanent, int invertValue) { int changedSAttack = SAttack; if (PermanentCondition(permanent)) { changedSAttack = _changeSAttackFunc(permanent, SAttack); switch (invertValue) { case -1: if(changedSAttack < SAttack) changedSAttack = SAttack + Mathf.Abs(changedSAttack - SAttack); break; case 1: if (changedSAttack > SAttack) changedSAttack = SAttack - (changedSAttack - SAttack); break; } } return changedSAttack; } public CalculateOrder isUpDown() { if (_isUpDown != null) { return _isUpDown(); } return CalculateOrder.UpToConstant; } public bool PermanentCondition(Permanent permanent) { if (permanent != null) { if (permanent.TopCard != null) { if (_permanentCondition != null) { if (_permanentCondition(permanent)) { return true; } } } } return false; } }