Exemple #1
0
    public override void OnInspectorGUI()
    {
        OverlapWFC generator = (OverlapWFC)target;

        if (generator.training != null)
        {
            if (GUILayout.Button("generate"))
            {
                /*foreach (Transform child in GameObject.Find("staircases").transform)
                 * {
                 *  DestroyImmediate(child.gameObject);
                 * }*/
                //generator.Clear();
                DestroyImmediate(GameObject.Find("staircases"));
                GameObject staircases = new GameObject();
                staircases.name = "staircases";
                staircases.transform.position = new Vector3(0, 0, 0);
                generator.Generate(generator.output);
                generator.Generate(GameObject.Find("output-overlap2"));
            }
            if (generator.model != null)
            {
                if (GUILayout.Button("RUN"))
                {
                    generator.Run();
                }
            }
        }
        DrawDefaultInspector();
    }
Exemple #2
0
    IEnumerator spawnPlayer(OverlapWFC chunk)
    {
        while (chunk.model == null)
        {
            Debug.Log("waiting");
            yield return(new WaitForSeconds(0.1f));
        }
        GameObject tile = chunk.findGoodTileForSpawning(30);

        player.transform.position = tile.transform.position + new Vector3(0, 4, 0);
        Debug.Log(tile.transform.position);
        Debug.DrawLine(tile.transform.position, tile.transform.position + new Vector3(0, 10, 0), Color.red, 1000);
    }
Exemple #3
0
    private void Start()
    {
        player       = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
        grid         = new Dictionary <int, Dictionary <int, GameObject> >();
        gridBooleans = new Dictionary <int, Dictionary <int, bool> >();
        generateAt(0, 0);
        OverlapWFC chunk = getChunkAt(0, 0).GetComponent <OverlapWFC>();

        StartCoroutine(spawnPlayer(chunk));
        instance = this;

        GameObject o = getChunkAt(0, 0);
    }
Exemple #4
0
    public static void PruneMiddle(GameObject container, int x, int y)
    {
        OverlapWFC WFC    = container.GetComponent <OverlapWFC>();
        int        width  = WFC.rendering.GetLength(0);
        int        height = WFC.rendering.GetLength(1);

        for (int i = width / 2 - x / 2; i < width / 2 + x / 2; i++)
        {
            for (int j = height / 2 - y / 2; j < height / 2 + y / 2; j++)
            {
                GameObject tile = WFC.rendering[i, j];
                GameObject.Destroy(tile);
            }
        }
    }
Exemple #5
0
    private void generateAt(int x, int z)
    {
        OverlapWFC chunk = Instantiate(mapChunkPrefab).GetComponent <OverlapWFC>();

        chunk.transform.parent   = transform;
        chunk.transform.position = new Vector3(x * chunkSize, 0, z * chunkSize);
        chunk.xloc = x;
        chunk.zloc = z;

        if (AddToPos(x, z, chunk.gameObject))
        {
            return;
        }
        Destroy(chunk);
    }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        map = new GameObject[3, 3];
        UnityEngine.Random.seed = (int)System.DateTime.Now.Ticks;
        initial_seed            = UnityEngine.Random.Range(0, Int32.MaxValue);
        initial_seed_x          = UnityEngine.Random.Range(0, Int32.MaxValue);
        initial_seed_y          = UnityEngine.Random.Range(0, Int32.MaxValue);

        InstantiateChunk(0, 0, 1, 1);

        output_settings = map[1, 1].GetComponent <OverlapWFC> ();
        width           = width_output * gridsize_output;
        length          = length_output * gridsize_output;

        center_x = 0;
        center_y = 0;
    }
Exemple #7
0
    GameObject InstantiateChunk(float pos_x, float pos_y, int i, int j)
    {
        map [i, j]      = Instantiate(output_prefab) as GameObject;
        output_settings = map[i, j].GetComponent <OverlapWFC> ();

        output_settings.training = input_map;
        output_settings.seed     = random_from_xy(pos_x, pos_y);
        output_settings.width    = width_output;
        output_settings.depth    = length_output;
        output_settings.gridsize = gridsize_output;
        output_settings.Generate();

        Transform t = map [i, j].transform;

        t.position = new Vector3(pos_x, pos_y, 0f);


        return(map [i, j]);
    }
    public override void OnInspectorGUI()
    {
        OverlapWFC generator = (OverlapWFC)target;

        if (generator.training != null)
        {
            if (GUILayout.Button("generate"))
            {
                generator.Generate();
            }
            if (generator.model != null)
            {
                if (GUILayout.Button("RUN"))
                {
                    generator.Run();
                }
            }
        }
        DrawDefaultInspector();
    }
    public void Execute()
    {
        OverlapWFC c = chunk.GetComponent <OverlapWFC>();

        c.enabled = true;
    }