//减少一次等待时间 如果有完成等待的卡 放入战场 private IEnumerator UpdateWaitingField() { foreach (Transform obj in enemy.hand.owner) { RealCard rc = obj.gameObject.GetComponent <RealCard>(); if (rc.tm.waiting.CheckTurn()) //这张卡已经完成了冷却 { rc.HandToField(); logger.Log($"{rc.info.name}进场了"); enemy.hand.sendTo(obj.transform, enemy.field); yield return(new WaitForSeconds(gameSpeed)); } } foreach (Transform obj in our.hand.owner) { RealCard rc = obj.gameObject.GetComponent <RealCard>(); if (rc.tm.waiting.CheckTurn()) //这张卡已经完成了冷却 { rc.HandToField(); logger.Log($"{rc.info.name}进场了"); our.hand.sendTo(obj.transform, our.field); yield return(new WaitForSeconds(gameSpeed)); } } yield return(new WaitForSeconds(gameSpeed)); }
public SkillManager(GameManager _gm, RealCard _rc, List <Skill> _skills) { gm = _gm; rc = _rc; skills = new List <Skill>(); foreach (var _skill in _skills) //deepCopy { skills.Add(_skill); } skills.Add(new Skill { skill = MetaSkill.普通攻击, var = 1 }); //每张卡都有普通攻击技能,如果后续有特殊攻击技能,普通攻击会被移除 }
public IEnumerator Cast(Skill skill, CardGroup cg, int pos) { switch (skill.skill) { case MetaSkill.普通攻击: Debug.Assert(cg == gm.our.field || cg == gm.enemy.field); if (cg.side.enemy.field.owner.childCount > pos) { RealCard enemyCard = cg.side.enemy.field.owner.GetChild(pos).GetComponent <RealCard>(); // 获取对面的卡牌 enemyCard.hp -= rc.atk; // 扣血 gm.logger.Log($"{rc.info.name}攻击了{enemyCard.info.name}"); yield return(rc.gp.playGIFAnimation()); } else { // 直接攻击 cg.side.enemy.healthBar.Hp -= rc.info.atk; gm.logger.Log($"{rc.info.name}直接攻击了{((cg == gm.our.field) ? "敌":"我")}方玩家"); } break; case MetaSkill.冲阵: if (cg.side.hand.owner.childCount == 0) { gm.logger.Log($"{rc.info.name}试图发动冲阵{skill.var},但是手牌是空的"); } else { //随机选择一个目标 RealCard tar = cg.side.hand.owner.GetChild(UnityEngine.Random.Range(0, cg.side.hand.owner.childCount)).GetComponent <RealCard>(); gm.logger.Log($"{rc.info.name}为{tar.info.name}发动了冲阵{skill.var}"); if (tar.tm.waiting.CheckTurn(skill.var)) //如果因此进场的话 { yield return(new WaitForSeconds(GameManager.gameSpeed)); tar.HandToField(); gm.logger.Log($"{tar.info.name}进场了"); cg.sendTo(tar.transform, cg.side.field); } } break; } yield return(new WaitForSeconds(GameManager.gameSpeed)); }
//添加一个状态 public void SetToken(TokenType ty, RealCard real, int num = 1) { switch (ty) { case TokenType.攻击力: attack.show(); attack.setNum(num); break; case TokenType.生命: health.show(); health.setNum(num); health.maxHp = real.info.hp; //需要额外存储一个hp,这里的real并不是敌人而是本体 break; case TokenType.等待: waiting.show(); waiting.setNum(num); break; } }
//抽卡 将卡组的卡移到手牌 private IEnumerator DrawCard() { //yield return new WaitForSeconds(gameSpeed); //我方回合 if (counter.turn % 2 == 1 && !our.deck.empty()) { Transform tar = our.deck.owner.GetChild(0); RealCard tarRC = tar.gameObject.GetComponent <RealCard>(); tarRC.tm.SetToken(TokenType.等待, tarRC, tarRC.info.turn); our.deck.sendTo(tar, our.hand); logger.Log($"我方抽卡 {tarRC.info.name}"); } //敌方回合 if (counter.turn % 2 == 0 && !enemy.deck.empty()) { Transform tar = enemy.deck.owner.GetChild(0); RealCard tarRC = tar.gameObject.GetComponent <RealCard>(); tarRC.tm.SetToken(TokenType.等待, tarRC, tarRC.info.turn); enemy.deck.sendTo(tar, enemy.hand); logger.Log($"敌方抽卡 {tarRC.info.name}"); } yield return(new WaitForSeconds(gameSpeed)); }
//public IAbilityEffect _abilityEffect; public abstract void CastAbility(RealCard card);
/// <summary> /// Used by derived class to initial its base part. /// </summary> /// <param name="realCard">real card.</param> protected RealCard(RealCard realCard) { }
void AddCardTo(int i, RealCard rc) { //GameObject go = new GameObject() }