/// <summary> /// 清除,从屏幕上消失 /// </summary> public void Clear() { if (GameMain.Singleton != null) { --GameMain.Singleton.NumFishAlive; } var gdata = App.GetGameData <FishGameData>(); if (gdata.EvtFishClear != null) { gdata.EvtFishClear(this); } Attackable = false; _mId = 0; if (_shadow != null) { _shadow.Clear(); } Pool_GameObj.RecycleGO(Prefab_GoAniSwim, MGoAniSprite); MGoAniSprite.SetActive(false); var tsAniSwim = MGoAniSprite.transform; tsAniSwim.position = new Vector3(1000F, 0F, 0F); tsAniSwim.rotation = Quaternion.identity; tsAniSwim.localScale = Vector3.one; MGoAniSprite = null; MAnimationSprite = null; App.GetGameData <FishGameData>().RmoveFish(TypeIndex); Destroy(gameObject); }
void Handle_CoinStackDisappear(CoinStack cStack) { mCoinStacks.Dequeue(); Pool_GameObj.RecycleGO(null, cStack.gameObject); if (mCoinStacks.Count != 0) { mState_IsMovingStacks = true; mElapse_MovingStacks = 0F; } }
public void Clear() { if (_shadowObj != null) { var obj = _shadowObj.gameObject; Pool_GameObj.RecycleGO(obj, obj); obj.SetActive(false); } Destroy(this); }
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_Popup(int num, Vector3 worldPos, Transform tsParent, int odds) { //tk2dTextMesh digit = Instantiate(Prefab_Digit) as tk2dTextMesh; var digit = Pool_GameObj.GetObj(Prefab_Digit.gameObject).GetComponent <tk2dTextMesh>(); digit.gameObject.SetActive(true); digit.text = YxUtiles.GetShowNumberToString(num); digit.Commit(); var ts = digit.transform; ts.parent = tsParent; ts.localRotation = Quaternion.identity; var scale = Mathf.Min(0.5f + odds / 5f * 0.3f, 1.5f); ts.localScale = new Vector3(scale, scale, 1F); var oriPos = worldPos; oriPos.z = Defines.GlobleDepth_DieFishPopDigit; ts.position = oriPos; var elapse = 0F; var c = Prefab_Digit.color; while (elapse < Duration) { yield return(0); var prct = elapse / Duration; ts.position = oriPos + new Vector3(0F, Curve_OffsetY.Evaluate(prct), 0F); digit.Commit(); elapse += Time.deltaTime; } yield return(new WaitForSeconds(2)); elapse = 0; while (elapse < Duration) { var prct = elapse / Duration; c.a = Curve_Alpha.Evaluate(prct); digit.color = c; digit.Commit(); elapse += Time.deltaTime; yield return(0); } //Destroy(digit.gameObject); digit.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_Digit.gameObject, digit.gameObject); }
// Use this for initialization IEnumerator Start() { if (Prefab == null) { Debug.LogError("Prefab ²»ÄÜΪ ¿Õ!!"); yield break; } yield return(new WaitForSeconds(delay)); Pool_GameObj.RecycleGO(Prefab, gameObject); gameObject.SetActive(false); transform.position = new Vector3(1000F, 1000F, 0F); Destroy(this); }
IEnumerator _Coro_Popup(int num, Vector3 worldPos, Transform tsParent, int fishTypeIdx) { //tk2dTextMesh digit = Instantiate(Prefab_Digit) as tk2dTextMesh; tk2dTextMesh digit = Pool_GameObj.GetObj(Prefab_Digit.gameObject).GetComponent <tk2dTextMesh>(); digit.gameObject.SetActive(true); digit.text = num.ToString(); digit.Commit(); Transform ts = digit.transform; ts.parent = tsParent; ts.localRotation = Quaternion.identity; float scale = 1F; if (mScaleDatasMap.TryGetValue(fishTypeIdx, out scale)) { ts.localScale = new Vector3(scale, scale, 1F); } else { ts.localScale = Vector3.one; } Vector3 oriPos = worldPos; oriPos.z = Defines.GlobleDepth_DieFishPopDigit; ts.position = oriPos; float elapse = 0F; Color c = Prefab_Digit.color; while (elapse < Duration) { float prct = elapse / Duration; ts.position = oriPos + new Vector3(0F, Curve_OffsetY.Evaluate(prct), 0F); c.a = Curve_Alpha.Evaluate(prct); digit.color = c; digit.Commit(); elapse += Time.deltaTime; yield return(0); } //Destroy(digit.gameObject); digit.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_Digit.gameObject, digit.gameObject); }
public void SelfDestroy() { if (mIsDestroyed) { return; } if (GameMain.EvtBulletDestroy != null) { GameMain.EvtBulletDestroy(this); } Pool_GameObj.RecycleGO(null, gameObject); mIsDestroyed = true;//Destroy不会立即使得OnTrigger失效,防止多次物理碰撞, }
public void SelfDestroy() { if (_mIsDestroyed) { return; } var gdata = App.GetGameData <FishGameData>(); if (gdata.EvtBulletDestroy != null) { gdata.EvtBulletDestroy(this); } Pool_GameObj.RecycleGO(null, gameObject); _mIsDestroyed = true;//Destroy不会立即使得OnTrigger失效,防止多次物理碰撞, }
public void On_Recycle() { gameObject.SetActive(false); //gameObject.active = false; //gameObject.SetActiveRecursively(false); if (mBulletGO != null) { mBulletGO.SetActive(false); Pool_GameObj.RecycleGO(Prefab_GoAnisprBullet, mBulletGO); mBulletGO = null; } --Owner.GunInst.NumBulletInWorld; if (Owner.GunInst.NumBulletInWorld < 0) { Debug.LogError("在场子弹数不能为负" + Owner.GunInst.NumBulletInWorld.ToString()); } }
IEnumerator _Coro_BubbleScaleUp(tk2dSprite spr) { //设置颜色 Color c = spr.color; c.a = AlphaStart; spr.color = c; float elapse = 0F; //放大 Transform tsSpr = spr.transform; float scaleUpTime = TimeOneBubble * 0.7F; while (elapse < scaleUpTime) { tsSpr.localScale = (ScaleTarget * (0.5F + elapse / scaleUpTime * 0.5F)) * Vector3.one; elapse += Time.deltaTime; yield return(0F); } tsSpr.localScale = Vector3.one * ScaleTarget; //渐隐 elapse = 0F; float fadeoutTime = TimeOneBubble * 0.3F; while (elapse < fadeoutTime) { c.a = (1F - elapse / fadeoutTime) * AlphaStart; spr.color = c; elapse += Time.deltaTime; yield return(0F); } //删除 spr.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_Bubble.gameObject, spr.gameObject); //Destroy(spr.gameObject); }
//private bool mIsCleaned = false; /// <summary> /// ����,����Ļ����ʧ /// </summary> public void Clear() { //if (mIsCleaned) // return; //mIsCleaned = true; if (GameMain.Singleton != null) { --GameMain.Singleton.NumFishAlive; } if (GameMain.EvtFishClear != null) { GameMain.EvtFishClear(this); } Attackable = false; Pool_GameObj.RecycleGO(Prefab_GoAniSwim, mGoAniSprite); mGoAniSprite.SetActive(false); Transform tsAniSwim = mGoAniSprite.transform; tsAniSwim.position = new Vector3(1000F, 0F, 0F); tsAniSwim.rotation = Quaternion.identity; tsAniSwim.localScale = Vector3.one; mGoAniSprite = null; mAnimationSprite = null; // if (!Pool_GameObj.RecycleGO(null, gameObject)) // { Destroy(gameObject); //} }
private IEnumerator _Coro_FlytProcess(Vector3 fishDieWorldPos, int num, float delay) { int numFly; var typeCoin = FlyingCoinType.Sliver; if (num < 10) { numFly = num; } else { numFly = num / 5 + (num % 5 != 0 ? 1 : 0); if (numFly > 11) { numFly = 11; //最大飞11颗 } typeCoin = FlyingCoinType.Glod; } yield return(new WaitForSeconds(delay)); //播放声音 if (PlaySound && GameMain.Singleton != null) { var musicMgr = Facade.Instance <MusicManager>(); if (typeCoin == FlyingCoinType.Sliver) { musicMgr.Play("getsilver"); } if (typeCoin == FlyingCoinType.Glod) { musicMgr.Play("getgold"); } } var fishDielocalPos = transform.InverseTransformPoint(fishDieWorldPos); fishDielocalPos.z = 0F; //var useGoldPrefab = t==FlyingCoinType.Glod ? Prefab_GoldBig : Prefab_Gold; FlyingCoin useGoldPrefab; float offy; if (typeCoin == FlyingCoinType.Glod) { useGoldPrefab = Prefab_GoldBig; offy = 12; } else { useGoldPrefab = Prefab_Gold; offy = 6.5f; } //生成币 var golds = new FlyingCoin[numFly]; var startLocalPos = fishDielocalPos; // -new Vector3(AppearOffsetX * (num - 1) * 0.5F, AppearOffsetY * (num - 1) * 0.5F, 0F); //startLocalPos += startLocalPos.normalized * 38.4F;//*1.3F,为延长距离,使得金币更像是鱼中飞出 var maxTime = 0F; var con = new GameObject("coins"); var ts = con.transform; if (coinSpace++ > 50) { coinSpace = 0; } ts.parent = GetCoinsContainer(); ts.localPosition = new Vector3(0, 0, coinSpace * 0.0001f); ts.localRotation = Quaternion.identity; var target = Vector3.zero; for (var i = 0; i < numFly; ++i) { var gold = Pool_GameObj.GetObj(useGoldPrefab.gameObject).GetComponent <FlyingCoin>(); golds[i] = gold; gold.FlySpeed = FlySpeed; var goldTs = gold.transform; goldTs.parent = ts; goldTs.localRotation = Quaternion.identity; var offPos = new Vector3(AppearOffsetX * i, AppearOffsetY * i, 0F); offPos = fishDielocalPos.x < transform.localRotation.x ? -offPos : offPos; goldTs.localPosition = startLocalPos + offPos; var flyNeedTime = gold.FlytoPosZero(Curve_Scale, target); target.y += offy; if (flyNeedTime > maxTime) { maxTime = flyNeedTime; } yield return(new WaitForSeconds(AppearInterval)); } yield return(new WaitForSeconds(maxTime - AppearInterval * numFly)); var coinNum = Pool_GameObj.GetObj(CoinNumPerfab.gameObject).GetComponent <tk2dTextMesh>(); var coinNumTs = coinNum.transform; coinNum.text = num.ToString(); coinNumTs.parent = ts; coinNumTs.localRotation = Quaternion.identity; coinNumTs.localPosition = new Vector3(0, target.y, 10); while (_nextStop) { yield return(new WaitForSeconds(WaitTime)); } _nextStop = true; yield return(new WaitForSeconds(WaitTime)); _nextStop = false; var times = 1; var pos = ts.localPosition; while (times < MoveCount) { ts.localPosition = pos; pos.x -= HMoveSpeed; times++; yield return(new WaitForSeconds(WaitTime)); } //消失 for (var i = 0; i != numFly; ++i) { Pool_GameObj.RecycleGO(null, golds[i].gameObject); //Destroy(golds[i].gameObject); } Destroy(con); }
void Update() { if (mState1 == State1.ScaleUp) { if (mElapse < TimeWebScaleUp) { mTsWeb.localScale = Vector3.one;//(ScaleTarget * mElapse / TimeWebScaleUp) * mElapse += Time.deltaTime; } else { mElapse = 0F; mState1 = State1.Shaking; } } else if (mState1 == State1.Shaking) { if (mElapse < TimeShake) { if (mElapseShakeInterval < IntervalShake) { mElapseShakeInterval += Time.deltaTime; } else { //float elapse = 0F; //int curDirectIdx = 0; mTsWeb.localPosition += (mShakeDirects[mIdxCurShakePos % mShakeDirects.Length] * RangeShake); ++mIdxCurShakePos; mElapseShakeInterval = 0; //elapse += IntervalShake; } //yield return new WaitForSeconds(IntervalShake); } else { mTsWeb.gameObject.SetActive(false); Pool_GameObj.RecycleGO(Prefab_GoSpriteWeb, mTsWeb.gameObject); Destroy(gameObject); } } if (!mState2_IsFadingOut) { if (mElapseFadeout < mTimeWaitFadeout) { mElapseFadeout += Time.deltaTime; } else { mState2_IsFadingOut = true; mElapseFadeout = 0F; } } else { mColorWeb.a = 1F - mElapseFadeout / TimeFadeOut; mSprWeb.color = mColorWeb; //c.a = 0F; //mSprWeb.color = c; mElapseFadeout += Time.deltaTime; } }