public void Return() { BlackShow.GetInstance().Show(false); obj.SetActive(false); PlayerController.GetInstance().obj.SetActive(true); EnemyController.GetInstance().obj.SetActive(true); }
public IEnumerator Show(bool isWin) { BlackShow.GetInstance().Show(true); PlayerController.GetInstance().obj.SetActive(false); EnemyController.GetInstance().obj.SetActive(false); obj.SetActive(true); if (isWin) { label.text = "游戏结束,你赢了!"; } else { label.text = "游戏结束,你输了"; } for (int i = 0; i < playerPowerList.Count; i++) { player_labels[i].text = playerPowerList[i].ToString(); } for (int i = 0; i < enemyPowerList.Count; i++) { enemy_labels[i].text = enemyPowerList[i].ToString(); } CoroutineManager.GetInstance().Finish(); yield return(null); }
public void Hide() { totalGrid = null; grid.DestroyChildren(); BlackShow.GetInstance().Show(false); PlayerController.GetInstance().obj.SetActive(true); EnemyController.GetInstance().obj.SetActive(true); obj.SetActive(false); }
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])); } }
public void PlayerTurn() { isTurned[0] = true; playerLabel.SetActive(true); if (isTurned[0] && isTurned[1]) { CoroutineManager.GetInstance().AddTask(GameController.GetInstance().Turn()); return; } CoroutineManager.GetInstance().AddTask(EnemyController.GetInstance().Play(EnemyController.GetInstance().grids[1])); }
public void StartGame() { if (PlayerController.GetInstance().group == Global.Group.scoiatael) { CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("领导牌技能发动\r\n可选择先手后手")); } else { int random = Random.Range(0, 2); if (random == 0) { offensive = true; } else { offensive = false; } } if (LeaderController.GetInstance().obj[0].GetComponent <PlayerLeaderBehavior>().GetType() == typeof(NilfgaardianBehavior3)) { LeaderController.GetInstance().obj[0].GetComponent <PlayerLeaderBehavior>().Play(); CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("领导牌技能发动\r\n取消对手领导牌能力")); } if (LeaderController.GetInstance().obj[0].GetComponent <PlayerLeaderBehavior>().GetType() == typeof(ScoiataelBehavior2)) { LeaderController.GetInstance().obj[0].GetComponent <PlayerLeaderBehavior>().Play(); CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("领导牌技能发动\r\n战斗开始时多摸一张牌")); } if (LeaderController.GetInstance().obj[1].GetComponent <EnemyLeaderBehavior>().GetType() == typeof(EnemyNilfgaardianBehavior3)) { LeaderController.GetInstance().obj[1].GetComponent <EnemyLeaderBehavior>().Play(); CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("敌方领导牌技能发动\r\n取消我方领导牌能力")); } if (LeaderController.GetInstance().obj[1].GetComponent <EnemyLeaderBehavior>().GetType() == typeof(EnemyScoiataelBehavior2)) { LeaderController.GetInstance().obj[1].GetComponent <EnemyLeaderBehavior>().Play(); CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("敌方领导牌技能发动\r\n战斗开始时多摸一张牌")); } if (offensive) { CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("你先手")); LeaderController.GetInstance().PlayerTurnIndicator(); } else { CoroutineManager.GetInstance().AddTask(TweenMessage.GetInstance().Play("对方先手")); CoroutineManager.GetInstance().AddTask(EnemyController.GetInstance().Play(EnemyController.GetInstance().grids[1])); } }
public void Number() { player = new int[3] { 0, 0, 0 }; enemy = new int[3] { 0, 0, 0 }; int[] player_improve_neighbours = { 0, 0, 0 }; int[] enemy_improve_neighbours = { 0, 0, 0 }; Dictionary <string, int> player_same_type_morale = new Dictionary <string, int>(); Dictionary <string, int> enemy_same_type_morale = new Dictionary <string, int>(); for (int i = 2; i < 5; i++) { for (int ii = 0; ii < PlayerController.GetInstance().grids[i].childCount; ii++) { CardProperty cardProperty = PlayerController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>(); switch (cardProperty.effect) { case Global.Effect.improve_neighbours: player_improve_neighbours[i - 2]++; break; case Global.Effect.same_type_morale: string spriteName = cardProperty.GetComponent <UISprite>().spriteName; if (!player_same_type_morale.ContainsKey(spriteName)) { player_same_type_morale.Add(spriteName, 1); } else { int value = player_same_type_morale[spriteName]; value++; player_same_type_morale[spriteName] = value; } break; } } } for (int i = 2; i < 5; i++) { for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { CardProperty cardProperty = EnemyController.GetInstance().grids[i].GetChild(ii).GetComponent <CardProperty>(); switch (cardProperty.effect) { case Global.Effect.improve_neighbours: enemy_improve_neighbours[i - 2]++; break; case Global.Effect.same_type_morale: string spriteName = cardProperty.GetComponent <UISprite>().spriteName; if (!enemy_same_type_morale.ContainsKey(spriteName)) { enemy_same_type_morale.Add(spriteName, 1); } else { int value = enemy_same_type_morale[spriteName]; value++; enemy_same_type_morale[spriteName] = value; } break; } } } for (int i = 2; i < 5; i++) { for (int ii = 0; ii < PlayerController.GetInstance().grids[i].childCount; ii++) { Transform card = PlayerController.GetInstance().grids[i].GetChild(ii); CardProperty cardProperty = card.GetComponent <CardProperty>(); int power = cardProperty.power; if (!cardProperty.gold) { if (WeatherController.GetInstance().weather[i - 2]) { power = 1; } string spriteName = card.GetComponent <UISprite>().spriteName; if (player_same_type_morale.ContainsKey(spriteName)) { power *= player_same_type_morale[spriteName]; } if (cardProperty.effect != Global.Effect.improve_neighbours) { power += player_improve_neighbours[i - 2]; } if (WarhornController.GetInstance().playerWarhorn[i - 2]) { power *= 2; } } card.GetComponent <CardBehavior>().totalPower = power; player[i - 2] += power; } } for (int i = 2; i < 5; i++) { for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { Transform card = EnemyController.GetInstance().grids[i].GetChild(ii); CardProperty cardProperty = card.GetComponent <CardProperty>(); int power = cardProperty.power; if (!cardProperty.gold) { if (WeatherController.GetInstance().weather[i - 2]) { power = 1; } string spriteName = card.GetComponent <UISprite>().spriteName; if (enemy_same_type_morale.ContainsKey(spriteName)) { power *= enemy_same_type_morale[spriteName]; } if (cardProperty.effect != Global.Effect.improve_neighbours) { power += enemy_improve_neighbours[i - 2]; } if (WarhornController.GetInstance().enemyWarhorn[i - 2]) { power *= 2; } } card.GetComponent <CardBehavior>().totalPower = power; enemy[i - 2] += power; } } for (int i = 0; i < 3; i++) { player_power_label[i].text = player[i].ToString(); enemy_power_label[i].text = enemy[i].ToString(); } player_total = player[0] + player[1] + player[2]; enemy_total = enemy[0] + enemy[1] + enemy[2]; player_power_label[3].text = player_total.ToString(); enemy_power_label[3].text = enemy_total.ToString(); if (player_total > enemy_total) { player_winner_indicator.gameObject.SetActive(true); enemy_winner_indicator.gameObject.SetActive(false); } else if (player_total < enemy_total) { player_winner_indicator.gameObject.SetActive(false); enemy_winner_indicator.gameObject.SetActive(true); } else if (player_total == enemy_total) { player_winner_indicator.gameObject.SetActive(true); enemy_winner_indicator.gameObject.SetActive(true); } }
public void Play() { int index = 0; for (int i = 0; i < ShowCards.GetInstance().totalGrid.childCount; i++) { if (string.Format("{0}(Clone)", ShowCards.GetInstance().totalGrid.GetChild(i).name) == name) { index = i; } } ShowCards.GetInstance().card = ShowCards.GetInstance().totalGrid.GetChild(index); switch (cardProperty.effect) { case Global.Effect.spy: ShowCards.GetInstance().card.SetTarget(EnemyController.GetInstance().grids[(int)cardProperty.line + 2]); PlayerController.GetInstance().DrawCards(2); break; case Global.Effect.clear_sky: WeatherController.GetInstance().ClearSky(); goto default; case Global.Effect.frost: if (!WeatherController.GetInstance().weather[0]) { WeatherController.GetInstance().Frost(); ShowCards.GetInstance().card.SetTarget(WeatherController.GetInstance().grid); break; } else { goto default; } case Global.Effect.fog: if (!WeatherController.GetInstance().weather[1]) { WeatherController.GetInstance().Fog(); ShowCards.GetInstance().card.SetTarget(WeatherController.GetInstance().grid); break; } else { goto default; } case Global.Effect.rain: if (!WeatherController.GetInstance().weather[2]) { WeatherController.GetInstance().Rain(); ShowCards.GetInstance().card.SetTarget(WeatherController.GetInstance().grid); break; } else { goto default; } case Global.Effect.scorch: if (cardProperty.effect == Global.Effect.scorch) { int maxPower = 0; for (int i = 2; i < 5; i++) { for (int ii = 0; ii < PlayerController.GetInstance().grids[i].childCount; ii++) { Transform scorchCard = PlayerController.GetInstance().grids[i].GetChild(ii); if (!scorchCard.GetComponent <CardProperty>().gold) { int power = scorchCard.GetComponent <CardBehavior>().totalPower; if (power > maxPower) { maxPower = power; } } } } for (int i = 2; i < 5; i++) { for (int ii = 0; ii < EnemyController.GetInstance().grids[i].childCount; ii++) { Transform scorchCard = EnemyController.GetInstance().grids[i].GetChild(ii); if (!scorchCard.GetComponent <CardProperty>().gold) { int power = scorchCard.GetComponent <CardBehavior>().totalPower; if (power > maxPower) { maxPower = power; } } } } for (int i = 2; i < 5; i++) { for (int ii = PlayerController.GetInstance().grids[i].childCount - 1; ii >= 0; ii--) { Transform scorchCard = PlayerController.GetInstance().grids[i].GetChild(ii); if (scorchCard.GetComponent <CardBehavior>().totalPower == maxPower && !scorchCard.GetComponent <CardProperty>().gold) { scorchCard.SetTarget(PlayerController.GetInstance().grids[5]); } } } for (int i = 2; i < 5; i++) { for (int ii = EnemyController.GetInstance().grids[i].childCount - 1; ii >= 0; ii--) { Transform scorchCard = EnemyController.GetInstance().grids[i].GetChild(ii); if (scorchCard.GetComponent <CardBehavior>().totalPower == maxPower && !scorchCard.GetComponent <CardProperty>().gold) { scorchCard.SetTarget(EnemyController.GetInstance().grids[5]); } } } } goto default; case Global.Effect.dummy: ShowCards.GetInstance().Show(ShowCards.ShowBehavior.dummy, PlayerController.GetInstance().grids[2], true); return; case Global.Effect.muster: MusterController.GetInstance().Muster(); goto default; case Global.Effect.warhorn: if (cardProperty.line == Global.Line.empty) { ShowCards.GetInstance().Show(ShowCards.ShowBehavior.warhorn, PlayerController.GetInstance().grids[2], true); return; } else { WarhornController.GetInstance().playerWarhorn[(int)cardProperty.line] = true; goto default; } case Global.Effect.agile: ShowCards.GetInstance().Show(ShowCards.ShowBehavior.agile, PlayerController.GetInstance().grids[2], true); return; default: ShowCards.GetInstance().card.SetTarget(PlayerController.GetInstance().grids[(int)cardProperty.line + 2]); break; } if (cardProperty.effect == Global.Effect.nurse) { CoroutineManager.GetInstance().AddTask(TweenCard.GetInstance().Play(ShowCards.GetInstance().card)); ShowCards.GetInstance().Show(ShowCards.ShowBehavior.nurse, PlayerController.GetInstance().grids[5], true); return; } ShowCards.GetInstance().Hide(); PlayerController.GetInstance().PlayOver(ShowCards.GetInstance().card); }
public void Show(ShowBehavior behavior, Transform showGrid, bool repeat) { showBehavior = behavior; popupList.items.Clear(); popupList.AddItem("近战"); popupList.AddItem("远程"); popupList.AddItem("攻城"); OKButton.onClick.Clear(); returnButton.onClick.Clear(); EventDelegate.Add(returnButton.onClick, () => Hide()); if (!repeat) { BlackShow.GetInstance().Show(true); PlayerController.GetInstance().obj.SetActive(false); EnemyController.GetInstance().obj.SetActive(false); obj.SetActive(true); } switch (showBehavior) { case ShowBehavior.draw: label.text = "请选择要打出的牌"; goto default; case ShowBehavior.show: label.text = "显示卡牌"; goto default; case ShowBehavior.leader: label.text = "领导牌"; PlayerLeaderBehavior leaderBehavior = LeaderController.GetInstance().obj[0].GetComponent <PlayerLeaderBehavior>(); messageLabel.text = leaderBehavior.message; messageLabel.gameObject.SetActive(true); popupList.gameObject.SetActive(false); OKButton.gameObject.SetActive(true); OKButton.GetComponent <UIButton>().isEnabled = leaderBehavior.IsEnabled; EventDelegate.Add(OKButton.onClick, () => leaderBehavior.Play()); break; case ShowBehavior.replace: label.text = string.Format("请选择要替换的牌 {0}/2", replaceInt); EventDelegate.Add(returnButton.onClick, () => GameController.GetInstance().StartGame()); goto default; case ShowBehavior.nurse: label.text = "从墓地中打出卡牌"; totalGrid = showGrid; messageLabel.gameObject.SetActive(false); popupList.gameObject.SetActive(false); OKButton.gameObject.SetActive(false); EventDelegate.Add(returnButton.onClick, () => CoroutineManager.GetInstance().AddTask(EnemyController.GetInstance().Play(EnemyController.GetInstance().grids[1]))); break; case ShowBehavior.dummy: label.text = "请选择要替换的牌"; messageLabel.gameObject.SetActive(false); popupList.gameObject.SetActive(true); OKButton.gameObject.SetActive(false); break; case ShowBehavior.warhorn: label.text = "战争号角"; messageLabel.gameObject.SetActive(false); popupList.gameObject.SetActive(true); OKButton.gameObject.SetActive(true); OKButton.GetComponent <UIButton>().isEnabled = true; EventDelegate.Add(OKButton.onClick, () => WarhornController.GetInstance().Warhorn()); break; case ShowBehavior.agile: label.text = "请选择出牌的排"; messageLabel.gameObject.SetActive(false); popupList.gameObject.SetActive(true); popupList.items.Remove("攻城"); OKButton.gameObject.SetActive(true); OKButton.GetComponent <UIButton>().isEnabled = true; EventDelegate.Add(OKButton.onClick, () => AgileController.GetInstance().Agile()); break; default: totalGrid = showGrid; messageLabel.gameObject.SetActive(false); popupList.gameObject.SetActive(false); OKButton.gameObject.SetActive(false); break; } if (repeat) { grid.DestroyChildren(); } for (int i = 0; i < showGrid.childCount; i++) { GameObject cardObject = Instantiate(showGrid.GetChild(i).gameObject, grid); UISprite sprite = cardObject.GetComponent <UISprite>(); sprite.width = 250; sprite.height = 450; UIButton cardButton = cardObject.GetComponent <UIButton>(); switch (showBehavior) { case ShowBehavior.draw: EventDelegate.Add(cardButton.onClick, () => cardObject.GetComponent <CardBehavior>().Play()); cardButton.enabled = true; break; case ShowBehavior.show: cardButton.enabled = false; break; case ShowBehavior.replace: EventDelegate.Add(cardButton.onClick, () => cardObject.GetComponent <CardBehavior>().Replace()); cardButton.enabled = true; break; case ShowBehavior.nurse: EventDelegate.Add(cardButton.onClick, () => cardObject.GetComponent <CardBehavior>().Play()); cardButton.enabled = true; break; case ShowBehavior.dummy: EventDelegate.Add(cardButton.onClick, () => cardObject.GetComponent <CardBehavior>().Dummy()); cardButton.enabled = true; break; case ShowBehavior.warhorn: cardButton.enabled = false; break; case ShowBehavior.agile: cardButton.enabled = false; break; } cardObject.GetComponent <UIDragScrollView>().scrollView = scrollView; cardObject.GetComponent <BoxCollider>().size = new Vector3(250, 450, 1); } grid.GetComponent <UIGrid>().Reposition(); }
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 void Initialize(string playerGroup) { PlayerController.GetInstance().Initialize(playerGroup); EnemyController.GetInstance().Initialize(); ShowCards.GetInstance().Show(ShowCards.ShowBehavior.replace, PlayerController.GetInstance().grids[1], false); }
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)); }