//スタックの追加 public void AddStack(EventBlock block) { if (EventStack.Count <= 0) { EventStack.Push(new StackEndBlock(block.GetCaster())); } EventStack.Push(block); isStackResolved = false; StartCoroutine(CallTrigger(block)); //Debug.Log(block); }
public IEnumerator Trap(TriggerType trigger, List <Card> cards, EventBlock block) { yield return(null); Card openTrap = null; switch (trigger) { case TriggerType.TakeAttack: AttackBlock atkBlock = block as AttackBlock; if (atkBlock == null) { yield break; } int damage = block.GetCaster().AttackPower; int needValue = 0; //必要な最低値 if (atkBlock.GetTarget().GetComponent <Player>()) { damage -= player.Defence; if (damage >= player.Life) { needValue = damage - player.Life; } else if (damage > 0) { needValue = 1; } } else { damage -= atkBlock.GetTarget().GetComponent <Card>().State.defence; needValue = damage + 1; } foreach (Card c in cards) { foreach (CardEffect ce in c.State.Effect) { foreach (EffectState es in ce.effectState) { if (es.effectType == EffectType.AttackAdd && es.value >= -needValue) { if (openTrap == null || openTrap.State.Cost > c.State.Cost) { openTrap = c; } } } } } break; case TriggerType.TakeSkill: openTrap = cards[0]; break; case TriggerType.TakeDispCard: CardDispBlock disp = block as CardDispBlock; if (disp.GetCards()[0].State.cardAligment == player.cardAligment) { openTrap = cards[0]; } break; default: openTrap = cards[0]; break; } if (openTrap) { yield return(new WaitForSeconds(0.5f)); Constants.BATTLE.CardOpen(openTrap); } }