private void PlayCard(CardVisual card, List <ISkillAim> aims) { CardEffect cellAimedCard = activeCard.CardAsset.CardEffects.FirstOrDefault(ce => ce.cardAim == CardEffect.CardAim.Cell); if (cellAimedCard != null) { if (cellAimedCard.cellAimType == CardEffect.CellAimType.Random) { ISkillAim[] shuffledAims = aims.OrderBy(a => Guid.NewGuid()).ToArray(); SelectAims(shuffledAims.Take(Mathf.Min(cellAimedCard.NumberOfCells, shuffledAims.Length)).ToArray()); aims = this.focusedAims; } } ActiveCard = null; NetworkCardGameManager.sInstance.RemoveCardFromHand(card.CardAsset, PhotonNetwork.player); if (card.CardAsset.DestroyAfterPlay) { card.SetState(CardVisual.CardState.Burned); } else { NetworkCardGameManager.sInstance.AddCardToDrop(card.CardAsset, PhotonNetwork.player, LocalPlayerVisual.CardAnimationAim.Hand, false); CardsManager.Instance.DropCard(card); } OnCardPlayed.Invoke(card.CardAsset); foreach (ICardEffect cardEffect in cardEffects) { cardEffect.TryToPlayCard(card.CardAsset.CardEffects, aims, () => { }); } }
public void OnPointerEnter(PointerEventData eventData) { if (!eventData.pointerDrag || CardsPlayer.Instance.ActiveCard || CardsManager.Instance.ChooseManager.Choosing) { return; } activeCardVisual = eventData.pointerDrag.GetComponent <CardVisual> (); if (activeCardVisual) { activeCardVisual.SetState(CardVisual.CardState.ChosingAim); } }
public void OnPointerExit(PointerEventData eventData) { if (CardsManager.Instance.ChooseManager.Choosing) { return; } if (activeCardVisual && (activeCardVisual.State == CardVisual.CardState.Dragging || activeCardVisual.State == CardVisual.CardState.ChosingAim) && !CardsManager.Instance.ChooseManager.Choosing) { activeCardVisual.SetState(CardVisual.CardState.Dragging); activeCardVisual = null; } }
private IEnumerator MoveCardOut(CardAnimationAim to, List <CardVisual> cards, Action <CardVisual> callback = null, bool withDelay = true) { Queue <CardVisual> movingCards = new Queue <CardVisual>(cards); while (movingCards.Count > 0) { CardVisual card = movingCards.Dequeue(); switch (to) { case CardAnimationAim.Burn: card.SetState(CardVisual.CardState.Burned); break; case CardAnimationAim.Drop: card.SetState(CardVisual.CardState.Played); break; case CardAnimationAim.Hand: card.SetState(CardVisual.CardState.Hand); break; case CardAnimationAim.Pile: Debug.Log("chose to pile"); card.SetState(CardVisual.CardState.Piled); break; case CardAnimationAim.Top: card.SetState(CardVisual.CardState.Stolen); break; } if (withDelay) { yield return(new WaitForSeconds(0.5f)); } } }
public void PlayCard(CardVisual card) { if (card.CardAsset.CardEffects.FirstOrDefault(e => e.cardAim != CardEffect.CardAim.None) != null) { if (focusedAims.Count > 0) { PlayCard(card, focusedAims); } else { card.SetState(CardVisual.CardState.Hand); } } else { PlayCard(card, focusedAims); } ActiveCard = null; }
public void DropCard(CardVisual cardVisual) { cardVisual.SetState(CardVisual.CardState.Played); CardsPlayer.Instance.DraggingCard = null; }