private void PlayCardCompleteHandler(WorkingCard card, object target) { WorkingCard workingCard = _gameplayManager.OpponentPlayer.CardsOnBoard[_gameplayManager.OpponentPlayer.CardsOnBoard.Count - 1]; switch (card.LibraryCard.CardKind) { case Enumerators.CardKind.CREATURE: { BoardUnit boardUnitElement = new BoardUnit(GameObject.Find("OpponentBoard").transform); GameObject boardCreature = boardUnitElement.GameObject; boardCreature.tag = SRTags.OpponentOwned; boardCreature.transform.position = Vector3.zero; boardUnitElement.OwnerPlayer = card.Owner; boardUnitElement.SetObjectInfo(workingCard); _battlegroundController.OpponentBoardCards.Add(boardUnitElement); boardCreature.transform.position += Vector3.up * 2f; // Start pos before moving cards to the opponents board // PlayArrivalAnimation(boardCreature, libraryCard.cardType); _gameplayManager.OpponentPlayer.BoardCards.Add(boardUnitElement); _actionsQueueController.PostGameActionReport(_actionsQueueController.FormatGameActionReport( Enumerators.ActionType.PLAY_UNIT_CARD, new object[] { boardUnitElement.OwnerPlayer, boardUnitElement })); boardUnitElement.PlayArrivalAnimation(); _battlegroundController.UpdatePositionOfBoardUnitsOfOpponent( () => { bool createTargetArrow = false; if (card.LibraryCard.Abilities != null && card.LibraryCard.Abilities.Count > 0) { createTargetArrow = _abilitiesController.IsAbilityCanActivateTargetAtStart( card.LibraryCard.Abilities[0]); } if (target != null) { CreateOpponentTarget( createTargetArrow, false, boardCreature.gameObject, target, () => { _abilitiesController.CallAbility(card.LibraryCard, null, workingCard, Enumerators.CardKind.CREATURE, boardUnitElement, null, false, null, target); }); } else { _abilitiesController.CallAbility(card.LibraryCard, null, workingCard, Enumerators.CardKind.CREATURE, boardUnitElement, null, false, null); } }); break; } case Enumerators.CardKind.SPELL: { GameObject spellCard = Object.Instantiate(_cardsController.SpellCardViewPrefab); spellCard.transform.position = GameObject.Find("OpponentSpellsPivot").transform.position; CurrentSpellCard = new SpellBoardCard(spellCard); CurrentSpellCard.Init(workingCard); CurrentSpellCard.SetHighlightingEnabled(false); BoardSpell boardSpell = new BoardSpell(spellCard, workingCard); spellCard.gameObject.SetActive(false); bool createTargetArrow = false; if (card.LibraryCard.Abilities != null && card.LibraryCard.Abilities.Count > 0) { createTargetArrow = _abilitiesController.IsAbilityCanActivateTargetAtStart(card.LibraryCard.Abilities[0]); } if (target != null) { CreateOpponentTarget( createTargetArrow, false, _gameplayManager.OpponentPlayer.AvatarObject, target, () => { _abilitiesController.CallAbility(card.LibraryCard, null, workingCard, Enumerators.CardKind.SPELL, boardSpell, null, false, null, target); }); } else { _abilitiesController.CallAbility(card.LibraryCard, null, workingCard, Enumerators.CardKind.SPELL, boardSpell, null, false, null); } break; } } }
public void PlayPlayerCard(Player player, BoardCard card, HandBoardCard handCard) { if (card.CanBePlayed(card.WorkingCard.Owner)) { Card libraryCard = card.WorkingCard.LibraryCard; card.Transform.DORotate(Vector3.zero, .1f); card.HandBoardCard.Enabled = false; _soundManager.PlaySound(Enumerators.SoundType.CARD_FLY_HAND_TO_BATTLEGROUND, Constants.CardsMoveSoundVolume); player.ThrowPlayCardEvent(card.WorkingCard); switch (libraryCard.CardKind) { case Enumerators.CardKind.CREATURE: { int indexOfCard = 0; float newCreatureCardPosition = card.Transform.position.x; // set correct position on board depends from card view position for (int i = 0; i < player.BoardCards.Count; i++) { if (newCreatureCardPosition > player.BoardCards[i].Transform.position.x) { indexOfCard = i + 1; } else { break; } } BoardUnit boardUnit = new BoardUnit(_playerBoard.transform); boardUnit.Transform.tag = SRTags.PlayerOwned; boardUnit.Transform.parent = _playerBoard.transform; boardUnit.Transform.position = new Vector2(1.9f * player.BoardCards.Count, 0); boardUnit.OwnerPlayer = card.WorkingCard.Owner; boardUnit.SetObjectInfo(card.WorkingCard); _battlegroundController.PlayerHandCards.Remove(card); _battlegroundController.PlayerBoardCards.Add(boardUnit); player.AddCardToBoard(card.WorkingCard); player.RemoveCardFromHand(card.WorkingCard); player.BoardCards.Insert(indexOfCard, boardUnit); _timerManager.AddTimer( creat => { card.WorkingCard.Owner.GraveyardCardsCount++; }); card.RemoveCardParticle.Play(); _actionsQueueController.PostGameActionReport(_actionsQueueController.FormatGameActionReport( Enumerators.ActionType.PLAY_UNIT_CARD, new object[] { boardUnit.OwnerPlayer, boardUnit })); UpdateCardsStatusEvent?.Invoke(player); Sequence animationSequence = DOTween.Sequence(); animationSequence.Append(card.Transform.DOScale(new Vector3(.27f, .27f, .27f), 1f)); animationSequence.OnComplete( () => { RemoveCard(new object[] { card }); _timerManager.AddTimer( param => { boardUnit.PlayArrivalAnimation(); _battlegroundController.UpdatePositionOfBoardUnitsOfPlayer( _gameplayManager.CurrentPlayer.BoardCards, () => { _abilitiesController.CallAbility(libraryCard, card, card.WorkingCard, Enumerators.CardKind.CREATURE, boardUnit, CallCardPlay, true, null); }); }, null, 0.1f); }); player.Goo -= card.ManaCost; _tutorialManager.ReportAction(Enumerators.TutorialReportAction.MOVE_CARD); break; } case Enumerators.CardKind.SPELL: { player.CardsInHand.Remove(card.WorkingCard); _battlegroundController.PlayerHandCards.Remove(card); _battlegroundController.UpdatePositionOfCardsInPlayerHand(); card.GameObject.GetComponent <SortingGroup>().sortingLayerID = SRSortingLayers.BoardCards; card.GameObject.GetComponent <SortingGroup>().sortingOrder = 1000; BoardSpell boardSpell = new BoardSpell(card.GameObject, card.WorkingCard); boardSpell.Transform.position = Vector3.zero; _abilitiesController.CallAbility(libraryCard, card, card.WorkingCard, Enumerators.CardKind.SPELL, boardSpell, CallSpellCardPlay, true, null, handCard: handCard); break; } default: throw new ArgumentOutOfRangeException(); } } else { card.HandBoardCard.ResetToInitialPosition(); } }