Пример #1
0
    public override void _Ready()
    {
        MainMap = this;

        //Gets tilemap children
        BlockMap = (BlockMap)GetNode("BlockMap");
        TileMap  = (TileMap)GetNode("TileMap");
        ThingMap = (ThingMap)GetNode("ThingMap");

        BlockMapTiles = BlockMap.Map;
        TileMapTiles  = TileMap.Map;
        //ThingMapTiles = ThingMap.Map; <- ???

        if (new Tile().GetBlocks().Find(x => x.Name.ToLower() == "grass_block" && x.GetType() == typeof(Tile)) is Tile tile)
        {
            TileMap.Fill(Option.Some(tile));
        }

        //else throw new Exception("NO_GRASS_TILE_FOUND");

        // Adding pre applied blocks
        for (int x = 0; x < BlockMap.Map.GetLength(0); x++)
        {
            for (int y = 0; y < BlockMap.Map.GetLength(1); y++)
            {
                BlockMap.Map[x, y] = BlockMap.GetCell(x, y) == -1 ? Option.None <Wall>() : Option.Some(new Wall()
                {
                    Name = ""
                });
            }
        }

        if (new Wall().GetBlocks().Find(x => x.Name.ToLower() == "mine" && x.GetType() == typeof(Wall)) is Wall bloc2k)
        {
            BlockMap.SetBlock(3, 3, Option.Some(bloc2k));
        }

        if (new Wall().GetBlocks().Find(x => x.Name.ToLower() == "mine" && x.GetType() == typeof(Wall)) is Wall block)
        {
            BlockMap.SetBlock(2, 2, Option.Some(block));
        }


        CollisionFor("link.png", Shape.Capsule).MatchSome(x => SpawnBeing(new Robot("Ribbit")
        {
            Speed = 3
        }, new Vector2(50, 50), "link.png", new Vector2(0.2f, 0.2f), x));
        CollisionFor("link.png", Shape.Capsule).MatchSome(x => SpawnBeing(new Robot("Snakeoil")
        {
            Speed = 3
        }, new Vector2(100, 100), "link.png", new Vector2(0.2f, 0.2f), x));
    }