Beispiel #1
0
 //减少一次等待时间 如果有完成等待的卡 放入战场
 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 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));
    }