public void DoDrop(CardGameObject cardGO) { currentValue++; cardGO.transform.position = this.transform.position + (Vector3.back * currentValue); cardGO.transform.SetParent(this.transform); SuitedDescendingDropReceiver sourceDrop = cardGO.GetComponent <SuitedDescendingDropReceiver>(); if (sourceDrop != null) { Destroy(cardGO.GetComponent <SuitedDescendingDropReceiver>()); } }
public void SelectCard(CardGameObject cardGO, Player player) { // Player has selected a card from the hand. // If it is not player's turn, do nothing. if (turn != TurnSelection.Players) { return; } // From here on, it's player's turn. // Ignore if the player does not have enough mana to play the card. if (cardGO.card.manaCost > player.mana) { return; } // Hide buttons for targetting. HideTargettingButtons(); stayUp = true; currentCardOwner = player; currentSelectedCard = cardGO; foreach (var c in coroutines) { StopCoroutine(c); } player.hand.SelectCard(cardGO.GetComponent <CardInHand>()); player.hand.RecalculateCardsPosition(); coroutines.Add(StartCoroutine(SelectCardCoro(cardGO))); }
public void DoDrop(CardGameObject cardGO) { cardGO.transform.position = this.transform.position + (Vector3.back * 10); cardGO.transform.SetParent(this.transform); if (cardGO.transform.childCount == 0 && cardGO.GetComponent <IDroppable>() == null) { cardGO.AddDropReceiver(); } }
public void DoDrop(CardGameObject cardGO) { cardGO.transform.position = this.transform.position - new Vector3(0, Solitaire.GameManager.YOffset, Solitaire.GameManager.ZOffset); cardGO.transform.SetParent(this.transform); if (cardGO.transform.childCount == 0 && cardGO.GetComponent <IDroppable>() == null) { cardGO.AddDropReceiver(); } }
public CardActions getCardInHandActions(CardGameObject cardGameObject) { CardActions actions = new CardActions(); copyOverActions(cardGameObject, actions); Card card = cardGameObject.card; CardData data = card.data; Transform transform = cardGameObject.transform; bool isDragging = false; bool isHovering = false; Vector3 startPosition = new Vector3(0, 0); GameObject backgroundImage = cardGameObject.transform.Find("cardBackground").gameObject; int yPositionForCardPlay = -250; actions.onDragStartAction = () => { card.data.targetedEnemy = null; if (startPosition == null) { startPosition = cardGameObject.transform.position; } if (!(deckService.isCardPlayable(cardGameObject.card) && playerService.isCardPlayable(cardGameObject.card))) { backgroundImage.GetComponent <Image>().color = ColorUtils.cardUnplayable; return; } isDragging = true; }; actions.onDragEndAction = () => { isDragging = false; EnemyGameObject target = card.data.targetedEnemy; if (data.playerCardData.needsTarget && transform.position.y >= yPositionForCardPlay && target != null) { cardService.onCardPlayed(card); target.onNotTargeted(); card.data.targetedEnemy = null; GameObject.Destroy(cardGameObject.gameObject); } else if (!data.playerCardData.needsTarget && transform.position.y >= yPositionForCardPlay) { cardService.onCardPlayed(card); GameObject.Destroy(cardGameObject.gameObject); } else { if (target != null) { target.onNotTargeted(); card.data.targetedEnemy = null; } backgroundImage.GetComponent <Image>().color = ColorUtils.none; if (transform.position != startPosition) { transform.localScale -= new Vector3(0.4f, 0.4f, 0); transform.position = startPosition; } } }; actions.onUpdateAction = () => { if (!isDragging || data.isEnemycard) { return; } EnemyGameObject target = card.data.targetedEnemy; if (transform.position.y >= yPositionForCardPlay && (!data.playerCardData.needsTarget || data.playerCardData.needsTarget && target != null)) { backgroundImage.GetComponent <Image>().color = ColorUtils.cardPlayedGreen; if (target != null) { target.onTargeted(); } } else { backgroundImage.GetComponent <Image>().color = ColorUtils.white; if (target != null) { target.onNotTargeted(); } } RectTransform playerHandTransform = transform.parent.GetComponent <RectTransform>(); transform.localPosition = new Vector2(Input.mousePosition.x - Screen.width / 2, Input.mousePosition.y - playerHandTransform.rect.height / 2); }; actions.onTriggerEnter2DAction = (Collider2D other) => { if (data.playerCardData.needsTarget) { EnemyGameObject curr = other.transform.gameObject.GetComponent <EnemyGameObject>(); if (curr != null) { card.data.targetedEnemy = curr; curr.onTargeted(); } } }; actions.onTriggerExit2DAction = (Collider2D other) => { EnemyGameObject target = card.data.targetedEnemy; if (target != null) { target.onNotTargeted(); } card.data.targetedEnemy = null; }; actions.onHoverEnter = () => { if (isHovering) { return; } startPosition = transform.position; transform.position += new Vector3(0, 140, 0); transform.localScale += new Vector3(0.4f, 0.4f, 0); cardGameObject.GetComponent <Canvas>().overrideSorting = true; cardGameObject.GetComponent <Canvas>().sortingOrder = 10; cardGameObject.GetComponent <Canvas>().sortingLayerName = "UI"; isHovering = true; }; actions.onHoverExit = () => { if (transform.position != startPosition) { transform.position -= new Vector3(0, 140, 0); transform.localScale -= new Vector3(0.4f, 0.4f, 0); } cardGameObject.GetComponent <Canvas>().overrideSorting = false; isHovering = false; }; return(actions); }
IEnumerator SelectTargets(CardGameObject cardGO, System.Action <CardInHand> SelectCardCallback, System.Action RecalculateCardsPositionCallback) { PlayerCombatObject playerOnTurn = currentCardOwner; HealthEntityCombatObject caster = playerOnTurn; stepNumber = 0; targetsPerAbilityStep = new List <List <HealthEntityCombatObject> >(); AbilityStepsWithTargetingData_Player[] abilities = cardGO.card.abilityStepsWithTargetingData; // Let's cycle through all ability steps in order to determine targets. foreach (var abilityStepWithTargetingData in abilities) { chosenTargets = new List <HealthEntityCombatObject>(); targetFound = false; TargetData targetData = GetValidTargets(caster, abilityStepWithTargetingData.targetingData); if (targetData.multipleSpecificMode) { multipleSpecificMode = true; numberOfSpecificTargets = targetData.multipleSpecificNumber; multipleSpecificModeList = new List <HealthEntityCombatObject>(); } else { multipleSpecificMode = false; } if (targetData.previousStepTargets > -1) { targetFound = true; foreach (var entity in targetsPerAbilityStep[targetData.previousStepTargets]) { chosenTargets.Add(entity); } } else if (targetData.targetDecided) { targetFound = true; foreach (var e in targetData.entities) { chosenTargets.Add(e); } } else { if (targetData.entities.Count == 1 && targetData.entities[0] is PlayerCombatObject) { targetFound = true; chosenTargets.Add(targetData.entities[0]); } else { SelectCardCallback(cardGO.GetComponent <CardInHand>()); RecalculateCardsPositionCallback(); infoText.text = abilityStepWithTargetingData.targetingData.textForChoosing; ShowTargetingButton(targetData.entities); } } while (targetFound == false) { yield return(null); } stepNumber++; targetsPerAbilityStep.Add(chosenTargets); } // We have all chosen targets. // We now have to check whether any of those are multiple hits. for (int i = 0; i < targetsPerAbilityStep.Count; i++) { TargetingData_Base targetingData = cardGO.card.abilityStepsWithTargetingData[i].targetingData; if (targetingData.targetAlignment == TargetingData_Base.TargetAlignment.Hostile) { if (targetingData.targets == TargetingData_Base.Target.Multiple) { EnemyCombatObject chosenTarget = (EnemyCombatObject)targetsPerAbilityStep[i][0]; List <EnemyCombatObject> nearbyEnemies = GetNearbyEnemies(chosenTarget, targetingData.numberOfTargets); foreach (var e in nearbyEnemies) { targetsPerAbilityStep[i].Add(e); } } } } // Now we have full lists of all targets for each attribute. // Let's do the card trick. DoCardTrick(); yield return(null); }
public void DropCard(CardGameObject card, bool stayUp) { hand.DropCard(card.GetComponent <CardInHand>(), stayUp); RefreshUI(); }
public void DropCard(CardGameObject card, bool stayUp) { DropCard(card.GetComponent <CardInHand>(), stayUp); }