/// <summary> /// 根据对象池名称回收游戏对象 /// </summary> /// <param name="poolName"></param> /// <param name="go"></param> public void Recyle(string poolName, GameObject go) { if (m_GameObjectPools.ContainsKey(poolName)) { GameObjectPool pool = m_GameObjectPools[poolName]; pool.RecyleToPool(go); } else { Debug.LogWarning("No pool available with name: " + poolName); } }
static int RecyleToPool(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); Framework.GameObjectPool obj = (Framework.GameObjectPool)ToLua.CheckObject <Framework.GameObjectPool>(L, 1); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject)); obj.RecyleToPool(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 显示减血Tips /// </summary> /// <param name="content">内容</param> /// <param name="pos">位置</param> /// <param name="y">y偏移</param> public void ShowReduceTips(string content, Vector3 pos, float y = 120f) { var txtObject = m_ReducePool.GetGameObject(); var tipsText = txtObject.GetComponent <Text>(); Util.SetParent(TipsCanvas, txtObject.transform); tipsText.text = content; txtObject.SetActive(true); txtObject.transform.localRotation = Quaternion.identity; txtObject.transform.localScale = Vector3.one; txtObject.transform.localPosition = new Vector3(pos.x, pos.y - y, 0); var color = tipsText.color; color.a = 0; tipsText.color = color; Sequence mySequence = DOTween.Sequence(); Tweener move1 = txtObject.transform.DOLocalMoveY(pos.y, 0.4f); move1.SetEase(Ease.InCubic); Tweener move2 = txtObject.transform.DOLocalMoveY(pos.y + y, 0.4f); move2.SetEase(Ease.OutCubic); Tweener alpha1 = tipsText.DOColor(new Color(color.r, color.g, color.b, 1), 0.4f); Tweener alpha2 = tipsText.DOColor(new Color(color.r, color.g, color.b, 0), 0.4f); Tweener scale1 = txtObject.transform.DOScale(new Vector3(2f, 2f, 1f), 0.4f); scale1.SetEase(Ease.InOutCubic); Tweener scale2 = txtObject.transform.DOScale(new Vector3(1f, 1f, 1f), 0.4f); scale2.SetEase(Ease.InOutCubic); mySequence.Append(move1); mySequence.Join(alpha1); mySequence.Join(scale1); mySequence.AppendInterval(0.4f); mySequence.Append(move2); mySequence.Join(alpha2); mySequence.Join(scale2); mySequence.OnComplete(delegate() { mySequence.Kill(); m_ReducePool.RecyleToPool(txtObject); }); }
/// <summary> /// 显示一个Icon Tips /// </summary> /// <param name="type">icon 类型(也是Sprite名称)</param> /// <param name="content">加分</param> /// <param name="y"></param> public void ShowTips(string type, string content, float y = 120f) { var txtObject = m_IconPool.GetGameObject(); var tipsIcon = txtObject.GetComponentInChildren <Image>(); var tipsText = txtObject.GetComponentInChildren <TextMeshProUGUI>(); Util.SetParent(TipsCanvas, txtObject.transform); tipsIcon.sprite = m_SpriteAtlas.GetSprite(type); tipsIcon.SetNativeSize(); tipsText.text = content; txtObject.SetActive(true); var vector = string.IsNullOrEmpty(content) ? Vector2.zero : Random.insideUnitCircle * 240; txtObject.transform.localRotation = Quaternion.identity; txtObject.transform.localScale = Vector3.one; txtObject.transform.localPosition = new Vector3(vector.x, vector.y - y, 0); var color = tipsText.color; color.a = 0; tipsText.color = color; Sequence mySequence = DOTween.Sequence(); Tweener move1 = txtObject.transform.DOLocalMoveY(vector.y, 0.2f); Tweener move2 = txtObject.transform.DOLocalMoveY(vector.y + 1.5f * y, 1.7f); Tweener alpha1 = tipsText.DOColor(new Color(color.r, color.g, color.b, 1), 0.2f); Tweener alpha2 = tipsText.DOColor(new Color(color.r, color.g, color.b, 0), 1.7f); mySequence.Append(move1); mySequence.Join(alpha1); mySequence.Append(move2); mySequence.Join(alpha2); mySequence.OnComplete(delegate() { mySequence.Kill(); m_IconPool.RecyleToPool(txtObject); }); }