예제 #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        cc      = GameObject.FindObjectOfType <CameraController>().GetComponent <Camera>();
        markers = GameObject.FindObjectsOfType <CityBorderMarker>();
        //Find initial ground
        RaycastHit hitC;

        if (Physics.Linecast(cc.transform.position, transform.position, out hitC, cityFoundation))
        {
            //print(hitC.collider.gameObject.name + " C");
            if (currentGround != hitC.collider.gameObject)
            {
                currentGround = hitC.collider.gameObject;
            }
        }
        //Find City Border Markers
        foreach (CityBorderMarker c in markers)
        {
            if (c.right)
            {
                rightEdge = c.transform;
            }
            else
            {
                leftEdge = c.transform;
            }
        }
        //load all ground types
        foreach (GameObject g in Resources.LoadAll("TestStuff/Grounds", typeof(GameObject)))
        {
            if (g.GetComponent <Grounds>().spawnBuildings)
            {
                cityGroundsSpawnable.Add(g);
            }
            else
            {
                cityGrounds.Add(g);
            }
        }
        //load all building types
        foreach (GameObject g in Resources.LoadAll("TestStuff/Buildings/Foundations", typeof(GameObject)))
        {
            buildings.Add(g);
        }
        nextStreetIn = 0;
    }
 // Use this for initialization
 void Start()
 {
     csm = GameObject.FindObjectOfType <CitySpawnManager>();
     cc  = GameObject.FindObjectOfType <CameraController>().GetComponent <Camera>();
 }