Ejemplo n.º 1
0
    private void updatePositions()
    {
        TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

        for (int i = 0; i <= currentIndex; ++i)
        {
            positions[i] += d.current;
        }
    }
Ejemplo n.º 2
0
    public void Execute(int index)
    {
        TubeUpdateData thisData = dataArray[index];
        byte           op       = 0;

        if (thisData.speed > 0.0f)
        {
            float movedDist = deltaTime * thisData.speed;
            thisData.current += movedDist;
            dataArray[index]  = thisData;
            op = (thisData.current >= thisData.boundary) ? (byte)1 : (byte)0;
        }
        outputOps[index] = op;
    }
Ejemplo n.º 3
0
    public bool hasSpace(ushort _itemId)
    {
        if (count == 0)
        {
            return(true);
        }

        if (itemId != 0 && _itemId != itemId)
        {
            return(false);
        }
        TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

        return(positions[0] + d.current - itemHalfWidth * 2f >= 0.0f);
    }
Ejemplo n.º 4
0
    // insert an element at random position. not usable yet!
    public void insert(float insertPos)
    {
        TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

        float[] tmpPositions = new float[MaxElement];

        for (int i = 0; i < count; ++i)
        {
            if (i <= currentIndex)
            {
                tmpPositions[i] = positions[i] + d.current;
            }
            else
            {
                tmpPositions[i] = positions[i];
            }
        }
        tmpPositions = null;
    }
Ejemplo n.º 5
0
    public void push(ushort _itemId)
    {
        if (count >= MaxElement)
        {
            return;
        }
        itemId = _itemId;
        if (count > 0)
        {
            TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

            if (positions[0] + d.current - itemHalfWidth * 2f >= 0.0f)
            {
                // refresh distances upto currentIndex.
                updatePositions();
                d.boundary -= d.current;
                d.current   = 0.0f;
                TubeSimulate.self.tubeUpdateData[idxInUpdateArray] = d;

                for (int i = count; i > 0; --i)
                {
                    positions[i] = positions[i - 1];
                }
                positions[0] = 0.0f;
                count++;
                currentIndex++;
                if (currentIndex == 0)
                {
                    transfer();
                }
            }
        }
        else
        {
            positions[0] = 0.0f;
            currentIndex = 0;
            count++;
            transfer();
        }
    }
Ejemplo n.º 6
0
    private void transfer()
    {
        TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

        d.current = 0.0f;
        if (currentIndex >= 0)
        {
            if (currentIndex < count - 1)
            {
                d.boundary = positions[currentIndex + 1] - positions[currentIndex] - itemHalfWidth * 2f;
            }
            else
            {
                d.boundary = length - itemHalfWidth - positions[currentIndex];
            }
            d.speed = speed;
        }
        else
        {
            d.boundary = 0.0f;
            d.speed    = 0.0f;
        }
        TubeSimulate.self.tubeUpdateData[idxInUpdateArray] = d;
    }
Ejemplo n.º 7
0
    public float getOffset()
    {
        TubeUpdateData d = TubeSimulate.self.tubeUpdateData[idxInUpdateArray];

        return(d.current);
    }