public bool AITurn() { if (EnemyController.GetInstance().grids[1].childCount == 0) { return(true); } if (TurnController.GetInstance().turnIndex == 0) { if (TurnController.GetInstance().isTurned[0] && (PlayerController.GetInstance().grids[1].childCount >= EnemyController.GetInstance().grids[1].childCount || PowerController.GetInstance().enemy_total > PowerController.GetInstance().player_total || PowerController.GetInstance().player_total - PowerController.GetInstance().enemy_total >= 25)) { return(true); } else if (PowerController.GetInstance().enemy_total - PowerController.GetInstance().player_total >= 15 || PowerController.GetInstance().player_total - PowerController.GetInstance().enemy_total >= 25) { return(true); } } if (TurnController.GetInstance().turnIndex == 1) { if (TurnController.GetInstance().isTurned[0]) { if ((int)GameOver.GetInstance().playerPowerList[0] >= (int)GameOver.GetInstance().enemyPowerList[0] && PowerController.GetInstance().enemy_total > PowerController.GetInstance().player_total) { return(true); } else if ((int)GameOver.GetInstance().enemyPowerList[0] > (int)GameOver.GetInstance().playerPowerList[0] && (PlayerController.GetInstance().grids[1].childCount >= EnemyController.GetInstance().grids[1].childCount || PowerController.GetInstance().enemy_total > PowerController.GetInstance().player_total)) { return(true); } } else if ((int)GameOver.GetInstance().playerPowerList[0] > (int)GameOver.GetInstance().enemyPowerList[0] && PowerController.GetInstance().enemy_total - PowerController.GetInstance().player_total >= 15) { return(true); } else if ((int)GameOver.GetInstance().enemyPowerList[0] >= (int)GameOver.GetInstance().playerPowerList[0] && PowerController.GetInstance().player_total - PowerController.GetInstance().enemy_total >= 25) { return(true); } else if (PowerController.GetInstance().enemy_total - PowerController.GetInstance().player_total >= 25) { return(true); } } return(false); }
public void PlayOver(Transform card) { CoroutineManager.GetInstance().AddTask(TweenCard.GetInstance().Play(card)); Number(); PowerController.GetInstance().Number(); if (!TurnController.GetInstance().isTurned[1]) { CoroutineManager.GetInstance().AddTask(EnemyController.GetInstance().Play(EnemyController.GetInstance().grids[1])); } }
IEnumerator PlayOver(Transform card) { StartCoroutine(LeaderController.GetInstance().EnemyTurnIndicator()); yield return(TweenCard.GetInstance().Play(card)); Number(); PowerController.GetInstance().Number(); if (TurnController.GetInstance().isTurned[0]) { yield return(Play(grids[1])); } }
public IEnumerator Turn() { TurnController.GetInstance().Clear(); GameOver.GetInstance().AddPower(PowerController.GetInstance().player_total, PowerController.GetInstance().enemy_total); int power = PowerController.GetInstance().player_total - PowerController.GetInstance().enemy_total; GameBehavior gameBehavior = new GameBehavior(); if (power > 0) { enemy_life_gem[enemy_fail].PlayForward(); enemy_fail++; gameBehavior = GameBehavior.win; } else if (power < 0) { player_life_gem[player_fail].PlayForward(); player_fail++; gameBehavior = GameBehavior.lose; } else if (power == 0) { if (PlayerController.GetInstance().group == Global.Group.nilfgaardian && EnemyController.GetInstance().group == Global.Group.nilfgaardian) { player_life_gem[player_fail].PlayForward(); enemy_life_gem[enemy_fail].PlayForward(); player_fail++; enemy_fail++; gameBehavior = GameBehavior.dogfall; } else if (PlayerController.GetInstance().group == Global.Group.nilfgaardian) { enemy_life_gem[enemy_fail].PlayForward(); enemy_fail++; gameBehavior = GameBehavior.win; yield return(TweenMessage.GetInstance().Play("领导牌技能发动\r\n平手时获胜")); } else if (EnemyController.GetInstance().group == Global.Group.nilfgaardian) { player_life_gem[player_fail].PlayForward(); player_fail++; gameBehavior = GameBehavior.lose; } else { player_life_gem[player_fail].PlayForward(); enemy_life_gem[enemy_fail].PlayForward(); player_fail++; enemy_fail++; gameBehavior = GameBehavior.dogfall; } } if (player_fail == 2) { yield return(GameOver.GetInstance().Show(false)); CoroutineManager.GetInstance().Finish(); yield break; } else if (enemy_fail == 2) { yield return(GameOver.GetInstance().Show(true)); CoroutineManager.GetInstance().Finish(); yield break; } WeatherController.GetInstance().ClearSky(); Transform playerMonsterCard = null; if (PlayerController.GetInstance().group == Global.Group.monster) { ArrayList line = new ArrayList(); for (int i = 0; i < 3; i++) { if (PlayerController.GetInstance().grids[i + 2].childCount != 0) { line.Add(i); } } if (line.Count != 0) { int randomLine = (int)line[Random.Range(0, line.Count)]; int randomIndex = Random.Range(0, PlayerController.GetInstance().grids[randomLine + 2].childCount); playerMonsterCard = PlayerController.GetInstance().grids[randomLine + 2].GetChild(randomIndex); } } Transform enemyMonsterCard = null; if (EnemyController.GetInstance().group == Global.Group.monster) { ArrayList line = new ArrayList(); for (int i = 0; i < 3; i++) { if (EnemyController.GetInstance().grids[i + 2].childCount != 0) { line.Add(i); } } if (line.Count != 0) { int randomLine = (int)line[Random.Range(0, line.Count)]; int randomIndex = Random.Range(0, EnemyController.GetInstance().grids[randomLine + 2].childCount); enemyMonsterCard = EnemyController.GetInstance().grids[randomLine + 2].GetChild(randomIndex); } } for (int i = 2; i < 5; i++) { for (int ii = PlayerController.GetInstance().grids[i].childCount - 1; ii >= 0; ii--) { PlayerController.GetInstance().grids[i].GetChild(ii).SetTarget(PlayerController.GetInstance().grids[5]); } } for (int i = 2; i < 5; i++) { for (int ii = EnemyController.GetInstance().grids[i].childCount - 1; ii >= 0; ii--) { EnemyController.GetInstance().grids[i].GetChild(ii).SetTarget(EnemyController.GetInstance().grids[5]); } } for (int i = 0; i < 3; i++) { if (WarhornController.GetInstance().playerWarhorn[i]) { if (WarhornController.GetInstance().playerGrids[i].childCount == 1) { WarhornController.GetInstance().playerGrids[i].GetChild(0).SetTarget(PlayerController.GetInstance().grids[5]); } WarhornController.GetInstance().playerWarhorn[i] = false; } if (WarhornController.GetInstance().enemyWarhorn[i]) { if (WarhornController.GetInstance().enemyGrids[i].childCount == 1) { WarhornController.GetInstance().enemyGrids[i].GetChild(0).SetTarget(EnemyController.GetInstance().grids[5]); } WarhornController.GetInstance().enemyWarhorn[i] = false; } } switch (gameBehavior) { case GameBehavior.win: yield return(TweenMessage.GetInstance().Play("此局获胜")); break; case GameBehavior.lose: yield return(TweenMessage.GetInstance().Play("此局失败")); break; case GameBehavior.dogfall: yield return(TweenMessage.GetInstance().Play("此局平手")); break; } if (PlayerController.GetInstance().group == Global.Group.northern && gameBehavior == GameBehavior.win) { PlayerController.GetInstance().DrawCards(1); yield return(TweenMessage.GetInstance().Play("领导牌技能发动\r\n摸一张牌")); } if (EnemyController.GetInstance().group == Global.Group.northern && gameBehavior == GameBehavior.lose) { EnemyController.GetInstance().DrawCards(1); } if (PlayerController.GetInstance().group == Global.Group.monster && playerMonsterCard != null) { playerMonsterCard.SetTarget(PlayerController.GetInstance().grids[(int)playerMonsterCard.GetComponent <CardProperty>().line + 2]); if (playerMonsterCard.GetComponent <CardProperty>().effect == Global.Effect.warhorn) { WarhornController.GetInstance().playerWarhorn[0] = true; } yield return(TweenMessage.GetInstance().Play("领导牌技能发动\r\n保留一张牌再战场上")); } if (EnemyController.GetInstance().group == Global.Group.monster && enemyMonsterCard != null) { enemyMonsterCard.SetTarget(EnemyController.GetInstance().grids[(int)enemyMonsterCard.GetComponent <CardProperty>().line + 2]); if (enemyMonsterCard.GetComponent <CardProperty>().effect == Global.Effect.warhorn) { WarhornController.GetInstance().enemyWarhorn[0] = true; } } PlayerController.GetInstance().grids[5].gameObject.SetActive(false); PlayerController.GetInstance().grids[5].gameObject.SetActive(true); EnemyController.GetInstance().grids[5].gameObject.SetActive(false); EnemyController.GetInstance().grids[5].gameObject.SetActive(true); PowerController.GetInstance().Number(); offensive = !offensive; if (offensive) { yield return(TweenMessage.GetInstance().Play("你先手")); LeaderController.GetInstance().PlayerTurnIndicator(); } else { yield return(TweenMessage.GetInstance().Play("对方先手")); yield return(EnemyController.GetInstance().Play(EnemyController.GetInstance().grids[1])); } CoroutineManager.GetInstance().Finish(); }
public int AICard(Transform grid) { cardList.Clear(); for (int i = 0; i < grid.childCount; i++) { cardList.Add(grid.GetChild(i)); } int index = -1; if (HasCard(Global.Effect.spy, out index)) { return(index);//间谍 } if (HasCard(Global.Effect.frost, out index) && PowerController.GetInstance().enemy[0] + 10 < PowerController.GetInstance().player[0] && !WeatherController.GetInstance().weather[0]) { return(index);//霜冻 } if (HasCard(Global.Effect.fog, out index) && PowerController.GetInstance().enemy[1] + 10 < PowerController.GetInstance().player[1] && !WeatherController.GetInstance().weather[1]) { return(index);//雾天 } if (HasCard(Global.Effect.rain, out index) && PowerController.GetInstance().enemy[2] + 10 < PowerController.GetInstance().player[2] && !WeatherController.GetInstance().weather[2]) { return(index);//地形雨 } int playerPower = 0; int enemyPower = 0; for (int i = 2; i < 5; i++) { for (int ii = 0; ii < PlayerController.GetInstance().grids[i].childCount; ii++) { playerPower += PlayerController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().power; } for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { enemyPower += EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().power; } } if (HasCard(Global.Effect.clear_sky, out index) && enemyPower > playerPower && ( WeatherController.GetInstance().weather[0] || WeatherController.GetInstance().weather[1] || WeatherController.GetInstance().weather[2])) { return(index);//晴天 } if (HasCard(Global.Effect.warhorn, out index) && (EnemyController.GetInstance().grids[2].childCount > 3 && !WarhornController.GetInstance().enemyWarhorn[0]) || (EnemyController.GetInstance().grids[3].childCount > 3 && !WarhornController.GetInstance().enemyWarhorn[1]) || (EnemyController.GetInstance().grids[4].childCount > 3 && !WarhornController.GetInstance().enemyWarhorn[2])) { return(index);//战斗号角 } bool isDummy = false; for (int i = 2; i < 5; i++) { for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { if (EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().effect == Global.Effect.spy || EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().effect == Global.Effect.nurse || EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().effect == Global.Effect.scorch || EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().effect == Global.Effect.warhorn) { isDummy = true; } } } if (HasCard(Global.Effect.dummy, out index) && grid != EnemyController.GetInstance().grids[5] && isDummy) { return(index);//稻草人 } int playerMaxPower = 0; int enemyMaxPower = 0; for (int i = 2; i < 5; i++) { for (int ii = 0; ii < PlayerController.GetInstance().grids[i].childCount; ii++) { if (!PlayerController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().gold) { int power = PlayerController.GetInstance().grids[i].GetChild(ii).GetComponent <CardBehavior>().totalPower; if (power > playerMaxPower) { playerMaxPower = power; } } } for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { if (!EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>().gold) { int power = EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardBehavior>().totalPower; if (power > enemyMaxPower) { enemyMaxPower = power; } } } } if (HasCard(Global.Effect.scorch, out index) && playerMaxPower >= 10 && playerMaxPower > enemyMaxPower) { return(index);//毒药 } if (HasCard(Global.Effect.muster, out index) && PowerController.GetInstance().enemy_total - 5 <= PowerController.GetInstance().player_total&& !IsWeather(cardList[index] as Transform)) { return(index);//召集 } if (HasCard(Global.Effect.same_type_morale, out index) && !IsWeather(cardList[index] as Transform)) { return(index);//士气增长 } if (HasCard(Global.Effect.nurse, out index) && EnemyController.GetInstance().grids[5].childCount > 3 && !IsWeather(cardList[index] as Transform)) { return(index);//护士 } if (PowerController.GetInstance().enemy_total >= PowerController.GetInstance().player_total) { int minPowerIndex = 0; int minPower = 15; for (int i = 0; i < cardList.Count; i++) { if ((cardList[i] as Transform).GetComponent <CardProperty>().power < minPower && (cardList[i] as Transform).GetComponent <CardProperty>().power > 0 && !IsWeather(cardList[i] as Transform)) { minPower = (cardList[i] as Transform).GetComponent <CardProperty>().power; minPowerIndex = i; } } return(minPowerIndex); } else if (PowerController.GetInstance().enemy_total < PowerController.GetInstance().player_total) { int maxPowerIndex = 0; int maxPower = 0; for (int i = 0; i < cardList.Count; i++) { if ((cardList[i] as Transform).GetComponent <CardProperty>().power > maxPower && !IsWeather(cardList[i] as Transform)) { maxPower = (cardList[i] as Transform).GetComponent <CardProperty>().power; maxPowerIndex = i; } } return(maxPowerIndex); } return(Random.Range(0, grid.childCount)); }