Exemplo n.º 1
0
    public void RandomSpawn()
    {
        do
        {
            bkey     = false;
            rnd_vect = new Vector2(Random.Range(-20.0f, 20.0f), Random.Range(-10.0f, 10.0f)); // вставь размер карты

            foreach (Vertex ver in GlobalGraph.vertices)
            {
                if (ver == null)
                {
                }
                else if ((rnd_vect - ver.coords).magnitude < 5.0f)
                {
                    bkey = true;
                }
            }
        } while (bkey);



        BasicProduction newFactory = Instantiate(Prefabs[Random.Range(0, Prefabs.Length)], rnd_vect, Quaternion.identity);


        newFactory.vert_id = GlobalGraph.numVerts;
        newFactory.coords  = newFactory.transform.position;
        newFactory.name    = newFactory.vert_id.ToString();

        GlobalGraph.AddVertex(GlobalGraph.numVerts, newFactory);



        //GlobalGraph.Show_matrix();
    }
Exemplo n.º 2
0
    public void RandomSpawn(int i)
    {
        Vector2         rnd_vect   = new Vector2(Random.Range(-30.0f, 30.0f), Random.Range(-20.0f, 20.0f));
        BasicProduction newFactory = Instantiate(Prefabs[i], rnd_vect, Quaternion.identity);


        newFactory.vert_id = GlobalGraph.numVerts;
        newFactory.coords  = newFactory.transform.position;
        newFactory.name    = newFactory.vert_id.ToString();

        GlobalGraph.AddVertex(GlobalGraph.numVerts, newFactory);
    }