public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        CaveGenerator c = (CaveGenerator)target;

        if (GUILayout.Button("Generate"))
        {
            c.Generate();
        }
    }
예제 #2
0
    void GenerateCave()
    {
        CaveGenerator caveGenerator = terrain.GetComponent <CaveGenerator>();

        caveGenerator.Generate();
        CaveGenerator.Point?point = caveGenerator.FindNearestSpace(caveGenerator.currentMap, new CaveGenerator.Point(0, 0));       //Find nearest clear point to bottom corner of map
        if (point.HasValue)
        {
            player.position = new Vector3(point.Value.x, point.Value.y, player.position.z) + terrain.position;                     //Terrain transform may not be at zero so map coordinates will be offset by its position
        }
    }
    private IEnumerator PerformRegen()
    {
        yield return(new WaitForEndOfFrame());

        CaveGenerator    caveGen    = FindObjectOfType <CaveGenerator>();
        GrammarGenerator grammarGen = FindObjectOfType <GrammarGenerator>();

        caveGen.Generate();
        grammarGen.Generate();
        earnedLevelLife = false;
        Respawn();
        loadSplash.SetActive(false);
        gameState   = GameState.PLAYING;
        regenQueued = false;
    }
예제 #4
0
    private void MapGeneration()
    {
        CaveGeneratorFactory factory = new CaveGeneratorFactory();

        ThreeTierCaveConfiguration ttcc = new ThreeTierCaveConfiguration();

        ttcc.CaveType = ThreeTierCaveType.Enclosed;

        AKSaigyouji.Modules.HeightMaps.HeightMapRocky ceiling_gen   = new AKSaigyouji.Modules.HeightMaps.HeightMapRocky();
        AKSaigyouji.HeightMaps.LayeredNoiseParameters ceiling_param = new AKSaigyouji.HeightMaps.LayeredNoiseParameters();
        ceiling_param.SetHeightRange(MIN_WALL, MAX_WALL);
        ceiling_param.SetSmoothness(10);
        ceiling_param.SetLayers(4, 0.5f, 2f);
        ceiling_gen.Properties      = ceiling_param;
        ttcc.CeilingHeightMapModule = ceiling_gen;
        ttcc.CeilingMaterial        = ceiling;

        AKSaigyouji.Modules.HeightMaps.HeightMapConstant floor_gen = new AKSaigyouji.Modules.HeightMaps.HeightMapConstant();
        floor_gen.Height          = 0;
        ttcc.FloorHeightMapModule = floor_gen;
        ttcc.FloorMaterial        = floor;

        ttcc.WallModule   = new AKSaigyouji.Modules.CaveWalls.CaveWallFlat();
        ttcc.WallMaterial = wall;

        AKSaigyouji.Modules.MapGeneration.MapGenCellAutomata map_gen = new AKSaigyouji.Modules.MapGeneration.MapGenCellAutomata();
        AKSaigyouji.Modules.MapGeneration.MapParameters      param   = new AKSaigyouji.Modules.MapGeneration.MapParameters
        {
            Length         = 100,
            Width          = 100,
            InitialDensity = 0.5f,
            ExpandTunnels  = true,
            BorderSize     = 1,
            MinWallSize    = 15,
            MinFloorSize   = 15
        };
        map_gen.Properties = param;
        ttcc.MapGenerator  = map_gen;

        ttcc.Scale = 2;

        ttcc.SetSeed(seed);

        CaveGenerator cg = factory.BuildThreeTierCaveGen(ttcc);
        //CaveGenerator cg = new MyCaveGenerator(ttcc);

        GameObject map = cg.Generate();
    }
    public override void OnInspectorGUI()
    {
        DrawProperties();
        serializedObject.ApplyModifiedProperties();

        CaveGenerator caveGenerator = (CaveGenerator)target;

        if (Application.isPlaying)
        {
            if (GUILayout.Button("Generate New Map"))
            {
                caveGenerator.Generate();
            }

            if (GUILayout.Button("Create Prefab"))
            {
                CreatePrefab(caveGenerator);
            }
        }
    }
 void OnTriggerEnter2D(Collider2D col)
 {
     if(col.gameObject.CompareTag("Player"))
     {
         Debug.Log("Player passed trigger");
         if(prev)
         {
             Destroy(prev.gameObject);
         }
         prev = terrain;
         terrain = next;
         transform.position += new Vector3(36f, 0f, 0f);
         GameObject nextGO = (GameObject)Instantiate(terrainPrefab, transform.position, Quaternion.identity);
         next = nextGO.transform;
         nextCaveGenerator = next.GetComponent<CaveGenerator>();
         //nextHillGenerator = next.GetComponent<HillGenerator>();
         nextPlatformGenerator = next.GetComponent<PlatformGenerator>();
         nextCaveGenerator.Generate();
         nextPlatformGenerator.Append();
     }
 }