Beispiel #1
0
    void Start()
    {
        le.Init();
        if (!isOn)
        {
            return;
        }


        for (int i = 0; i < le.GetRoadCountWidth() * le.GetRoadCountHeight(); i++)
        {
            GameObject obj = m_vert;
            Vector2    pos = le.GetVert(i).pos;
            bool       act = le.GetVert(i).active;

            obj.transform.position = pos;
            vVerts[i] = Instantiate(obj);
            if (act)
            {
                vVerts[i].GetComponent <MeshRenderer>().material = on;
            }
        }
        VBuilds.Vertices tempVert = le.GetRootVert();
        for (int i = 0; i < 12; i++)
        {
            le.NextVert();
        }
        ChangeColour(vVerts, le);
    }
    void Start()
    {
        inGameUnitsSize = sizeOfRoad / pPixels;
        Size            = Height * Width;

        roads = new RoadManager.Roads[Size];

        build.Init(Height, Width, RoadLength);
        roadManager.InitRoadArray(ref roads);

        //Init the root vert/road//
        roads[0].m_GameObjectPrefabType = PrefavStrRoad;
        roads[0].pos = build.GetRootVert().pos *inGameUnitsSize;
        roads[0].m_GameObjectPrefabType.transform.localPosition = roads[0].pos;

        Debug.Log(roads[0].m_GameObjectPrefabType.transform.rotation);
        roads[0].m_GameObjectInstance = Instantiate(roads[0].m_GameObjectPrefabType);

        //Debug.Log(build.GetRealativePosition(new Vector2(3, 3), new Vector2(3, 6)));
        for (int i = 0; i < build.GetPathLength(); i++)
        {
            build.NextVert();
        }
        CreateNextRoad();
        roads[0].m_GameObjectInstance.transform.rotation = roadManager.GetRoadDirection(Vector2.zero, build.GetRootVert().pos, build.GetVertPath(1).pos);
        //Create EndRoad


        //Fill the rest of the world - Tree
        int[] m_tree = build.GetStatusIntArr(false);
        int[] m_rock = build.GetStatusIntArr(true);
        m_Trees = new GameObject[m_tree.Length];
        m_Rock  = new GameObject[m_rock.Length];
        for (int i = 0; i < m_rock.Length; i++)
        {
            VBuilds.Vertices temp = build.GetVert(m_rock[i]);
            if (temp.pathIndex == -1)
            {
                Vector2 pos = temp.pos * inGameUnitsSize;
                m_Rock[i] = PrefavRock;
                m_Rock[i].transform.position = pos;
                Instantiate(m_Rock[i]);
            }
        }
        for (int i = 0; i < m_tree.Length; i++)
        {
            Vector2 pos = build.GetVert(m_tree[i]).pos *inGameUnitsSize;
            m_Trees[i] = PrefavTree;
            m_Trees[i].transform.position = pos;
            //PrefavTree.transform.position = pos;
            Instantiate(m_Trees[i]);
        }
    }