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;
|
protected levelTransitionScreen: Rect;
|
||||||
|
|
||||||
// The battle manager for the scene
|
// The battle manager for the scene
|
||||||
private battleManager: BattleManager;
|
protected battleManager: BattleManager;
|
||||||
|
|
||||||
// Health UI
|
// Health UI
|
||||||
protected healthLabel: Label;
|
protected healthLabel: Label;
|
||||||
|
@ -70,10 +70,10 @@ export default class GameLevel extends Scene {
|
||||||
protected seedLabel: Label;
|
protected seedLabel: Label;
|
||||||
|
|
||||||
// A list of items in the scene
|
// A list of items in the scene
|
||||||
private items: Array<Item>;
|
protected items: Array<Item>;
|
||||||
|
|
||||||
// A list of enemies
|
// A list of enemies
|
||||||
private enemies: Array<AnimatedSprite>;
|
protected enemies: Array<AnimatedSprite>;
|
||||||
|
|
||||||
//buffs layer
|
//buffs layer
|
||||||
buffLayer: 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.image("inventorySlot", "shattered_sword_assets/sprites/inventory.png");
|
||||||
|
|
||||||
this.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json")
|
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.initViewport();
|
||||||
this.initLayers();
|
this.initLayers();
|
||||||
// Create the battle manager
|
// Create the battle manager
|
||||||
this.battleManager = new BattleManager();
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
this.initializeWeapons();
|
this.initializeWeapons();
|
||||||
|
@ -129,7 +130,6 @@ export default class GameLevel extends Scene {
|
||||||
this.addUI();
|
this.addUI();
|
||||||
|
|
||||||
// Create an enemies array
|
// Create an enemies array
|
||||||
this.enemies = new Array();
|
|
||||||
// Send the player and enemies to the battle manager
|
// Send the player and enemies to the battle manager
|
||||||
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
||||||
// Initialize all enemies
|
// Initialize all enemies
|
||||||
|
|
|
@ -7,8 +7,12 @@ import GameLevel from "./GameLevel";
|
||||||
import Label from "../../Wolfie2D/Nodes/UIElements/Label";
|
import Label from "../../Wolfie2D/Nodes/UIElements/Label";
|
||||||
import Color from "../../Wolfie2D/Utils/Color";
|
import Color from "../../Wolfie2D/Utils/Color";
|
||||||
import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes";
|
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 map: TiledTilemapData;
|
||||||
private rmg: RandomMapGenerator;
|
private rmg: RandomMapGenerator;
|
||||||
|
|
||||||
|
@ -18,7 +22,7 @@ export default class Tutorial extends GameLevel{
|
||||||
// Load resources
|
// Load resources
|
||||||
// this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json");
|
// this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json");
|
||||||
// let map = localStorage.getItem("map");
|
// 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.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed);
|
||||||
this.map = this.rmg.getMap();
|
this.map = this.rmg.getMap();
|
||||||
this.load.tilemapFromObject("forest1", this.map);
|
this.load.tilemapFromObject("forest1", this.map);
|
||||||
|
@ -34,18 +38,38 @@ export default class Tutorial extends GameLevel{
|
||||||
}
|
}
|
||||||
|
|
||||||
startScene(): void {
|
startScene(): void {
|
||||||
|
|
||||||
|
|
||||||
// Add the level 1 tilemap
|
// Add the level 1 tilemap
|
||||||
this.add.tilemap("forest1", new Vec2(2, 2));
|
this.add.tilemap("forest1", new Vec2(2, 2));
|
||||||
console.log("width,height:"+this.map.width,this.map.height);
|
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.setBounds(0, 0, this.map.width * 32, this.map.height * 32);
|
||||||
this.viewport.follow(this.player);
|
this.viewport.follow(this.player);
|
||||||
|
|
||||||
console.log(this.rmg.getEnemies());
|
|
||||||
this.playerSpawn = this.rmg.getPlayer().scale(32);
|
this.playerSpawn = this.rmg.getPlayer().scale(32);
|
||||||
|
console.log(this.playerSpawn)
|
||||||
|
|
||||||
|
|
||||||
// Do generic setup for a GameLevel
|
// Do generic setup for a GameLevel
|
||||||
super.startScene();
|
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 {
|
updateScene(deltaT: number): void {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user