Ejemplo n.º 1
0
    public void LoadsProceduralBuilding()
    {
        GameObject            gameObject = new UnityEngine.GameObject();
        Transform             transform  = gameObject.transform;
        int                   seed       = 1234;
        int                   floors     = 3;
        DistrictConfiguration config     = new DistrictConfiguration();

        ProceduralBuilding building = new ProceduralBuilding(transform, Vector3.left, seed, floors, config);

        ProceduralBuilding.Generator = new ProceduralBuildingCreator();
    }
 void Changed(ProceduralBuilding aux)
 {
     EditorUtility.SetDirty(aux);
     if (aux.roof)
     {
         EditorUtility.SetDirty(aux.roof);
     }
     if (aux.groundFloor)
     {
         EditorUtility.SetDirty(aux.groundFloor);
     }
     foreach (var item in aux.floors)
     {
         EditorUtility.SetDirty(item);
     }
 }
Ejemplo n.º 3
0
    void GenerateBuildings(List <GraphLinked.Cell> cells)
    {
        foreach (GraphLinked.Cell cell in cells)
        {
            float area = cell.Area;
            //if (area < 4000  && area >500)
            {
                ProceduralBuilding building = Instantiate(buildingTemplate);
                building.transform.parent   = this.transform;
                building.transform.position = cell.Center;
                int height = (int)(area / 1000 * 5);

                building.Generate(cell.localContour.ToArray(), height, new Vector2(Random.Range(1, 2), Random.Range(1, 2)));
            }
        }
    }
Ejemplo n.º 4
0
    public void ConstructsProceduralBuilding()
    {
        GameObject            gameObject = new UnityEngine.GameObject();
        Transform             transform  = gameObject.transform;
        int                   seed       = 1234;
        int                   floors     = 3;
        DistrictConfiguration config     = new DistrictConfiguration();

        ProceduralBuilding building = new ProceduralBuilding(transform, Vector3.left, seed, floors, config);

        Assert.AreEqual(building.Parent, transform);
        Assert.AreEqual(building.Position, Vector3.left);
        Assert.AreEqual(building.NumberOfFloors, floors);
        Assert.AreEqual(building.Configuration, config);
        Assert.AreEqual(building.Seed, seed);
        Assert.AreEqual(building.IsLoaded, false);
        Assert.NotNull(building.Attachments);
        Assert.IsNull(building.Instance);
    }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    public void Start()
    {
        seed          = 42; // I trust this number will yield the best possible version of my city
        voids         = new List <MeshCollider>();
        voidsOther    = new List <MeshCollider>();
        potentialJobs = new List <Job>();
        currentJobs   = new List <Job>();
        activeJobs    = new List <Job>();
        pBuilding     = new ProceduralBuilding(buildingFootPrint, multiplierSpacing, this);
        CityGen();

        army = new Army(this);


        //initiating one potential job between the 'WakeCity' coroutine
        var j1 = new Job(this);

        potentialJobs.Add(j1);
        totalJobIndices.AddRange(j1.indices);
    }
    public override void OnInspectorGUI()
    {
        aux = (ProceduralBuilding)target;

        EditorGUILayout.PropertyField(floors);
        EditorGUILayout.PropertyField(grounds);
        EditorGUILayout.PropertyField(roofs);
        serializedObject.ApplyModifiedProperties();
        if (!aux.floorsData)
        {
            return;
        }

        if (aux.floors == null || aux.floors.Count == 0 || aux.floors[0] == null)
        {
            aux.UpdatePositions();
        }

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Floor"))
        {
            int id = 0;
            if (aux.floors != null && aux.floors.Count != 0 && aux.floors[0] != null)
            {
                id = aux.floors[aux.floors.Count - 1].id;
            }
            aux.Add(id);
            Changed(aux);
        }
        if (GUILayout.Button("Remove Floor"))
        {
            aux.Remove();
            Changed(aux);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Increase Size"))
        {
            aux.Increase();
            Changed(aux);
        }
        if (GUILayout.Button("Decrease Size"))
        {
            aux.Decrease();
            Changed(aux);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Previous Floor"))
        {
            aux.Previous();
            Changed(aux);
        }
        if (GUILayout.Button("Next Floor"))
        {
            aux.Next();
            Changed(aux);
        }
        GUILayout.EndHorizontal();


        if (GUILayout.Button("Update"))
        {
            aux.UpdatePositions();
            Changed(aux);
        }

        GUILayout.BeginHorizontal();
        aux.fillLeft       = GUILayout.Toggle(aux.fillLeft, "Left");
        aux.fillRight      = GUILayout.Toggle(aux.fillRight, "Right");
        aux.fillFront      = GUILayout.Toggle(aux.fillFront, "Front");
        aux.fillBack       = GUILayout.Toggle(aux.fillBack, "Back");
        aux.fillRoof       = GUILayout.Toggle(aux.fillRoof, "Roof");
        aux.fillBaseGround = GUILayout.Toggle(aux.fillBaseGround, "Ground");
        GUILayout.EndHorizontal();
    }