public void SpawnNumber(int number, Color c) { GameObject damageNumber = pool.GetObject(); ((RectTransform)damageNumber.transform).anchoredPosition = new Vector2(0, 0); TextMeshProUGUI tmpugui = damageNumber.GetComponent <TextMeshProUGUI>(); tmpugui.SetText(number.ToString()); tmpugui.faceColor = c; Color outline = Color.black; UpdateTimer ut = timers.Get(); ut.Start(2, () => { // finish pool.Return(damageNumber); timers.Return(ut); }, (percentComplete) => { // update c.a = 1 - percentComplete; tmpugui.faceColor = c; outline.a = c.a; tmpugui.outlineColor = outline; }); }
IEnumerator ScrollOff(GameObject go) { RectTransform rt = go.GetComponent <RectTransform>(); Image im = go.GetComponent <Image>(); float grayness = 1f; im.color = new Color(grayness, grayness, grayness, 1); while (rt.anchoredPosition.x > EndingPosition) { if (grayness > 0.6f) { im.color = new Color(grayness, grayness, grayness, 1); grayness -= 0.8f * Time.deltaTime; } if (Scrolling) { Vector3 pos = rt.anchoredPosition; pos.x -= ScrollSpeed * Time.deltaTime; rt.anchoredPosition = pos; } yield return(null); } DeadEnemies.Return(go); }
private void OnClick(ItemDropBubble it, Action onClick, Action onDone) { SmoothPopUpManager.ShowPopUp(it.transform.localPosition, $"<color=green>+1</color> {it.Item.GetName()}", ConfigObject.GetColorFromRarity(it.Item.Rarity)); if (!EquipItemProcessor.Instance.ProcessItem(it.Item, () => { Pool.Return(it.gameObject); onClick?.Invoke(); })) { SoundManager.Instance.PlaySound(SoundManager.Instance.PickUp, 1); } }
// Update is called once per frame void Update() { if (IsScrolling) { float scrollSpeed = ScrollSpeed; for (int i = 0; i < nextSpawnDistance.Count; i++) { nextSpawnDistance[i] -= scrollSpeed * Time.deltaTime; if (nextSpawnDistance[i] <= 0) { MiningPoint point = areaPoints[i]; GameObject go = Pool.GetObject(); Image im = go.GetComponent <Image>(); im.sprite = point.Image; im.SetNativeSize(); AddListener(go.GetComponent <ClickReceiver>(), point); Vector3 pos = go.transform.localPosition; pos.x = 79; go.transform.localPosition = pos; nextSpawnDistance[i] = Random.Range(point.MinDistanceBetween, point.MaxDistanceBetween); } } foreach (var point in Pool.InUse.ToArray()) { Vector3 pos = point.transform.localPosition; pos.x -= scrollSpeed * Time.deltaTime; if (pos.x <= ReturnToPoolXValue) { Pool.Return(point); } point.transform.localPosition = pos; } } }
void Update() { foreach (var data in currentLerpers.ToList()) { data.Time += Time.deltaTime; if (OpacityCurve.keys[OpacityCurve.length - 1].time <= data.Time) { currentLerpers.Remove(data); popUpPool.Return(data.PopUpText.gameObject); continue; } data.PopUpText.alpha = OpacityCurve.Evaluate(data.Time); Vector3 pos = data.PopUpPosition.anchoredPosition; pos.y = data.StartY + HeightCurve.Evaluate(data.Time); data.PopUpPosition.anchoredPosition = pos; } }