Beispiel #1
0
    public void SetMap(BlockMap map)
    {
        this.blockMap = map;

        InitializeStreamingMap(
            BlockUtilities.GetMapWidth(map),
            BlockUtilities.GetMapHeight(map),
            BlockUtilities.GetMapUpperDepth(map) - BlockUtilities.GetMapLowerDepth(map) + 1
            );
    }
Beispiel #2
0
    void RandomlyModifyMap()
    {
        //We'll retrieve the bounds of our map in order to pick a nice random block
        int x = UnityEngine.Random.Range(0, BlockUtilities.GetMapWidth(createdMap));
        int y = UnityEngine.Random.Range(0, BlockUtilities.GetMapHeight(createdMap));

        //The depth is a little different from the width/height, as depth may be negative
        int z = UnityEngine.Random.Range(BlockUtilities.GetMapLowerDepth(createdMap), BlockUtilities.GetMapUpperDepth(createdMap));

        //Here we'll flip a figurative coin to decide if we'll add or remove
        if (UnityEngine.Random.Range(0, 2) == 1)
        {
            //We'll remove a block in this case
            BlockUtilities.RemoveBlockFromMap(createdMap, x, y, z, true, false);
        }
        else
        {
            //Again, we'll create a block
            Block b = GameObject.Instantiate(blockPrefab) as Block;

            //And then add it to the map
            //We'll randomise on addition
            //And pending our CleanMap parameter, we'll refresh the surrounding blocks
            BlockUtilities.AddBlockToMap(createdMap, b, true, 0, true, x, y, z, false, true);
        }
    }