Exemplo n.º 1
0
    void initEC()
    {
        createlist = new LinkedList <EndlessCorridorHolder>();

        //建立最中間的
        EndlessCorridorHolder prefab  = getRandomEndlessCorridorPrefab();
        EndlessCorridorHolder initObj = (EndlessCorridorHolder)GameObject.Instantiate(prefab, Vector3.zero, Quaternion.Euler(-90, 0, 0));

        halfIndex = createSize / 2;
        initObj.initEC(halfIndex, this, doRescale);
        createlist.AddLast(initObj);

        //add head
        EndlessCorridorHolder refObj = initObj;

        for (int i = halfIndex - 1; i >= 0; i--)
        {
            EndlessCorridorHolder newObj = createEcByRef(i, refObj, refObj.getHeadDummy(), 2.0f);
            createlist.AddFirst(newObj);

            refObj = newObj;
        }
        Head = refObj;

        // add tail
        refObj = initObj;
        for (int i = halfIndex + 1; i < createSize; i++)
        {
            EndlessCorridorHolder newObj = createEcByRef(i, refObj, refObj.getTailDummy(), 0.5f);
            createlist.AddLast(newObj);

            refObj = newObj;
        }
        Tail = refObj;
    }
Exemplo n.º 2
0
    EndlessCorridorHolder createEcByRef(int index, EndlessCorridorHolder refObj, Transform dummy, float ScaleValue)
    {
        float nowScale = refObj.getGlobalScale() * ScaleValue;
        EndlessCorridorHolder nowPrefab = getRandomEndlessCorridorPrefab();
        EndlessCorridorHolder newObj    = (EndlessCorridorHolder)GameObject.Instantiate(nowPrefab, dummy.position, dummy.rotation);

        newObj.transform.localScale = new Vector3(nowScale, nowScale, nowScale);
        newObj.initEC(index, this, doRescale);
        return(newObj);
    }