private void PushOneStack(int coinNum, int fishOdd, int gunScore) { //return; if (coinNum <= 0) { return; } //CoinStack coinStackNew = Instantiate(Prefab_coinStack) as CoinStack; CoinStack coinStackNew = Pool_GameObj.GetObj(Prefab_coinStack.gameObject).GetComponent <CoinStack>(); Transform coinStackNewTs = coinStackNew.transform; mCoinStackCurrentDepth = mCoinStacks.Count == 0 ? 0F : mCoinStackCurrentDepth - 0.1F; coinStackNewTs.parent = transform; coinStackNewTs.localRotation = Quaternion.identity; coinStackNewTs.localPosition = new Vector3(-mCoinStacks.Count * (OneStackWidth + OneStackSpace), 0F, mCoinStackCurrentDepth); coinStackNew.PileUp(coinNum, GetCoinStackHeight(fishOdd, gunScore), mCurCoinStackBGColor); mCurCoinStackBGColor = !mCurCoinStackBGColor; coinStackNew.EvtDisappear += Handle_CoinStackDisappear; coinStackNew.EvtRoleToHead += Handle_CoinStackRollToHead; mCoinStacks.Enqueue(coinStackNew); //mState_IsMovingStacks = true; }
void Handle_CoinStackRollToHead(CoinStack cStack) { if (mCoinStacks.Count != 0 && cStack.GetInstanceID() == mCoinStacks.Peek().GetInstanceID()) { cStack.FadeOut(); } }
private float mCenterToCenterBetweenStack; //币堆间的距离 void Update() { //如果显示中的币堆少于限制数,则加入新币堆. if (mCoinStackDataToView.Count > 0 && mCoinStacks.Count < NumCoinStackLimit) { CoinStackDataToView csdtv = mCoinStackDataToView.Dequeue(); PushOneStack(csdtv.coinNum, csdtv.fishOdd, csdtv.gunScore); } if (mState_IsMovingStacks) { if (mCoinStacks.Count == 0) { goto TAG_BREAK_MOVINGSTACK; } if (mElapse_MovingStacks < TimeMoveUse) { int idx = 1; Transform tsCoinStack; foreach (CoinStack cs in mCoinStacks) { tsCoinStack = cs.transform; tsCoinStack.localPosition = new Vector3(-mCenterToCenterBetweenStack * idx + mElapse_MovingStacks / TimeMoveUse * mCenterToCenterBetweenStack, 0F, tsCoinStack.localPosition.z); ++idx; } //if (mElapse_MovingStacks == TimeMoveUse) //{ // break; //} //if (mElapse_MovingStacks > TimeMoveUse) // mElapse_MovingStacks = TimeMoveUse; mElapse_MovingStacks += Time.deltaTime; } else//移动到目标位置 { int idx = 1; Transform tsCoinStack; foreach (CoinStack cs in mCoinStacks) { tsCoinStack = cs.transform; tsCoinStack.localPosition = new Vector3(-mCenterToCenterBetweenStack * idx + mCenterToCenterBetweenStack, 0F, tsCoinStack.localPosition.z); ++idx; } CoinStack coinStackHead = mCoinStacks.Peek(); if (coinStackHead.IsRoleToHead)//如果最前面的还没有pileup到顶部,则不进行消失 { coinStackHead.FadeOut(); mElapse_MovingStacks = 0F; mState_IsMovingStacks = false; } } TAG_BREAK_MOVINGSTACK :; } }
void Handle_CoinStackDisappear(CoinStack cStack) { mCoinStacks.Dequeue(); Pool_GameObj.RecycleGO(null, cStack.gameObject); if (mCoinStacks.Count != 0) { mState_IsMovingStacks = true; mElapse_MovingStacks = 0F; } }