コード例 #1
0
    // Use this for initialization
    void Start()
    {
        //Error Checking
        if (startArea == null)
        {
            Debug.LogError("LevelManager: Start Area Null");
        }

        if (!areas.Contains(startArea))
        {
            Debug.LogError("LevelManager: Start Area not listed in areas");
        }

        //Variable Initialization
        player = GameObject.FindGameObjectWithTag("Player").transform;

        //Initialize the positions
        currentAreaIndex = areas.IndexOf(startArea);
        currentArea      = startArea;

        position = new Vector3(0, 0, 0);
        startArea.transform.position = position;
        //Debug.Log("Index: " + currentAreaIndex + "; Width: " + currentArea.getWidth());


        //Panels to the right
        position.x = currentArea.getWidth() / 2.0f;
        for (int i = currentAreaIndex + 1; i < areas.Count; i++)
        {
            position.x += areas[i].getWidth() / 2.0f;
            areas[i].transform.position = position;
            position.x += areas[i].getWidth() / 2.0f;
            //Debug.Log("Index: " + areas[i].name + "; Width: " + areas[i].getWidth());
        }

        //Panels to the left
        position.x = 0 - currentArea.getWidth() / 2.0f;
        for (int i = currentAreaIndex - 1; i >= 0; i--)
        {
            position.x -= areas[i].getWidth() / 2.0f;
            areas[i].transform.position = position;
            position.x -= areas[i].getWidth() / 2.0f;
            //Debug.Log("Index: " + i + "; Width: " + areas[i].getWidth());
        }
    }