(prop &mut :Player player null) (prop &mut :FlxOgmo3Loader map null) (prop &mut :FlxTilemap walls null) (prop &mut :FlxTypedGroup coins null) (prop &mut :FlxTypedGroup enemies null) (method &override :Void create [] (set map (new FlxOgmo3Loader AssetPaths.turnBasedRPG__ogmo AssetPaths.room_001__json)) (set walls (map.loadTilemap AssetPaths.tiles__png "walls")) (walls.follow) (walls.setTileProperties 1 FlxObject.NONE) (walls.setTileProperties 2 FlxObject.ANY) (add walls) (set coins (new FlxTypedGroup)) (add coins) (set enemies (new FlxTypedGroup)) (add enemies) (map.loadEntities placeEntities "entities") (FlxG.camera.follow player TOPDOWN 1) (super.create)) (method :Void placeEntities [:EntityData entity] (case entity.name ("player" (set player (new Player entity.x entity.y)) (add player)) ("coin" (coins.add (new Coin (+ entity.x 4) (+ entity.y 4)))) ("enemy" (enemies.add (new Enemy (+ entity.x 4) entity.y REGULAR))) ("boss" (enemies.add (new Enemy (+ entity.x 4) entity.y BOSS))))) (method &override :Void update [:Float elapsed] (super.update elapsed) (FlxG.collide player walls) (FlxG.overlap player coins playerTouchCoin) (FlxG.collide enemies walls) (enemies.forEachAlive checkEnemyVision)) (method :Void checkEnemyVision [:Enemy enemy] (if (walls.ray (enemy.getMidpoint) (player.getMidpoint)) { (set enemy.seesPlayer true) (set enemy.playerPosition (player.getMidpoint)) } (set enemy.seesPlayer false))) (method playerTouchCoin [:Player player :Coin coin] (when (and player.alive player.exists coin.alive coin.exists) (coin.kill)))