예제 #1
0
    public void SpawnNodes(PolySet water)
    {
        List <Vector3> spawnPoints = new List <Vector3>();
        List <Polygon> _water      = new List <Polygon>(water);

        for (int i = 0; i < m_NumberOfShops; i++)
        {
            Polygon poly = _water[Random.Range(0, water.Count)];
            Vector3 ab   = m_Vertices[poly.m_Vertices[1]] - m_Vertices[poly.m_Vertices[0]];
            Vector3 ac   = m_Vertices[poly.m_Vertices[2]] - m_Vertices[poly.m_Vertices[0]];

            Vector3 normal = Vector3.Cross(ab, ac).normalized;

            Vector3 shopToPlace = m_PlanetMesh.transform.TransformPoint(normal);
            if (checkShopDistance(shopToPlace, spawnPoints))
            {
                spawnPoints.Add(shopToPlace);
            }
            else
            {
                i--;
                m_shopRangeMin -= 0.02f;
            }
        }

        m_nodeController.GenerateNodes(_nodePrefab, spawnPoints, m_PlanetMesh.transform);
    }