コード例 #1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Generate"))
        {
            GroundGenerator theBigG = (GroundGenerator)target;
            theBigG.Generate();
        }
    }
コード例 #2
0
    public void Regenerate()
    {
        if (generatorInstance)
        {
            generatorInstance.Clear();
            DestroyImmediate(generatorInstance);
        }
        generatorInstance = Instantiate(generator);

        Vector2Int worldSize = generatorInstance.GetWorldSize();

        generatorSpec = new HoleGroundGenerator(stoneTile, new List <Rect> {
            new Rect(16, worldSize.y - 32, 32, 32),
            new Rect(15, worldSize.y - 31, 34, 32),
            new Rect(14, worldSize.y - 30, 36, 32),
            new Rect(14, worldSize.y - 30, 36, 32),
            InvertRectY(new Rect(42, 32, 5, 6)),
            InvertRectY(new Rect(26, 36, 18, 2)),
            InvertRectY(new Rect(12, 38, 18, 4)),
            InvertRectY(new Rect(12, 38, 2, 10)),
            InvertRectY(new Rect(12, 48, 30, 10)),
            InvertRectY(new Rect(42, 48, 10, 2)),
            InvertRectY(new Rect(52, 48, 2, 14)),
            InvertRectY(new Rect(42, 60, 10, 2)),
            InvertRectY(new Rect(26, 60, 16, 2)),
            InvertRectY(new Rect(12, 60, 16, 8)),
            InvertRectY(new Rect(10, 60, 2, 20)),
            InvertRectY(new Rect(12, 79, 2, 1)),
            InvertRectY(new Rect(14, 79, 20, 10)),
            InvertRectY(new Rect(34, 79, 4, 2)),
            InvertRectY(new Rect(36, 81, 2, 30)),
            InvertRectY(new Rect(10, 93, worldSize.x - 20, 29)),
        }, new Vector2Int(18, worldSize.y - 29), new List <HoleGroundGenerator.CustomGenerator>
        {
            (seed, position) =>
            {
                Rect[] boulders = new Rect[]
                {
                    new Rect(14, 40, 2, 2),
                    new Rect(20, 40, 2, 2),
                    new Rect(26, 40, 2, 2),
                    new Rect(12, 50, 2, 8),
                    new Rect(14, 52, 2, 6),
                    new Rect(16, 54, 2, 4),
                    new Rect(18, 56, 2, 2),
                    new Rect(22, 52, 2, 2),
                    new Rect(26, 52, 2, 2),
                    new Rect(30, 52, 2, 2),
                    new Rect(34, 52, 2, 2),
                    new Rect(38, 52, 2, 2),
                    new Rect(42, 52, 2, 2),
                    new Rect(26, 64, 2, 4),
                    new Rect(24, 66, 2, 2),
                    new Rect(20, 67, 2, 1),
                    new Rect(16, 67, 2, 1),
                    new Rect(12, 67, 2, 1),
                    new Rect(14, 82, 2, 7),
                    new Rect(24, 85, 2, 2),

                    new Rect(28, 83, 2, 2),
                };

                foreach (Rect boulder in boulders)
                {
                    if (InvertRectY(boulder).Contains(position))
                    {
                        return(stoneTile);
                    }
                }

                Rect[] lavaSpots = new Rect[]
                {
                    new Rect(31, 32, 10, 3),
                    new Rect(50, 62, 2, 2),
                    new Rect(46, 62, 2, 2),
                    new Rect(42, 62, 2, 2),
                    new Rect(38, 62, 2, 2),
                    new Rect(34, 62, 2, 2),
                    new Rect(30, 62, 2, 2),
                    new Rect(22, 68, 2, 2),
                    new Rect(18, 68, 2, 2),
                    new Rect(14, 68, 2, 2),
                    new Rect(16, 89, 18, 2)
                };

                foreach (Rect lava in lavaSpots)
                {
                    if (InvertRectY(lava).Contains(position))
                    {
                        return(lavaTile);
                    }
                }


                if ((position.x == 17 || position.x == 18) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(moveInstructionTile);
                }
                if ((position.x == 21 || position.x == 22) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(jumpInstructionTile);
                }
                if ((position.x == 25 || position.x == 26) && (position.y == worldSize.y - 32 || position.y == worldSize.y - 31))
                {
                    return(shootInstructionTile);
                }
                if ((position.x >= 29 && position.x <= 30) && (position.y >= (worldSize.y - 32) && position.y <= (worldSize.y - 31)))
                {
                    return(stoneTile);
                }

                return(null);
            }
        });

        generatorInstance.Generate(0, generatorSpec);
    }
コード例 #3
0
ファイル: MapGenerator.cs プロジェクト: AkpoFlash/Bomberman
    public void AddGround(GameObject gameObject)
    {
        GroundGenerator ground = new GroundGenerator();

        ground.Generate(gameObject);
    }