public IEnumerator 풀링_기본테스트() { CManagerPooling <ETestPoolingObjectName, TestPoolingObject> pPoolingManager = InitGeneratePoolingTest(); Assert.AreEqual(0, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test1]); Assert.AreEqual(0, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test2]); List <GameObject> listObjectPooling = new List <GameObject>(); for (int i = 0; i < 10; i++) { listObjectPooling.Add(pPoolingManager.DoPop(ETestPoolingObjectName.Test1).gameObject); } Assert.AreEqual(10, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test1]); for (int i = 0; i < 10; i++) { pPoolingManager.DoPush(listObjectPooling[i].GetComponent <TestPoolingObject>()); } Assert.AreEqual(0, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test1]); listObjectPooling.Clear(); for (int i = 0; i < 5; i++) { listObjectPooling.Add(pPoolingManager.DoPop(ETestPoolingObjectName.Test2).gameObject); } Assert.AreEqual(5, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test2]); pPoolingManager.DoPushAll(); Assert.AreEqual(0, TestPoolingObject.g_mapActiveCount[ETestPoolingObjectName.Test2]); yield break; }
public IEnumerator 풀링_이벤트테스트() { g_mapMakeCount = new Dictionary <ETestPoolingObjectName, int>() { { ETestPoolingObjectName.Test3, 0 } }; g_mapPopCount = new Dictionary <ETestPoolingObjectName, int>() { { ETestPoolingObjectName.Test3, 0 } }; g_mapPushCount = new Dictionary <ETestPoolingObjectName, int>() { { ETestPoolingObjectName.Test3, 0 } }; CManagerPooling <ETestPoolingObjectName, TestPoolingObject> pPoolingManager = InitGeneratePoolingTest(); pPoolingManager.p_EVENT_OnMakeResource += PPoolingManager_p_EVENT_OnMakeResource; pPoolingManager.p_EVENT_OnPopResource += PPoolingManager_p_EVENT_OnPopResource; pPoolingManager.p_EVENT_OnPushResource += PPoolingManager_p_EVENT_OnPushResource; int iTotalMakeCount = Random.Range(15, 50); for (int i = 0; i < iTotalMakeCount; i++) { pPoolingManager.DoPop(ETestPoolingObjectName.Test3); } Assert.AreEqual(g_mapMakeCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPopCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPushCount[ETestPoolingObjectName.Test3], 0); pPoolingManager.DoPushAll(); Assert.AreEqual(g_mapMakeCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPopCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPushCount[ETestPoolingObjectName.Test3], iTotalMakeCount); for (int i = 0; i < iTotalMakeCount; i++) { pPoolingManager.DoPop(ETestPoolingObjectName.Test3); } Assert.AreEqual(g_mapMakeCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPopCount[ETestPoolingObjectName.Test3], iTotalMakeCount * 2); Assert.AreEqual(g_mapPushCount[ETestPoolingObjectName.Test3], iTotalMakeCount); pPoolingManager.DoPushAll(); Assert.AreEqual(g_mapMakeCount[ETestPoolingObjectName.Test3], iTotalMakeCount); Assert.AreEqual(g_mapPopCount[ETestPoolingObjectName.Test3], iTotalMakeCount * 2); Assert.AreEqual(g_mapPushCount[ETestPoolingObjectName.Test3], iTotalMakeCount * 2); yield break; }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { Pooling_BulletTest pBullet = _pManagerPool_Bullet.DoPop(Pooling_BulletTest.ProjectileModel.Model_Projectile_Blue); pBullet.DoInitBullet(_pTransMuzzle); } if (Input.GetKeyDown(KeyCode.Alpha2)) { Pooling_BulletTest pBullet = _pManagerPool_Bullet.DoPop(Pooling_BulletTest.ProjectileModel.Model_Projectile_Red); pBullet.DoInitBullet(_pTransMuzzle); } }
public void DoStartTween_Indicator(string strText, string strFormat, Color pColor, Vector3 v3Position) { CResource_NGUILabelIndicator pResource = _pManagerPool_LabelIndicator.DoPop(ELabelIndicator.Label_Indicator); pResource.p_pTransCached.parent = _pTrans_Label; pResource.p_pTransCached.DoResetTransform(); pResource.p_pTransCached.localPosition = v3Position; pResource.DoStartTween_Indicator(string.Format(strFormat, strText), ++_iLastDepth, pColor, p_vecStartPos, _sInfoIndicator); }
// ========================================================================== // /* private - [Proc] Function * 로직을 처리(Process Local logic) */ virtual protected void ProcShotGenerate(Vector3 vecBulletPos, Quaternion rotBulletAngle) { Class_Resource pResource = _pManagerPool.DoPop(p_eGenerateKey); pResource.transform.position = vecBulletPos; pResource.transform.rotation = rotBulletAngle; pResource.transform.localScale = _vecAdjust_GenerateScale; if (_fAngleRandom != 0f) { float fRandomAngleZ = Random.Range(-_fAngleRandom, _fAngleRandom); pResource.transform.Rotate(0f, 0f, fRandomAngleZ); } if (p_EVENT_OnGenerate != null) { p_EVENT_OnGenerate(p_eGenerateKey, pResource); } OnGenerateSomthing(p_eGenerateKey, pResource); }
// ========================================================================== // /* public - [Do] Function * 외부 객체가 호출 */ public CEffect DoPop(string strEffectName) { return(_pManagerPooling.DoPop(strEffectName)); }
// ========================================================================== // /* public - [Do] Function * 외부 객체가 호출(For External class call)*/ public HealthBar GetHealthBar() { return(_pHealthBarPool.DoPop(p_pObjectHealthBar_Origin)); }