示例#1
0
    public void create()
    {
        delete();
        //----------buildling para
        //height
        h = Mathf.Max((int)(height_max * globalpara.Instance.getValue(parameters.height)), 1);          //mathf.max so it'll never be 0

        //bounds
        r = Mathf.Max((int)(row_max * globalpara.Instance.getValue(parameters.width)), 1);          //mathf.max so it'll never be 0
        c = Mathf.Max((int)(col_max * globalpara.Instance.getValue(parameters.depth)), 1);          //mathf.max so it'll never be 0

        //fidelity
        float fidelity = globalpara.Instance.getValue(parameters.fidelity);

        room_size_max = Mathf.Max((int)(fidelity * Mathf.Min(r, c)), 1);

        //chaos
        //variation in room size/dimensions
        float chaos = globalpara.Instance.getValue(parameters.rooms);

        room_height_max = room_height_min + (int)(chaos * h);
        room_size_min   = Mathf.Max(room_size_max - (int)(room_size_max * chaos), 1);

        //density
        density_updown = Mathf.Max(globalpara.Instance.getValue(parameters.up_down), 0.1f);
        density_inout  = Mathf.Max(globalpara.Instance.getValue(parameters.in_out), 0.1f);

        //---------struct para
        //floor thickness
        floorThickness = globalpara.Instance.getValue(parameters.thickness);

//		Debug.Log("height: "+h+"\nbounds, rows&cols: "+r+", "+c+"\n"+"fidelity, max room size: "+room_size_max+
//					"\nchaos, room height min, max: "+room_height_min+","+room_height_max+
//					", min room size: "+room_size_min+
//					"\ndensity: "+density);

        globalpara.Instance.resetGreen();
        globalpara.Instance.resetPeople();

        initialize();
        clear();

        for (int i = 0; i < h; i++)
        {
            if (i == 0 || Random.Range(0f, 1f) < density_updown)
            {
                randomPlacement(i);
            }
        }

        // NO DELAY
        connScript.InitializeConnections();
        // DELAY
        //Invoke("InitConnections", 0.1f);


        if (globalpara.Instance.getPeople() < 5)
        {
            globalpara.Instance.setState(events.less5people, true);
        }
        if (globalpara.Instance.getGreen() > 25)
        {
            globalpara.Instance.setState(events.more25trees, true);
        }
        if (peopleOnTop < 1)
        {
            globalpara.Instance.setState(events.nopeopletop, true);
        }
    }