public override void OnStartDrag() { savedHandSlot = whereIsTheCard.Slot; tempSTate = whereIsTheCard.VisualState; whereIsTheCard.VisualState = VisualStates.Dragging; whereIsTheCard.BringToFront(); }
// Used when the player has max cards and the drawn card needs to be show getting destroyed public void VisuallyShowCard(CardTemplate c, int UniqueID, bool fast = false, bool fromDeck = true) { GameObject card; if (fromDeck) { card = CreateACardAtPosition(c, DeckTransform.position, new Vector3(0f, -179f, 0f)); } else { card = CreateACardAtPosition(c, OtherCardDrawSourceTransform.position, new Vector3(0f, -179f, 0f)); } // Bring card to front while it travels fromd raw spot to hand WhereIsTheCard w = card.GetComponent <WhereIsTheCard>(); w.BringToFront(); w.Slot = 0; w.VisualState = VisualStates.Transition; IDHolder id = card.AddComponent <IDHolder>(); id.UniqueID = UniqueID; // Move card to the hand Sequence s = DOTween.Sequence(); { if (!fast) { // not fast s.Append(card.transform.DOMove(DrawPreviewSpot.position, GameManager.Instance.CardTransitionTimes)); if (TakeCardsOpenly) { s.Insert(0f, card.transform.DORotate(Vector3.zero, GameManager.Instance.CardTransitionTimes)); } s.AppendInterval(GameManager.Instance.CardPreviewTime); // displace the card so that we can select it in the scene easily s.Append(card.transform.DOLocalMove(slots.Slots[0].transform.localPosition, GameManager.Instance.CardTransitionTimes)); } else { // Displace the card so it can be selected in the scene more easily. s.Append(card.transform.DOLocalMove(slots.Slots[0].transform.localPosition, GameManager.Instance.CardTransitionTimes)); if (TakeCardsOpenly) { s.Insert(0f, card.transform.DORotate(Vector3.zero, GameManager.Instance.CardTransitionTimes)); } } s.OnComplete(() => ChangeLastCardStatusToInHand(card, w)); } }
public void AttackTarget(int targetUniqueID, int damageTakenByTarget, int damageTakenByAttacker, int attackHealthAfter, int targetHealthAfter) { Debug.Log(targetUniqueID); cardManager.CanAttackNow = false; GameObject target = IDHolder.GetGameObjectWithID(targetUniqueID); // Bring the creature to the front layer whereIsTheCard.BringToFront(); // Store a temp state for later VisualStates tempstate = whereIsTheCard.VisualState; // Set state to transition whereIsTheCard.VisualState = VisualStates.Transition; transform.DOMove(target.transform.position, 0.5f).SetLoops(2, LoopType.Yoyo).SetEase(Ease.InCubic).OnComplete(() => { // Which player is the target? if (targetUniqueID == GameManager.Instance.BottomPlayer.PlayerID) { // Change players values GameManager.Instance.BottomPlayer.Health = targetHealthAfter; } else if (targetUniqueID == GameManager.Instance.TopPlayer.PlayerID) { // Change players values GameManager.Instance.TopPlayer.Health = targetHealthAfter; } else { PlayedCreatureDisplay tempCardTarget = target.GetComponent <PlayedCreatureDisplay>(); tempCardTarget.HealthText.text = targetHealthAfter.ToString(); } whereIsTheCard.SetTableSortingOrder(); // revert back to the original state whereIsTheCard.VisualState = tempstate; cardManager.HealthText.text = attackHealthAfter.ToString(); Sequence s = DOTween.Sequence(); s.AppendInterval(1f); s.OnComplete(Action.ActionExecutionComplete); }); }