private IEnumerator MoveOnToStack(MoveableItem otherItem) { float y = (itemsOnTop.Count + 1) * 0.2f; Vector3 randomJitter = new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f), UnityEngine.Random.Range(0, 0.1f), 0); Vector3 stackPos = stackingLocation == null ? Vector3.zero : stackingLocation.localPosition; float elapsedTime = 0; float progress = 0; Vector3 startPos = otherItem.t.localPosition; Vector3 endPos = stackPos + new Vector3(0, y, 0) + randomJitter; while (progress <= 1) { elapsedTime += Time.deltaTime; progress = elapsedTime / MOVE_ON_TIME; otherItem.t.localPosition = Vector3.Lerp(startPos, endPos, Easing.easeInOutSine(0, 1, progress)); yield return(null); } otherItem.t.localPosition = endPos; otherItem.partOfStack = true; int previousStackValue = GetStackValue(this, itemsOnTop); itemsOnTop.Add(otherItem); int currentStackValue = GetStackValue(this, itemsOnTop); int valueDiff = currentStackValue - previousStackValue; StatUIManager.instance.Satisfaction += (valueDiff); InfoCirclePool.instance.ShowInfoCircle("Satisfaction " + ItemPanelManager.GetNumberString(valueDiff), t.position); }
private void ItemPanelClickedHandler(MoveableItem item) { mainObject.SetActive(false); Time.timeScale = 1; if (!seenItemNames.Contains(item.title)) { AlertCanvasManager.instance.ShowAlert(item.purchaseEventText); seenItemNames.Add(item.title); } InstantiateItem(item, instantiationLocation.position); if (item.purchaseSatisfaction != 0) { InfoCirclePool.instance.ShowInfoCircle("Satisfaction " + ItemPanelManager.GetNumberString(item.purchaseSatisfaction), instantiationLocation.position, Color.black, 0.4f); } }
private void CollapseStack(Vector3 collapseSource) { lastStackStatusChangeFrame = Time.frameCount; Vector3 collapseDirection = (collapseSource - t.position).normalized; for (int i = 0; i < itemsOnTop.Count; i++) { MoveableItem item = itemsOnTop[i]; item.isoSorter.Register(); item.t.SetParent(null, true); item.lastStackStatusChangeFrame = Time.frameCount; Vector3 collapseVector = (collapseDirection * 1f) * (i + 1); StartCoroutine(MoveOffOfStack(item, collapseVector)); } int stackValue = GetStackValue(this, itemsOnTop); StatUIManager.instance.Satisfaction -= stackValue; InfoCirclePool.instance.ShowInfoCircle("Satisfaction " + ItemPanelManager.GetNumberString(-stackValue), t.position, Color.red); itemsOnTop.Clear(); StatUIManager.instance.Health -= 15; InfoCirclePool.instance.ShowInfoCircle("Health -15", t.position, Color.red, 0.3f); }