added seed ui
This commit is contained in:
parent
417315cf08
commit
006701dbaf
|
@ -39,19 +39,19 @@ export default class Patrol extends EnemyState {
|
|||
console.log(this.parent.tilemap.getTileAtRowCol(colrow));
|
||||
this.parent.direction *= -1;
|
||||
(<Sprite>this.owner).invertX = MathUtils.sign(1) < 0;
|
||||
console.log("turn around cus wall in front");
|
||||
//console.log("turn around cus wall in front");
|
||||
}
|
||||
//check if next ground tile is collidable
|
||||
else if(this.parent.tilemap.isTileCollidable(colrow.x+this.parent.direction,colrow.y+1)){
|
||||
//keep moving
|
||||
//this.velocity.x = this.speed;
|
||||
console.log("there is floor ahead");
|
||||
//console.log("there is floor ahead");
|
||||
}
|
||||
else{
|
||||
//turn around
|
||||
this.parent.direction *=-1;
|
||||
(<Sprite>this.owner).invertX = MathUtils.sign(1) < 0;
|
||||
console.log("turn around cus no floor in front");
|
||||
//console.log("turn around cus no floor in front");
|
||||
|
||||
}
|
||||
//move
|
||||
|
|
|
@ -14,10 +14,12 @@ export default class BattleManager {
|
|||
|
||||
if (attackerType === "player") {
|
||||
// Check for collisions with enemies
|
||||
for (let enemy of this.enemies) {
|
||||
if (weapon.hits(enemy.owner)) {
|
||||
enemy.damage(weapon.type.damage);
|
||||
console.log("enemy took dmg");
|
||||
if(this.enemies.length != 0){
|
||||
for (let enemy of this.enemies) {
|
||||
if (weapon.hits(enemy.owner)) {
|
||||
enemy.damage(weapon.type.damage);
|
||||
console.log("enemy took dmg");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -61,12 +61,16 @@ export default class GameLevel extends Scene {
|
|||
// Health UI
|
||||
protected healthLabel: Label;
|
||||
|
||||
// A list of items in the scene
|
||||
private items: Array<Item>;
|
||||
//seed UI
|
||||
protected seedLabel: Label;
|
||||
|
||||
// A list of items in the scene
|
||||
private items: Array<Item>;
|
||||
|
||||
// A list of enemies
|
||||
private enemies: Array<AnimatedSprite>;
|
||||
|
||||
randomSeed: number;
|
||||
loadScene(): void {
|
||||
//can load player sprite here
|
||||
|
||||
|
@ -115,6 +119,13 @@ export default class GameLevel extends Scene {
|
|||
|
||||
// Send the player and enemies to the battle manager
|
||||
this.battleManager.setPlayers([<PlayerController>this.player._ai]);
|
||||
// Initialize all enemies
|
||||
//this.initializeEnemies();
|
||||
this.battleManager.setEnemies(this.enemies.map(enemy => <BattlerAI>enemy._ai));
|
||||
|
||||
// Subscribe to relevant events
|
||||
//this.receiver.subscribe("");
|
||||
|
||||
|
||||
// Initialize the timers
|
||||
this.respawnTimer = new Timer(1000, () => {
|
||||
|
@ -160,17 +171,14 @@ export default class GameLevel extends Scene {
|
|||
|
||||
//handle collisions - may be in battle manager instead
|
||||
|
||||
|
||||
//move background
|
||||
|
||||
|
||||
// Get the viewport center and padded size
|
||||
const viewportCenter = this.viewport.getCenter().clone();
|
||||
const baseViewportSize = this.viewport.getHalfSize().scaled(2);
|
||||
//check position of player
|
||||
this.playerFalloff(viewportCenter, baseViewportSize);
|
||||
|
||||
|
||||
//TODO - this is for testing
|
||||
if(Input.isJustPressed("spawn")){
|
||||
console.log("trying to spawn enemy");
|
||||
|
@ -222,10 +230,17 @@ export default class GameLevel extends Scene {
|
|||
*/
|
||||
protected addUI(){
|
||||
// In-game labels
|
||||
this.healthLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(100, 30), text: "Player Health: "+ (<PlayerController>this.player.ai).CURRENT_HP });
|
||||
this.healthLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(120, 30), text: "Player Health: "+ (<PlayerController>this.player.ai).CURRENT_HP });
|
||||
this.healthLabel.textColor = Color.WHITE;
|
||||
this.healthLabel.font = "PixelSimple";
|
||||
|
||||
//seed label
|
||||
|
||||
//this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(400, 30), text: "Seed: "+ this.randomSeed });
|
||||
this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(this.worldSize.x - 50, 30), text: "Seed: "+ this.randomSeed });
|
||||
this.seedLabel.textColor = Color.WHITE;
|
||||
this.seedLabel.font = "PixelSimple";
|
||||
|
||||
|
||||
// End of level label (start off screen)
|
||||
this.levelEndLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(-300, 200), text: "Level Complete"});
|
||||
|
@ -283,18 +298,6 @@ export default class GameLevel extends Scene {
|
|||
});
|
||||
|
||||
|
||||
// Initialize all enemies
|
||||
//this.initializeEnemies();
|
||||
|
||||
// Send the player and enemies to the battle manager
|
||||
//this.battleManager.setPlayers([<BattlerAI>this.player._ai]);
|
||||
//this.battleManager.setEnemies(this.enemies.map(enemy => <BattlerAI>enemy._ai));
|
||||
|
||||
// Subscribe to relevant events
|
||||
//this.receiver.subscribe("");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//TODO - determine whether we will have weapon datatype
|
||||
|
|
|
@ -4,18 +4,21 @@ import Debug from "../../Wolfie2D/Debug/Debug";
|
|||
import { GameEventType } from "../../Wolfie2D/Events/GameEventType";
|
||||
import RandomMapGenerator from "../Tools/RandomMapGenerator";
|
||||
import GameLevel from "./GameLevel";
|
||||
|
||||
|
||||
import Label from "../../Wolfie2D/Nodes/UIElements/Label";
|
||||
import Color from "../../Wolfie2D/Utils/Color";
|
||||
import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes";
|
||||
|
||||
export default class Tutorial extends GameLevel{
|
||||
private map: TiledTilemapData;
|
||||
|
||||
|
||||
loadScene(): void {
|
||||
super.loadScene();
|
||||
// Load resources
|
||||
// this.load.tilemap("forest1", "shattered_sword_assets/tilemaps/Tutorial.json");
|
||||
// let map = localStorage.getItem("map");
|
||||
let randomSeed = Math.floor(Math.random()*10000000000);
|
||||
let rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", randomSeed);
|
||||
this.randomSeed = Math.floor(Math.random()*10000000000);
|
||||
let rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed);
|
||||
this.map = rmg.getMap();
|
||||
this.load.tilemapFromObject("forest1", this.map);
|
||||
|
||||
|
@ -25,6 +28,7 @@ export default class Tutorial extends GameLevel{
|
|||
this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json");
|
||||
|
||||
|
||||
|
||||
//load music here
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user