IEnumerator EnemyFight()//敌人攻击回合 { //遍历,若有敌人死亡则销毁敌人 DestoryEnemy(); if (enemyList.Count != 0) { for (int i = 0; i < enemyList.Count; i++) { if (enemyList[i].subRounds())//回合数减少,0时攻击 { enemyList[i].role = rolelist[UnityEngine.Random.Range(0, 3)]; enemyList[i].goMove(); yield return(new WaitForSeconds(1)); Hurt(Random.Range(Mathf.CeilToInt(enemyList[i].enemy.PhyAttck * 0.8f), enemyList[i].enemy.PhyAttck * 2));//敌人攻击方法,伤害随机计算 switch (enemyList[i].isBoss) { case 2: if (Random.Range(0, 2) == 0) { stateMgr.randomBuddle(Random.Range(2, 5)); //随机生成障碍 } break; case 3: if (Random.Range(0, 2) == 0) { stateMgr.randomState(State.burn, Random.Range(1, 3)); //随机生成燃烧状态 } break; case 4: if (Random.Range(0, 2) == 0) { stateMgr.randomState(State.poison, Random.Range(1, 3)); //随机生成中毒状态 } break; default: break; } enemyList[i].Back(); yield return(new WaitForSeconds(fillTime)); } } } if (enemyList.Count == 0 && Levelnum > 1)//如果没有敌人,则再次生成,共三波敌人 { //地图移动 if (SaveIndexMgr.Instance.SaveSceneId == 1) { MapTranslateOne.Instance.MapRun(); } if (SaveIndexMgr.Instance.SaveSceneId == 2) { MapTranslateTwo.Instance.MapRun(); } if (SaveIndexMgr.Instance.SaveSceneId == 3) { MapTranslateThree.Instance.MapRun(); } if (SaveIndexMgr.Instance.SaveSceneId == 4) { MapTranslateFour.Instance.MapRun(); } roleMove();//人物移动动画 yield return(new WaitForSeconds(2.4f)); OnceAgain(); roleStop();//人物停止动画 int i = int.Parse(RoleInfoMgr.Instance.timeRound.text); i++; RoleInfoMgr.Instance.timeRound.text = i.ToString();//显示回合数 Levelnum -= 1; } if (enemyList.Count == 0 && Levelnum == 1) { Debug.Log("Success"); Vectory(); } CheckState(); //检查消消乐棋盘是否存在debuff grid.Start(); //人物动画执行完毕后打开消消乐界面格子拖动操作 }