コード例 #1
0
        private TempUpdate GenTempUpdate()
        {
            TempUpdate tu = null;

            for (int i = 0, count = updateList.Count; i < count; i++)
            {
                tu = updateList[i];
                if (tu == null)
                {
                    tu            = new TempUpdate();
                    tu.objID      = -1;
                    updateList[i] = tu;
                    break;
                }
                else
                {
                    if (tu.objID < 0)
                    {
                        break;
                    }
                }
            }

            if (tu == null)
            {
                tu       = new TempUpdate();
                tu.objID = -1;
                updateList.Add(tu);
            }

            return(tu);
        }
コード例 #2
0
        void Update()
        {
            TempUpdate tu = null;
            Vector3    worldPos;
            bool       doo  = false;
            float      time = Time.time;

            for (int i = 0, count = updateList.Count; i < count; i++)
            {
                tu = updateList[i];
                if (tu != null && tu.objID >= 0)
                {
                    if (time - tu.beginTime <= lifeTime)
                    {
                        bool v = CalculateWorldPos(tu.objID, tu.camObjID, tu.localCenter, out worldPos);
                        if (v)
                        {
                            doo = true;
                            for (uint j = tu.begin; j < tu.end; j++)
                            {
                                uint indexPos = j * BC_VERTEX_EACH_BOARD;
                                mCenters[indexPos]     = worldPos;
                                mCenters[indexPos + 1] = worldPos;
                                mCenters[indexPos + 2] = worldPos;
                                mCenters[indexPos + 3] = worldPos;
                            }
                        }
                    }
                    else
                    {
                        tu.objID = -1;
                    }
                }
            }

            if (doo)
            {
                mMesh.vertices = mCenters;
            }
        }
コード例 #3
0
        //-------------------------------------------------------------------------------------------//
        public void DisplayNumber(int luaObjID, int camObjID, Example.PackItem[] items, int item_valid_num, Vector2 size, Vector3 localCenter, Color clr, bool haveScale, float offsetX)
        {
            if (item_valid_num <= 0)
            {
                return;
            }

            Vector3 center = localCenter;

            if (luaObjID >= 0)
            {
                bool re = CalculateWorldPos(luaObjID, camObjID, localCenter, out center);
                if (!re)
                {
                    return;
                }
            }

            float time = Time.timeSinceLevelLoad;

            int     numLength = item_valid_num;
            Vector2 halfSize  = new Vector2(size.x * 0.5f, size.y * 0.5f);

            Example.PackItem item;
            float            leftBio = 0;

            for (int i = 0; i < numLength; ++i)
            {
                item = items[i];
                float sw = (float)item.Width / standardWidth;
                leftBio += size.x * sw;
            }

            leftBio *= -0.5f;

            int inthaveScale = 1;

            if (!haveScale)
            {
                inthaveScale = 0;
            }

            TempUpdate tu = GenTempUpdate();

            tu.objID       = luaObjID;
            tu.camObjID    = camObjID;
            tu.begin       = mBoardIndex;
            tu.localCenter = localCenter;
            tu.beginTime   = Time.time;

            float px = leftBio;

            for (int i = 0; i < numLength; ++i)
            {
                item = items[i];
                float fw = (float)item.Width / textureWidth;
                float fh = (float)item.Height / textureHeight;

                float sw = (float)item.Width / standardWidth;
                float sh = (float)item.Height / standardHeight;

                uint indexPos = mBoardIndex * BC_VERTEX_EACH_BOARD;

                float thh = 1 + sh * 0.5f;

                mPosXYLifeScale[indexPos].Set(px, halfSize.y * thh, time, inthaveScale);
                mPosXYLifeScale[indexPos + 1].Set(px, -halfSize.y * thh, time, inthaveScale);
                mPosXYLifeScale[indexPos + 2].Set(px + size.x * sw, halfSize.y * thh, time, inthaveScale);
                mPosXYLifeScale[indexPos + 3].Set(px + size.x * sw, -halfSize.y * thh, time, inthaveScale);

                px += size.x * sw;

                mCenters[indexPos]     = center;
                mCenters[indexPos + 1] = center;
                mCenters[indexPos + 2] = center;
                mCenters[indexPos + 3] = center;

                mColors[indexPos]     = clr;
                mColors[indexPos + 1] = clr;
                mColors[indexPos + 2] = clr;
                mColors[indexPos + 3] = clr;

                {
                    //计算UV//
                    Vector2 uvBegin = new Vector2((float)item.X / textureWidth, 1 - (float)item.Y / textureHeight);
                    mUv[indexPos] = uvBegin;
                    mUv[indexPos + 1].Set(uvBegin.x, uvBegin.y - fh);
                    mUv[indexPos + 2].Set(uvBegin.x + fw, uvBegin.y);
                    mUv[indexPos + 3].Set(uvBegin.x + fw, uvBegin.y - fh);
                }

                mUv2[indexPos].Set(offsetX, 0);
                mUv2[indexPos + 1].Set(offsetX, 0);
                mUv2[indexPos + 2].Set(offsetX, 0);
                mUv2[indexPos + 3].Set(offsetX, 0);


                mBoardIndex = ++mBoardIndex < mMaxBoardSize ? mBoardIndex : 0;
            }

            tu.end = mBoardIndex;

            mMesh.vertices = mCenters;
            mMesh.tangents = mPosXYLifeScale;
            mMesh.colors   = mColors;
            mMesh.uv       = mUv;
            mMesh.uv2      = mUv2;
        }
コード例 #4
0
 private void OnTempUpdate(double result)
 {
     TempUpdate?.Invoke(this, result);
 }