feat: added an example of enemy spawning
This commit is contained in:
parent
75ce98f947
commit
d19a52e184
|
@ -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<Item>;
|
||||
protected items: Array<Item>;
|
||||
|
||||
// A list of enemies
|
||||
private enemies: Array<AnimatedSprite>;
|
||||
protected enemies: Array<AnimatedSprite>;
|
||||
|
||||
//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([<PlayerController>this.player._ai]);
|
||||
// Initialize all enemies
|
||||
|
|
|
@ -7,8 +7,12 @@ 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;
|
||||
|
||||
|
@ -18,7 +22,7 @@ export default class Tutorial extends GameLevel{
|
|||
// 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);
|
||||
|
@ -34,18 +38,38 @@ export default class Tutorial extends GameLevel{
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user