IEnumerator showCardCrt(Card card, bool fromTop) { showCardFinished = false; TransformManager tm = card.TransformManager; tm.ClearQueue(); tm.Lock(); // set starting location if (fromTop) { card.transform.position = new Vector3(0, 10); } else { card.transform.position = new Vector3(0, -10); } // move to center of screen Transform cardTransform = card.TransformManager.transform; Vector3 target = new Vector3(0, 0); while (Vector3.Distance(target, cardTransform.position) > 0.02f) { cardTransform.position = Vector3.Lerp(cardTransform.position, target, 15f * Time.deltaTime); yield return(null); } // TODO play animation/sound // pause yield return(new WaitForSeconds(.3f)); // flip bool to signal finished tm.UnLock(); showCardFinished = true; }
IEnumerator ResizeToCreature(Vector3 newPosition) { restingTransform.ClearQueue(); restingTransform.Lock(); resizeToCreatureFinished = false; Vector3 positionStart = restingTransform.transform.position; Vector3 positionEnd = newPosition; Vector3 scaleStart = restingTransform.transform.localScale; Vector3 scaleEnd = Vector3.one * scaleWhenPermanent; Vector3 offsetPosStart = offsetTransform.transform.localPosition; Vector3 offsetScaleStart = offsetTransform.transform.localScale; // --- temporary --- restingTransform.SetTransform(new TransformStruct() { localScale = scaleEnd, position = newPosition, useLocalPosition = false, rotation = Vector3.zero }); yield break; // ----------------- // resize root float currentPercentage = 0; float timePassed = 0; while (currentPercentage < .98f) { timePassed += Time.deltaTime; currentPercentage = timePassed / timeForShrinkAnimation; restingTransform.transform.position = Vector3.Lerp(positionStart, positionEnd, currentPercentage); restingTransform.transform.localScale = Vector3.Lerp(scaleStart, scaleEnd, currentPercentage); offsetTransform.transform.localPosition = Vector3.Lerp(offsetPosStart, Vector3.zero, currentPercentage); offsetTransform.transform.localScale = Vector3.Lerp(offsetScaleStart, Vector3.one, currentPercentage); yield return(null); } // pause yield return(new WaitForSeconds(pauseBetweenResize)); // resize icons Vector3 targetIconScale = Vector3.one * iconScaleWhenPermanent; while (Vector3.Distance(iconsToResize[0].transform.localScale, targetIconScale) > 0.02f) { foreach (Transform t in iconsToResize) { t.localScale = Vector3.MoveTowards(t.localScale, targetIconScale, iconResizeSpeed * Time.deltaTime); } yield return(null); } FofBorder.SetActive(true); resizeToCreatureFinished = true; restingTransform.UnLock(); }
public void OnPointerDown(PointerEventData eventData) { transformManager.ClearQueue(); transformManager.Lock(); }