コード例 #1
0
    private void coinBehavior(Vector2 pos, Vector2 endPos, int nCount, bool bGold, float staytime)
    {
        float randomX = nCount * 0.03f;
        float randomY = nCount * 0.03f;

        for (int i = 0; i < nCount; i++)
        {
            CoinObjInfo coin = getUnActiveCoinInfo(bGold);

            if (coin != null)
            {
                Transform goldTf = coin.CoinObj.transform;
                float     nX     = Random.Range(-randomX, randomX);
                float     nY     = Random.Range(-randomY, randomY);

                Vector3    startPos   = new Vector3(pos.x + nX, pos.y + nY, coin.CoinObj.transform.position.z);
                GoldBezier gb         = coin.CoinObj.GetComponent <GoldBezier>();
                float      nEveryTime = 0.5f / nCount;
                nEveryTime = Mathf.Min(0.08f, nEveryTime);
                if (i >= nCount - 1 && bGold)
                {
                    gb._bLastCoin = true;
                }
                else
                {
                    gb._bLastCoin = false;
                }
                gb.setBezier(startPos, endPos, i, nEveryTime, staytime);
                coin.Active = true;
            }
        }
    }
コード例 #2
0
    public void insertGameObj(GameObject coinObj, bool bGold, bool bActive, int nIndex = 9999999)
    {
        CoinObjInfo coin = new CoinObjInfo();

        coin.CoinObj = coinObj;
        coin.Active  = bActive;

        Animator animator = coinObj.transform.Find("Icon").GetComponent <Animator>();

        animator.enabled = false;

        PListMono plistMono = coinObj.transform.Find("Icon").GetComponent <PListMono>();

        plistMono.enabled = false;

        coin.CoinObj.transform.position = new Vector3(1000, 1000, coin.CoinObj.transform.position.z);

        if (bGold)
        {
            if (nIndex == 9999999)
            {
                _goldList.Add(coin);
            }
            else
            {
                _goldList.Insert(nIndex, coin);
            }
        }
        else
        {
            if (nIndex == 9999999)
            {
                _silverList.Add(coin);
            }
            else
            {
                _silverList.Insert(nIndex, coin);
            }
        }
    }
コード例 #3
0
    private CoinObjInfo getUnActiveCoinInfo(bool bGold)
    {
        CoinObjInfo coin = new CoinObjInfo();

        coin.Active  = true;
        coin.CoinObj = null;

        bool bLast = false;

        Transform parent = _goldList[0].CoinObj.transform.parent;

//         int nIndex = 0;
//         while ((coin.Active || coin.CoinObj == null) && !bLast)
//         {
//             if (bGold)
//             {
//                 coin = _goldList[nIndex];
//             }
//             else
//             {
//                 coin = _silverList[nIndex];
//             }
//             nIndex++;
//             if (bGold)
//             {
//                 if (nIndex >= _goldList.size)
//                 {
//                     bLast = true;
//                 }
//             }
//             else
//             {
//                 if (nIndex >= _silverList.size)
//                 {
//                     bLast = true;
//                 }
//             }
//         }


        if (bGold)
        {
            coin = _goldList[nGoldIndex];
        }
        else
        {
            coin = _silverList[nSilverIndex];
        }

        if (coin.Active || coin.CoinObj == null)
        {
            int nIndex = 0;
            coin = null;
            coin = new CoinObjInfo();
            GameObject singleCoinObj = null;
            if (bGold)
            {
                nIndex = nGoldIndex + 1;
                if (_goldList[0].CoinObj != null)
                {
                    singleCoinObj = NGUITools.AddChild(parent.gameObject, _goldList[0].CoinObj);
                }
                nGoldIndex += 2;
            }
            else
            {
                nIndex = nSilverIndex + 1;
                if (_silverList[0].CoinObj != null)
                {
                    singleCoinObj = NGUITools.AddChild(parent.gameObject, _silverList[0].CoinObj);
                }
                nSilverIndex += 2;
            }

            if (singleCoinObj != null)
            {
                coin.CoinObj = singleCoinObj;
                coin.Active  = true;

                insertGameObj(singleCoinObj, bGold, true, nIndex + 1);
                //Utils.LogSys.LogError("create new coin");
            }
        }
        else
        {
            if (bGold)
            {
                nGoldIndex++;
            }
            else
            {
                nSilverIndex++;
            }
        }

        if (nGoldIndex >= _goldList.size)
        {
            nGoldIndex = 0;
        }

        if (nSilverIndex >= _silverList.size)
        {
            nSilverIndex = 0;
        }


        if (coin.CoinObj != null)
        {
            return(coin);
        }
        return(null);
    }