IEnumerator OnMouseExit() { MouseHoveringOver = null; if (SlotContent != null) slotContent.transform.localRotation = Quaternion.Euler(new Vector3(0, 90, 0)); if (ShopItemsHookedTo != this) { StopCoroutine("OnMouseEnter"); StopCoroutine("OnMouseDown"); while (time > 0) { SlotAnimateAt(time -= Time.smoothDeltaTime * 2f); yield return new WaitForEndOfFrame(); } } }
IEnumerator OnMouseDown() { StopCoroutine("OnMouseEnter"); ShopItemsHookedTo = this; ShopItems.gameObject.SetActiveRecursively(true); shopInstance.ResetShopItems(); Vector3 newPosition = transform.localPosition; newPosition.z = -12f; ShopItems.localPosition = newPosition; if (SlotContent != null) slotContent.transform.localRotation = Quaternion.Euler(new Vector3(0, 90, 0)); Vector3 tempPosition = initialPosition; Vector3 tempScale = initialScale; slotColor.a = 0.3f; SlotAnimateAt(1f); while (true) { if (ShopItemsHookedTo != this) { StartCoroutine(OnMouseExit()); break; } transform.localScale = Vector3.Lerp(transform.localScale, tempScale + Vector3.right * 2.5f + Vector3.up * 2.5f, Time.smoothDeltaTime * 10f); transform.localPosition = Vector3.Lerp(transform.localPosition, tempPosition + Vector3.back * 6f, Time.smoothDeltaTime * 10f); yield return new WaitForEndOfFrame(); } }
IEnumerator OnMouseEnter() { if (ShopItemsHookedTo != this) { MouseHoveringOver = this; StopCoroutine("OnMouseExit"); StopCoroutine("OnMouseDown"); while (time < 1) { SlotAnimateAt(time += Time.smoothDeltaTime * 3f); yield return new WaitForEndOfFrame(); } // Start flickering Vector3 tempScale = transform.localScale; float tempTime = 0.05f; while (true) { if (tempTime > 0.9f) { tempTime = 0; } tempTime += Time.smoothDeltaTime; curveEvalution = TileMouseOverCurve.Evaluate(tempTime) * 20f; transform.localScale = tempScale + Vector3.right * curveEvalution + Vector3.up * curveEvalution; if(SlotContent != null) SlotContent.transform.Rotate(0,Time.smoothDeltaTime * 200f, 0); yield return new WaitForEndOfFrame(); } } }