diff --git a/v3.0/doc/getting-started.md b/v3.0/doc/getting-started.md index b5eba48..099f97d 100644 --- a/v3.0/doc/getting-started.md +++ b/v3.0/doc/getting-started.md @@ -36,7 +36,7 @@ Now you can run to see your map: directional: JoystickDirectional(), ), // required map: WorldMapByTiled( - TiledReader.asset('tile/map.json') + WorldMapReader.fromAsset('tile/map.json') ), ); } @@ -113,7 +113,9 @@ Now you just need add your player in the game: joystick: Joystick( directional: JoystickDirectional(), ), - map: WorldMapByTiled('tile/map.json'), + map: WorldMapByTiled( + WorldMapReader.fromAsset('tile/map.json') + ), player: Knight(Vector2(40,40)) ); } diff --git a/v3.0/doc/map.md b/v3.0/doc/map.md index 00aebbf..75c1d97 100644 --- a/v3.0/doc/map.md +++ b/v3.0/doc/map.md @@ -11,21 +11,20 @@ It is a matrix of small tiles that toghether assembles the map as seen below: We currently recommend creating the map using [Tiled](https://www.mapeditor.org/). For that we use `WorldMapByTiled` in `BonfireWidget` in the `map` parameter: ```dart -WorldMapByTiled(TiledReader.asset('tile/map.json'), forceTileSize: Size(32,32)) +WorldMapByTiled(WorldMapReader.fromAsset('tile/map.json')) ``` The first parameter (`tile/map.json`) is the path of the `.json` file exported by Tiled. > IMPORTANT: Bonfire only supports .json files. -The second parameter (`Size(32,32)`) is optional and determines the size of each Tile on the map (squares). If not set it takes the default size defined by your TileSet. - You can load a map from url. Just pass the url in path. Example: ```dart WorldMapByTiled( - TiledReader.network( Uri.parse('https://raw.githubusercontent.com/RafaelBarbosatec/rafaelbarbosatec.github.io/master/tiled/my_map.json')), - forceTileSize: Size(32,32), + WorldMapReader.fromNetwork( + Uri.parse('https://raw.githubusercontent.com/RafaelBarbosatec/rafaelbarbosatec.github.io/master/tiled/my_map.json') + ), ) ``` @@ -36,8 +35,7 @@ You can add objects like [Decorations](doc/decoration?id=decoration) and [Enemie ```dart return BonfireWidget( map: WorldMapByTiled( - TiledReader.asset('tiled/map.json'), - forceTileSize: Size(32,32), + WorldMapReader.fromAsset('tiled/map.json'), objectsBuilder: { 'orc': (TiledObjectProperties properties) => Orc(properties.position), }, @@ -85,18 +83,22 @@ To use this resource is very easy: return BonfireWidget( map: MatrixMapGenerator.generate( axisInverted: true, - matrix: [ - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + layers: [ + MatrixLayer( + matrix: [ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + ], + ) ], builder: (ItemMatrixProperties prop){ @@ -220,18 +222,22 @@ After that you pass the 'build' method of the `terrainBuilder` to `builder`: return BonfireWidget( map: MatrixMapGenerator.generate( axisInverted: true, // This is `true` to create the map same as seen in the matrix. Because the normal axis is `matrix[x][y]`, When `axisInverted` is `true` it's turn `matrix[y][x]` - matrix: [ - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], - [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + layers: [ + MatrixLayer( + matrix: [ + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + ], + ) ], builder: terrainBuilder.build, ), diff --git a/v3.0/doc/mixins.md b/v3.0/doc/mixins.md index f6caedb..6155826 100644 --- a/v3.0/doc/mixins.md +++ b/v3.0/doc/mixins.md @@ -237,22 +237,23 @@ Adds these methods in your component: void addLife(double life) void updateLife(double life,{bool verifyDieOrRevive = true}) void removeLife(double life) - - /// This method is used to check if this component can receive damage from any attacker. - @override - bool checkCanReceiveDamage( - AttackFromEnum attacker, - double damage, - dynamic from, - ) /// You can listen if this component receive attack + // If returns true, this component received damage. @override - void receiveDamage(double damage, dynamic from) + bool receiveDamage( + AttackOriginEnum attacker, + double damage, + dynamic identify, + ) /// If your life stay minor than 0 this method is called @override - void die() + void onDie() + + /// If you dead and revive + @override + void onRevive() ``` ## Vision diff --git a/v3.0/doc/tiled_support.md b/v3.0/doc/tiled_support.md index c2e96bc..8ce4ec9 100644 --- a/v3.0/doc/tiled_support.md +++ b/v3.0/doc/tiled_support.md @@ -41,7 +41,7 @@ For maps built with Tiled we must use the Widget `BonfireWidget` (example [here] directional: JoystickDirectional() ), map: WorldMapByTiled( - TiledReader.asset('tiled/map.json'), + WorldMapReader.fromAsset('tiled/map.json'), forceTileSize: DungeonMap.tileSize, // if you want to force the size of the Tile to be larger or smaller than the original objectsBuilder: { 'goblin': (TiledObjectProperties properties) => Goblin(properties.position), @@ -73,7 +73,7 @@ You can storage your map files in a server and load. Just load using `TiledReade directional: JoystickDirectional() ), map: WorldMapByTiled( - TiledReader.network( + WorldMapReader.fromNetwork( Uri.parse('http://rafaelbarbosatec.github.io/tiled/my_map.json'), // cacheProvider: TiledMemoryCacheProvider() ),