Ejemplo 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;
    }
Ejemplo n.º 2
0
    void addTail()
    {
        //修改其他元素序號
        // 0 1 2 3 4 變成
        //-1 0 1 2 3
        foreach (EndlessCorridorHolder element in createlist)
        {
            element.ListIndex = element.ListIndex - 1;
        }

        //刪除Head元素
        createlist.RemoveFirst();
        Destroy(Head.gameObject);
        Head = createlist.First.Value;

        EndlessCorridorHolder newObj = createEcByRef(createSize - 1, Tail, Tail.getTailDummy(), 0.5f);

        createlist.AddLast(newObj);
        Tail = newObj;
    }