IEnumerator _Coro_FlytProcess(Vector3 fishDieWorldPos, FlyingCoinType t, int num, float delay) { yield return(new WaitForSeconds(delay)); //播放声音 if (GameMain.Singleton.SoundMgr.snd_Coin != null && t == FlyingCoinType.Sliver) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Coin); } if (GameMain.Singleton.SoundMgr.snd_Gold != null && t == FlyingCoinType.Glod) { GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Gold); } Vector3 fishDielocalPos = transform.InverseTransformPoint(fishDieWorldPos); fishDielocalPos.z = 0F; FlyingCoin useGoldPrefab = t == FlyingCoinType.Glod ? Prefab_GoldBig : Prefab_Gold; //生成币 FlyingCoin[] golds = new FlyingCoin[num]; Vector3 startLocalPos = fishDielocalPos - new Vector3(AppearOffsetX * (num - 1) * 0.5F, AppearOffsetY * (num - 1) * 0.5F, 0F); startLocalPos += startLocalPos.normalized * 38.4F;//*1.3F,为延长距离,使得金币更像是鱼中飞出 float maxTime = 0F; for (int i = 0; i != num; ++i) { //golds[i] = Instantiate(useGoldPrefab) as FlyingCoin; golds[i] = Pool_GameObj.GetObj(useGoldPrefab.gameObject).GetComponent <FlyingCoin>(); golds[i].FlySpeed = FlySpeed; Transform goldTs = golds[i].transform; goldTs.parent = transform; goldTs.localRotation = Quaternion.identity; goldTs.localPosition = startLocalPos + new Vector3(AppearOffsetX * i, AppearOffsetY * i, 0F); float flyNeedTime = golds[i].FlytoPosZero(Curve_Scale); if (flyNeedTime > maxTime) { maxTime = flyNeedTime; } yield return(new WaitForSeconds(AppearInterval)); } yield return(new WaitForSeconds(maxTime - AppearInterval * num)); for (int i = 0; i != num; ++i) { Pool_GameObj.RecycleGO(null, golds[i].gameObject); //Destroy(golds[i].gameObject); } }
IEnumerator _Coro_FlytProcess(Vector3 fishDieWorldPos, FlyingCoinType t, int num, float delay) { yield return new WaitForSeconds(delay); //�������� if (GameMain.Singleton.SoundMgr.snd_Coin != null&&t == FlyingCoinType.Sliver) GameMain.Singleton.SoundMgr.PlayOneShot(GameMain.Singleton.SoundMgr.snd_Coin); if(GameMain.Singleton.SoundMgr.snd_Gold != null && t == FlyingCoinType.Glod) GameMain.Singleton.SoundMgr.PlayOneShot( GameMain.Singleton.SoundMgr.snd_Gold ); Vector3 fishDielocalPos = transform.InverseTransformPoint(fishDieWorldPos); fishDielocalPos.z = 0F; FlyingCoin useGoldPrefab = t==FlyingCoinType.Glod ? Prefab_GoldBig : Prefab_Gold; //���ɱ� FlyingCoin[] golds = new FlyingCoin[num]; Vector3 startLocalPos = fishDielocalPos - new Vector3(AppearOffsetX * (num - 1) * 0.5F, AppearOffsetY * (num - 1) * 0.5F, 0F); startLocalPos += startLocalPos.normalized * 38.4F;//*1.3F,Ϊ�ӳ�����,ʹ�ý�Ҹ��������зɳ� float maxTime = 0F; for (int i = 0; i != num; ++i) { //golds[i] = Instantiate(useGoldPrefab) as FlyingCoin; golds[i] = Pool_GameObj.GetObj(useGoldPrefab.gameObject).GetComponent<FlyingCoin>(); golds[i].FlySpeed = FlySpeed; Transform goldTs = golds[i].transform; goldTs.parent = transform; goldTs.localRotation = Quaternion.identity; goldTs.localPosition = startLocalPos + new Vector3(AppearOffsetX * i, AppearOffsetY * i, 0F); float flyNeedTime = golds[i].FlytoPosZero(Curve_Scale); if (flyNeedTime > maxTime) maxTime = flyNeedTime; yield return new WaitForSeconds(AppearInterval); } yield return new WaitForSeconds(maxTime - AppearInterval * num); for (int i = 0; i != num; ++i) { Pool_GameObj.RecycleGO(null, golds[i].gameObject); //Destroy(golds[i].gameObject); } }