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));
|
console.log(this.parent.tilemap.getTileAtRowCol(colrow));
|
||||||
this.parent.direction *= -1;
|
this.parent.direction *= -1;
|
||||||
(<Sprite>this.owner).invertX = MathUtils.sign(1) < 0;
|
(<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
|
//check if next ground tile is collidable
|
||||||
else if(this.parent.tilemap.isTileCollidable(colrow.x+this.parent.direction,colrow.y+1)){
|
else if(this.parent.tilemap.isTileCollidable(colrow.x+this.parent.direction,colrow.y+1)){
|
||||||
//keep moving
|
//keep moving
|
||||||
//this.velocity.x = this.speed;
|
//this.velocity.x = this.speed;
|
||||||
console.log("there is floor ahead");
|
//console.log("there is floor ahead");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
//turn around
|
//turn around
|
||||||
this.parent.direction *=-1;
|
this.parent.direction *=-1;
|
||||||
(<Sprite>this.owner).invertX = MathUtils.sign(1) < 0;
|
(<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
|
//move
|
||||||
|
|
|
@ -14,12 +14,14 @@ export default class BattleManager {
|
||||||
|
|
||||||
if (attackerType === "player") {
|
if (attackerType === "player") {
|
||||||
// Check for collisions with enemies
|
// Check for collisions with enemies
|
||||||
|
if(this.enemies.length != 0){
|
||||||
for (let enemy of this.enemies) {
|
for (let enemy of this.enemies) {
|
||||||
if (weapon.hits(enemy.owner)) {
|
if (weapon.hits(enemy.owner)) {
|
||||||
enemy.damage(weapon.type.damage);
|
enemy.damage(weapon.type.damage);
|
||||||
console.log("enemy took dmg");
|
console.log("enemy took dmg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check for collision with player
|
// Check for collision with player
|
||||||
for (let player of this.players) {
|
for (let player of this.players) {
|
||||||
|
|
|
@ -61,12 +61,16 @@ export default class GameLevel extends Scene {
|
||||||
// Health UI
|
// Health UI
|
||||||
protected healthLabel: Label;
|
protected healthLabel: Label;
|
||||||
|
|
||||||
|
//seed UI
|
||||||
|
protected seedLabel: Label;
|
||||||
|
|
||||||
// A list of items in the scene
|
// A list of items in the scene
|
||||||
private items: Array<Item>;
|
private items: Array<Item>;
|
||||||
|
|
||||||
// A list of enemies
|
// A list of enemies
|
||||||
private enemies: Array<AnimatedSprite>;
|
private enemies: Array<AnimatedSprite>;
|
||||||
|
|
||||||
|
randomSeed: number;
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
//can load player sprite here
|
//can load player sprite here
|
||||||
|
|
||||||
|
@ -115,6 +119,13 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
// 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
|
||||||
|
//this.initializeEnemies();
|
||||||
|
this.battleManager.setEnemies(this.enemies.map(enemy => <BattlerAI>enemy._ai));
|
||||||
|
|
||||||
|
// Subscribe to relevant events
|
||||||
|
//this.receiver.subscribe("");
|
||||||
|
|
||||||
|
|
||||||
// Initialize the timers
|
// Initialize the timers
|
||||||
this.respawnTimer = new Timer(1000, () => {
|
this.respawnTimer = new Timer(1000, () => {
|
||||||
|
@ -160,17 +171,14 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
//handle collisions - may be in battle manager instead
|
//handle collisions - may be in battle manager instead
|
||||||
|
|
||||||
|
|
||||||
//move background
|
//move background
|
||||||
|
|
||||||
|
|
||||||
// Get the viewport center and padded size
|
// Get the viewport center and padded size
|
||||||
const viewportCenter = this.viewport.getCenter().clone();
|
const viewportCenter = this.viewport.getCenter().clone();
|
||||||
const baseViewportSize = this.viewport.getHalfSize().scaled(2);
|
const baseViewportSize = this.viewport.getHalfSize().scaled(2);
|
||||||
//check position of player
|
//check position of player
|
||||||
this.playerFalloff(viewportCenter, baseViewportSize);
|
this.playerFalloff(viewportCenter, baseViewportSize);
|
||||||
|
|
||||||
|
|
||||||
//TODO - this is for testing
|
//TODO - this is for testing
|
||||||
if(Input.isJustPressed("spawn")){
|
if(Input.isJustPressed("spawn")){
|
||||||
console.log("trying to spawn enemy");
|
console.log("trying to spawn enemy");
|
||||||
|
@ -222,10 +230,17 @@ export default class GameLevel extends Scene {
|
||||||
*/
|
*/
|
||||||
protected addUI(){
|
protected addUI(){
|
||||||
// In-game labels
|
// 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.textColor = Color.WHITE;
|
||||||
this.healthLabel.font = "PixelSimple";
|
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)
|
// End of level label (start off screen)
|
||||||
this.levelEndLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(-300, 200), text: "Level Complete"});
|
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
|
//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 { GameEventType } from "../../Wolfie2D/Events/GameEventType";
|
||||||
import RandomMapGenerator from "../Tools/RandomMapGenerator";
|
import RandomMapGenerator from "../Tools/RandomMapGenerator";
|
||||||
import GameLevel from "./GameLevel";
|
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{
|
export default class Tutorial extends GameLevel{
|
||||||
private map: TiledTilemapData;
|
private map: TiledTilemapData;
|
||||||
|
|
||||||
|
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
super.loadScene();
|
super.loadScene();
|
||||||
// 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");
|
||||||
let randomSeed = Math.floor(Math.random()*10000000000);
|
this.randomSeed = Math.floor(Math.random()*10000000000);
|
||||||
let rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", randomSeed);
|
let rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", this.randomSeed);
|
||||||
this.map = rmg.getMap();
|
this.map = rmg.getMap();
|
||||||
this.load.tilemapFromObject("forest1", this.map);
|
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");
|
this.load.spritesheet("slice", "shattered_sword_assets/spritesheets/slice.json");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//load music here
|
//load music here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user