public void CardsFight(CardInfoScr playerCard, CardInfoScr enemyCard) { playerCard.SelfCard.GetDamage(enemyCard.SelfCard.Attack); enemyCard.SelfCard.GetDamage(playerCard.SelfCard.Attack); // проверка карт, если они выжили то оставляем и снимаем урон, если нет то удаляем if (!playerCard.SelfCard.IsAlive) { DestroyCard(playerCard); } else { playerCard.RefreshData(); } if (!enemyCard.SelfCard.IsAlive) { DestroyCard(enemyCard); } else { enemyCard.RefreshData(); } }
public void fight(CardInfoScr card1, CardInfoScr card2, int e) { card2.SelfCard.GetDamage(card1.SelfCard.Attack); if (!card2.SelfCard.IsAlive) { DestroyCard(card2, e); } else { card2.RefreshData(); } }
public void DestroyCard(CardInfoScr card) { card.GetComponent <CardMovementScr>().OnEndDrag(null); if (EnemyFieldCards.Exists(x => x == card)) { EnemyFieldCards.Remove(card); } if (PlayerFieldCards.Exists(x => x == card)) { PlayerFieldCards.Remove(card); } Destroy(card.gameObject); }
public void DamageHero(CardInfoScr card) { if (IsPlayerTurn) { EnemyHP = Mathf.Clamp(EnemyHP - card.SelfCard.Attack, 0, int.MaxValue); } else { PlayerHP = Mathf.Clamp(PlayerHP - card.SelfCard.Attack, 0, int.MaxValue); } ShowHP(); ChekForResult(); }
public void OnDrop(PointerEventData eventData) { CardInfoScr card = eventData.pointerDrag.GetComponent <CardInfoScr>(); if (card && card.SelfCard.CanAttack && transform.parent == GetComponent <CardMovementScr>().GameManager.enemyField) { card.SelfCard.ChangeAttackState(false); if (card.IsPlayer) { card.HideHighLightBG(); } GetComponent <CardMovementScr>().GameManager.CardsFight(card, GetComponent <CardInfoScr>()); } }
public void DamageHero(CardInfoScr card, bool isEnemyAttacked) { if (isEnemyAttacked) { EnemyHP = Mathf.Clamp(EnemyHP - card.SelfCard.Attack, 0, int.MaxValue); } else { PlayerHP = Mathf.Clamp(PlayerHP - card.SelfCard.Attack, 0, int.MaxValue); } ShowHP(); card.DeHighlightCard(); CheckForResult(); }
public void OnDrop(PointerEventData eventData) { if (!GameManager.IsPlayerTurn) { return; } CardInfoScr card = eventData.pointerDrag.GetComponent <CardInfoScr>(); if (card && card.SelfCard.CanAttack && Type == HeroType.ENEMY) { card.SelfCard.CanAttack = false; GameManager.DamageHero(card, true); } }
private void EnemyTurn(List <CardInfoScr> cards) { int count = Random.Range(0, cards.Count - 1); for (int i = 0; i < count; i++) { if (EnemyFieldCards.Count > 5) { return; } else { CardInfoScr currentCard = cards[0]; currentCard.ShowCardInfo(cards[0].SelfCard, false); currentCard.transform.SetParent(enemyField); EnemyHandCards.Remove(currentCard); EnemyFieldCards.Add(currentCard); } } }
public void CardsFight(CardInfoScr attackCard, CardInfoScr defenseCard) { attackCard.SelfCard.GetDamage(defenseCard.SelfCard.Attack); defenseCard.SelfCard.GetDamage(attackCard.SelfCard.Attack); if (!attackCard.SelfCard.IsAlive) { DestroyCard(attackCard); } else { attackCard.RefreshCardData(); } if (!defenseCard.SelfCard.IsAlive) { DestroyCard(defenseCard); } else { defenseCard.RefreshCardData(); } }
public void OnDrop(PointerEventData eventData) { if (!GetComponent <CardMovementScr>().GameManager.IsPlayerTurn) { return; // чтобы карты не могли ходить если не ход игрока } CardInfoScr card = eventData.pointerDrag.GetComponent <CardInfoScr>(); if (card && card.SelfCard.CanAttack && transform.parent == GetComponent <CardMovementScr>().GameManager.EnemyField) { card.SelfCard.ChageAttackState(false); if (card.IsPlayer) { card.DeHighlightedCard(); } GetComponent <CardMovementScr>().GameManager.CardsFight(card, GetComponent <CardInfoScr>()); } }
public void CardsFight(CardInfoScr playerCard, CardInfoScr enemyCard) { playerCard.SelfCard.GetDamage(enemyCard.SelfCard.Attack); enemyCard.SelfCard.GetDamage(playerCard.SelfCard.Attack); if (!playerCard.SelfCard.IsAlive) { DestroyCard(playerCard); } else { playerCard.RefreshData(); } if (!enemyCard.SelfCard.IsAlive) { DestroyCard(enemyCard); } else { enemyCard.RefreshData(); } }
public void DamageAll() { manacost = 6; damage = 3; if (GetComponent <GameManagerScr>().PlayerManapool < manacost) { return; } else { GetComponent <GameManagerScr>().PlayerManapool = Mathf.Clamp(GetComponent <GameManagerScr>().PlayerManapool - manacost, 0, int.MaxValue); } GetComponent <GameManagerScr>().ShowMana(); if (GetComponent <GameManagerScr>().EnemyFieldCards.Count > 0 && GetComponent <GameManagerScr>().IsPlayerTurn) { if (GetComponent <GameManagerScr>().EnemyFieldCard1.Count == 1) { CardInfoScr card1 = GetComponent <GameManagerScr>().EnemyFieldCard1[0].GetComponent <CardInfoScr>(); card1.SelfCard.GetDamage(damage); if (!card1.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard1.Remove(card1); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card1); Destroy(card1.gameObject); } else { card1.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard2.Count == 1) { CardInfoScr card2 = GetComponent <GameManagerScr>().EnemyFieldCard2[0].GetComponent <CardInfoScr>(); card2.SelfCard.GetDamage(damage); if (!card2.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard2.Remove(card2); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card2); Destroy(card2.gameObject); } else { card2.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard3.Count == 1) { CardInfoScr card3 = GetComponent <GameManagerScr>().EnemyFieldCard3[0].GetComponent <CardInfoScr>(); card3.SelfCard.GetDamage(damage); if (!card3.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard3.Remove(card3); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card3); Destroy(card3.gameObject); } else { card3.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard4.Count == 1) { CardInfoScr card4 = GetComponent <GameManagerScr>().EnemyFieldCard4[0].GetComponent <CardInfoScr>(); card4.SelfCard.GetDamage(damage); if (!card4.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard4.Remove(card4); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card4); Destroy(card4.gameObject); } else { card4.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard5.Count == 1) { CardInfoScr card5 = GetComponent <GameManagerScr>().EnemyFieldCard5[0].GetComponent <CardInfoScr>(); card5.SelfCard.GetDamage(damage); if (!card5.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard5.Remove(card5); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card5); Destroy(card5.gameObject); } else { card5.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard6.Count == 1) { CardInfoScr card6 = GetComponent <GameManagerScr>().EnemyFieldCard6[0].GetComponent <CardInfoScr>(); card6.SelfCard.GetDamage(damage); if (!card6.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard6.Remove(card6); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card6); Destroy(card6.gameObject); } else { card6.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard7.Count == 1) { CardInfoScr card7 = GetComponent <GameManagerScr>().EnemyFieldCard7[0].GetComponent <CardInfoScr>(); card7.SelfCard.GetDamage(damage); if (!card7.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard7.Remove(card7); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card7); Destroy(card7.gameObject); } else { card7.RefreshData(); } } if (GetComponent <GameManagerScr>().EnemyFieldCard8.Count == 1) { CardInfoScr card8 = GetComponent <GameManagerScr>().EnemyFieldCard8[0].GetComponent <CardInfoScr>(); card8.SelfCard.GetDamage(damage); if (!card8.SelfCard.IsAlive) { GetComponent <GameManagerScr>().EnemyFieldCard8.Remove(card8); GetComponent <GameManagerScr>().EnemyFieldCards.Remove(card8); Destroy(card8.gameObject); } else { card8.RefreshData(); } } } }
void DestroyCard(CardInfoScr card, int e) { if (IsPlayerTurn) { if (e == 1) { EnemyFieldCard1.Remove(card); } if (e == 2) { EnemyFieldCard2.Remove(card); } if (e == 3) { EnemyFieldCard3.Remove(card); } if (e == 4) { EnemyFieldCard4.Remove(card); } if (e == 5) { EnemyFieldCard5.Remove(card); } if (e == 6) { EnemyFieldCard6.Remove(card); } if (e == 7) { EnemyFieldCard7.Remove(card); } if (e == 8) { EnemyFieldCard8.Remove(card); } EnemyFieldCards.Remove(card); } else { if (e == 1) { PlayerFieldCard1.Remove(card); } if (e == 2) { PlayerFieldCard2.Remove(card); } if (e == 3) { PlayerFieldCard3.Remove(card); } if (e == 4) { PlayerFieldCard4.Remove(card); } if (e == 5) { PlayerFieldCard5.Remove(card); } if (e == 6) { PlayerFieldCard6.Remove(card); } if (e == 7) { PlayerFieldCard7.Remove(card); } if (e == 8) { PlayerFieldCard8.Remove(card); } PlayerFieldCards.Remove(card); } Destroy(card.gameObject); }
public void CardsFight() { if (IsPlayerTurn) { if (PlayerFieldCard1.Count == 1 && EnemyFieldCard1.Count == 1) { CardInfoScr cardP1 = PlayerFieldCard1[0].GetComponent <CardInfoScr>(); CardInfoScr cardE1 = EnemyFieldCard1[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField1); fight(cardP1, cardE1, 1); } else if (PlayerFieldCard1.Count == 1 && EnemyFieldCard1.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP1 = PlayerFieldCard1[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField1); DamageHero(cardP1); } if (PlayerFieldCard2.Count == 1 && EnemyFieldCard2.Count == 1) { CardInfoScr cardP2 = PlayerFieldCard2[0].GetComponent <CardInfoScr>(); CardInfoScr cardE2 = EnemyFieldCard2[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField2); fight(cardP2, cardE2, 2); } else if (PlayerFieldCard2.Count == 1 && EnemyFieldCard2.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP2 = PlayerFieldCard2[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField2); DamageHero(cardP2); } if (PlayerFieldCard3.Count == 1 && EnemyFieldCard3.Count == 1) { CardInfoScr cardP3 = PlayerFieldCard3[0].GetComponent <CardInfoScr>(); CardInfoScr cardE3 = EnemyFieldCard3[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField3); fight(cardP3, cardE3, 3); } else if (PlayerFieldCard3.Count == 1 && EnemyFieldCard3.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP3 = PlayerFieldCard3[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField3); DamageHero(cardP3); } if (PlayerFieldCard4.Count == 1 && EnemyFieldCard4.Count == 1) { CardInfoScr cardP4 = PlayerFieldCard4[0].GetComponent <CardInfoScr>(); CardInfoScr cardE4 = EnemyFieldCard4[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField4); fight(cardP4, cardE4, 4); } else if (PlayerFieldCard4.Count == 1 && EnemyFieldCard4.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP4 = PlayerFieldCard4[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField4); DamageHero(cardP4); } if (PlayerFieldCard5.Count == 1 && EnemyFieldCard5.Count == 1) { CardInfoScr cardP5 = PlayerFieldCard5[0].GetComponent <CardInfoScr>(); CardInfoScr cardE5 = EnemyFieldCard5[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField5); fight(cardP5, cardE5, 5); } else if (PlayerFieldCard5.Count == 1 && EnemyFieldCard5.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP5 = PlayerFieldCard5[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField5); DamageHero(cardP5); } if (PlayerFieldCard6.Count == 1 && EnemyFieldCard6.Count == 1) { CardInfoScr cardP6 = PlayerFieldCard6[0].GetComponent <CardInfoScr>(); CardInfoScr cardE6 = EnemyFieldCard6[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField6); fight(cardP6, cardE6, 6); } else if (PlayerFieldCard6.Count == 1 && EnemyFieldCard6.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP6 = PlayerFieldCard6[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField6); DamageHero(cardP6); } if (PlayerFieldCard7.Count == 1 && EnemyFieldCard7.Count == 1) { CardInfoScr cardP7 = PlayerFieldCard7[0].GetComponent <CardInfoScr>(); CardInfoScr cardE7 = EnemyFieldCard7[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField7); fight(cardP7, cardE7, 7); } else if (PlayerFieldCard7.Count == 1 && EnemyFieldCard7.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP7 = PlayerFieldCard7[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField7); DamageHero(cardP7); } if (PlayerFieldCard8.Count == 1 && EnemyFieldCard8.Count == 1) { CardInfoScr cardP8 = PlayerFieldCard8[0].GetComponent <CardInfoScr>(); CardInfoScr cardE8 = EnemyFieldCard8[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField8); fight(cardP8, cardE8, 8); } else if (PlayerFieldCard8.Count == 1 && EnemyFieldCard8.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardP8 = PlayerFieldCard8[0].GetComponent <CardInfoScr>(); // GetComponent<Animation>().attack(GetComponent<Animation>().Sword, PlayerField8); DamageHero(cardP8); } } else { if (PlayerFieldCard1.Count == 1 && EnemyFieldCard1.Count == 1) { CardInfoScr cardP1 = PlayerFieldCard1[0].GetComponent <CardInfoScr>(); CardInfoScr cardE1 = EnemyFieldCard1[0].GetComponent <CardInfoScr>(); fight(cardE1, cardP1, 1); } else if (EnemyFieldCard1.Count == 1 && PlayerFieldCard1.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE1 = EnemyFieldCard1[0].GetComponent <CardInfoScr>(); DamageHero(cardE1); } if (PlayerFieldCard2.Count == 1 && EnemyFieldCard2.Count == 1) { CardInfoScr cardP2 = PlayerFieldCard2[0].GetComponent <CardInfoScr>(); CardInfoScr cardE2 = EnemyFieldCard2[0].GetComponent <CardInfoScr>(); fight(cardE2, cardP2, 2); } else if (EnemyFieldCard2.Count == 1 && PlayerFieldCard2.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE2 = EnemyFieldCard2[0].GetComponent <CardInfoScr>(); DamageHero(cardE2); } if (PlayerFieldCard3.Count == 1 && EnemyFieldCard3.Count == 1) { CardInfoScr cardP3 = PlayerFieldCard3[0].GetComponent <CardInfoScr>(); CardInfoScr cardE3 = EnemyFieldCard3[0].GetComponent <CardInfoScr>(); fight(cardE3, cardP3, 3); } else if (EnemyFieldCard3.Count == 1 && PlayerFieldCard3.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE3 = EnemyFieldCard3[0].GetComponent <CardInfoScr>(); DamageHero(cardE3); } if (PlayerFieldCard4.Count == 1 && EnemyFieldCard4.Count == 1) { CardInfoScr cardP4 = PlayerFieldCard4[0].GetComponent <CardInfoScr>(); CardInfoScr cardE4 = EnemyFieldCard4[0].GetComponent <CardInfoScr>(); fight(cardE4, cardP4, 4); } else if (EnemyFieldCard4.Count == 1 && PlayerFieldCard4.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE4 = EnemyFieldCard4[0].GetComponent <CardInfoScr>(); DamageHero(cardE4); } if (PlayerFieldCard5.Count == 1 && EnemyFieldCard5.Count == 1) { CardInfoScr cardP5 = PlayerFieldCard5[0].GetComponent <CardInfoScr>(); CardInfoScr cardE5 = EnemyFieldCard5[0].GetComponent <CardInfoScr>(); fight(cardE5, cardP5, 5); } else if (EnemyFieldCard5.Count == 1 && PlayerFieldCard5.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE5 = EnemyFieldCard5[0].GetComponent <CardInfoScr>(); DamageHero(cardE5); } if (PlayerFieldCard6.Count == 1 && EnemyFieldCard6.Count == 1) { CardInfoScr cardP6 = PlayerFieldCard6[0].GetComponent <CardInfoScr>(); CardInfoScr cardE6 = EnemyFieldCard6[0].GetComponent <CardInfoScr>(); fight(cardE6, cardP6, 6); } else if (EnemyFieldCard6.Count == 1 && PlayerFieldCard6.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE6 = EnemyFieldCard6[0].GetComponent <CardInfoScr>(); DamageHero(cardE6); } if (PlayerFieldCard7.Count == 1 && EnemyFieldCard7.Count == 1) { CardInfoScr cardP7 = PlayerFieldCard7[0].GetComponent <CardInfoScr>(); CardInfoScr cardE7 = EnemyFieldCard7[0].GetComponent <CardInfoScr>(); fight(cardE7, cardP7, 7); } else if (EnemyFieldCard7.Count == 1 && PlayerFieldCard7.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE7 = EnemyFieldCard7[0].GetComponent <CardInfoScr>(); DamageHero(cardE7); } if (PlayerFieldCard8.Count == 1 && EnemyFieldCard8.Count == 1) { CardInfoScr cardP8 = PlayerFieldCard8[0].GetComponent <CardInfoScr>(); CardInfoScr cardE8 = EnemyFieldCard8[0].GetComponent <CardInfoScr>(); fight(cardE8, cardP8, 8); } else if (EnemyFieldCard8.Count == 1 && PlayerFieldCard8.Count == 0) { if (chekWin == "WIN" || chekWin == "Lose") { return; } CardInfoScr cardE8 = EnemyFieldCard8[0].GetComponent <CardInfoScr>(); DamageHero(cardE8); } } }