From 006701dbaf63173423a68455abbb8477fd5ca95a Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Sun, 10 Apr 2022 20:00:57 -0400 Subject: [PATCH] added seed ui --- src/shattered_sword/AI/EnemyStates/Patrol.ts | 6 +-- .../GameSystems/BattleManager.ts | 10 +++-- src/shattered_sword/Scenes/GameLevel.ts | 39 ++++++++++--------- src/shattered_sword/Scenes/Tutorial.ts | 12 ++++-- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/shattered_sword/AI/EnemyStates/Patrol.ts b/src/shattered_sword/AI/EnemyStates/Patrol.ts index ab40b7f..aa132bc 100644 --- a/src/shattered_sword/AI/EnemyStates/Patrol.ts +++ b/src/shattered_sword/AI/EnemyStates/Patrol.ts @@ -39,19 +39,19 @@ export default class Patrol extends EnemyState { console.log(this.parent.tilemap.getTileAtRowCol(colrow)); this.parent.direction *= -1; (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; (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 diff --git a/src/shattered_sword/GameSystems/BattleManager.ts b/src/shattered_sword/GameSystems/BattleManager.ts index acdbd37..9025da6 100644 --- a/src/shattered_sword/GameSystems/BattleManager.ts +++ b/src/shattered_sword/GameSystems/BattleManager.ts @@ -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 { diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 0406268..ad6049e 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -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; + //seed UI + protected seedLabel: Label; + + // A list of items in the scene + private items: Array; // A list of enemies private enemies: Array; + 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([this.player._ai]); + // Initialize all enemies + //this.initializeEnemies(); + this.battleManager.setEnemies(this.enemies.map(enemy => 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 =