diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 2c64623..8db71bc 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -59,7 +59,7 @@ export default class GameLevel extends Scene { protected levelTransitionScreen: Rect; // The battle manager for the scene - private battleManager: BattleManager; + protected battleManager: BattleManager; // Health UI protected healthLabel: Label; @@ -70,10 +70,10 @@ export default class GameLevel extends Scene { protected seedLabel: Label; // A list of items in the scene - private items: Array; + protected items: Array; // A list of enemies - private enemies: Array; + protected enemies: Array; //buffs layer buffLayer: Layer; @@ -103,6 +103,8 @@ export default class GameLevel extends Scene { this.load.image("inventorySlot", "shattered_sword_assets/sprites/inventory.png"); this.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json") + this.enemies = new Array(); + this.battleManager = new BattleManager(); } @@ -116,7 +118,6 @@ export default class GameLevel extends Scene { this.initViewport(); this.initLayers(); // Create the battle manager - this.battleManager = new BattleManager(); // TODO this.initializeWeapons(); @@ -129,7 +130,6 @@ export default class GameLevel extends Scene { this.addUI(); // Create an enemies array - this.enemies = new Array(); // Send the player and enemies to the battle manager this.battleManager.setPlayers([this.player._ai]); // Initialize all enemies diff --git a/src/shattered_sword/Scenes/Tutorial.ts b/src/shattered_sword/Scenes/Tutorial.ts index 421efb1..74fca3f 100644 --- a/src/shattered_sword/Scenes/Tutorial.ts +++ b/src/shattered_sword/Scenes/Tutorial.ts @@ -7,45 +7,69 @@ import GameLevel from "./GameLevel"; import Label from "../../Wolfie2D/Nodes/UIElements/Label"; import Color from "../../Wolfie2D/Utils/Color"; import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes"; +import { Statuses } from "../sword_enums"; +import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB"; +import EnemyAI from "../AI/EnemyAI"; +import BattlerAI from "../AI/BattlerAI"; -export default class Tutorial extends GameLevel{ +export default class Tutorial extends GameLevel { private map: TiledTilemapData; private rmg: RandomMapGenerator; - + loadScene(): void { super.loadScene(); // Load resources // this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json"); // let map = localStorage.getItem("map"); - this.randomSeed = Math.floor(Math.random()*10000000000); + this.randomSeed = Math.floor(Math.random() * 10000000000); this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed); this.map = this.rmg.getMap(); this.load.tilemapFromObject("forest1", this.map); - + this.load.spritesheet("player", "shattered_sword_assets/spritesheets/Hiro.json") // TODO - change when done testing this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json"); - - + + //load music here } startScene(): void { + + // Add the level 1 tilemap this.add.tilemap("forest1", new Vec2(2, 2)); - console.log("width,height:"+this.map.width,this.map.height); - this.viewport.setBounds(0, 0, this.map.width*32, this.map.height*32); + console.log("width,height:" + this.map.width, this.map.height); + this.viewport.setBounds(0, 0, this.map.width * 32, this.map.height * 32); this.viewport.follow(this.player); - console.log(this.rmg.getEnemies()); this.playerSpawn = this.rmg.getPlayer().scale(32); + console.log(this.playerSpawn) + // Do generic setup for a GameLevel super.startScene(); + let enemies = this.rmg.getEnemies(); + for (let enemy of enemies) { + switch (enemy.type) { + case "test_dummy": + this.addEnemy("test_dummy", enemy.position.scale(32), { + player: this.player, + health: 100, + tilemap: "Main", + //actions:actions, + goal: Statuses.REACHED_GOAL, + }) + break; + + default: + break; + } + } } updateScene(deltaT: number): void {