added lives label, player level label, level up sound

This commit is contained in:
OfficialCHenry 2022-04-23 17:23:53 -04:00
parent de822a8111
commit 75e70a00ba
3 changed files with 47 additions and 11 deletions

Binary file not shown.

View File

@ -98,6 +98,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
CURRENT_SHIELD : number =0;
MAX_SHIELD : number = 20;
invincible : boolean = false;
level : number = 1;
godMode: boolean = false;
@ -281,6 +282,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
}
if(this.CURRENT_HP <= 0){
this.lives --;
(<AnimatedSprite>this.owner).animation.play("DYING");
(<AnimatedSprite>this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED);
this.emitter.fireEvent(Player_Events.PLAYER_KILLED);
@ -315,6 +317,9 @@ export default class PlayerController extends StateMachineAI implements BattlerA
//if > than max exp level up (give buff)
if(this.CURRENT_EXP >= this.MAX_EXP){
this.CURRENT_EXP -= this.MAX_EXP;
this.MAX_EXP += 50; //increase max exp needed for level up
this.level++ ;
this.emitter.fireEvent(GameEventType.PLAY_SOUND, {key: "level_up", loop: false, holdReference: false});
this.emitter.fireEvent(Player_Events.GIVE_BUFF);
}
}
@ -331,7 +336,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
// Get sub-array of first 3 elements after shuffled
let shuffled = PlayerController.buffPool.slice(0, 3); //3 buff categories
let num = Number(Math.random().toPrecision(1)) * 10; //random number from 1 to 10 if no value given
let num = parseFloat(Math.random().toPrecision(1)) * 10; //random number from 1 to 10 if no value given
if(typeof val !== 'undefined'){
num = val;
}
@ -346,12 +351,21 @@ export default class PlayerController extends StateMachineAI implements BattlerA
}
let dotBuffs : Buff[] = [
{type:BuffType.BLEED, value:1, category: BuffCategory.DOT, string: "Your hits \napply Bleed"},
{type:BuffType.BURN, value:1, category: BuffCategory.DOT, string: "Your hits \napply Burn"},
{type:BuffType.POISON, value:1, category: BuffCategory.DOT, string: "Your hits \napply poison"},
{type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT, string: "increase your \nDOT damage"},
];
if(!this.hasBleed){
dotBuffs.push({type:BuffType.BLEED, value:1, category: BuffCategory.DOT, string: "Your hits \napply Bleed"});
}
if(!this.hasBurn){
dotBuffs.push({type:BuffType.BURN, value:1, category: BuffCategory.DOT, string: "Your hits \napply Burn"});
}
if(!this.hasPoison){
dotBuffs.push({type:BuffType.POISON, value:1, category: BuffCategory.DOT, string: "Your hits \napply poison"});
}
if(dotBuffs.length < 3){ //only add extra dot if at least one dot is acquired
dotBuffs.push({type:BuffType.EXTRA_DOT, value:num, category: BuffCategory.DOT, string: "increase your \nDOT damage"});
}
let shieldBuffs : Buff[] = [
{type:BuffType.HEALTH, value:1, category: BuffCategory.SHIELD},
@ -381,7 +395,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
{type:BuffType.SPEED, value:num, category: BuffCategory.EXTRA},
{type:BuffType.ATK, value:num, category: BuffCategory.EXTRA}
];
if(!this.hasOneShot){
if(!this.hasOneShot){ //only add oneshot buff if it isnt already included
extraBuffs.push({type:BuffType.ONESHOT, value:1, category: BuffCategory.EXTRA, string: "Your hits hurt \n100x more but \nyour max health \nis set to 1 "});
};

View File

@ -76,6 +76,9 @@ export default class GameLevel extends Scene {
protected expLabel : Label;
protected expBar: Rect;
//level label
protected playerLevelLabel : Label;
//shield label
protected shieldLabel : Label;
protected shieldBar: Rect;
@ -144,7 +147,7 @@ export default class GameLevel extends Scene {
this.load.audio("jump", "shattered_sword_assets/sounds/jump2.wav");
this.load.audio("hurt", "shattered_sword_assets/sounds/hurt.wav");
this.load.audio("die", "shattered_sword_assets/sounds/die.wav");
this.load.audio("level_up","shattered_sword_assets/sounds/level_up.wav");
this.load.image("knife", "shattered_sword_assets/sprites/knife.png");
@ -206,6 +209,7 @@ export default class GameLevel extends Scene {
// Initialize the timers
/*
this.respawnTimer = new Timer(1000, () => {
if(GameLevel.livesCount === 0){
this.sceneManager.changeToScene(MainMenu);
@ -215,6 +219,7 @@ export default class GameLevel extends Scene {
this.player.unfreeze();
}
});
*/
let enemies = this.rmg.getEnemies();
//may have to move this to start scene in gameLevel
@ -392,6 +397,11 @@ export default class GameLevel extends Scene {
this.expBar.fillWidth = (playerAI.CURRENT_EXP/playerAI.MAX_EXP)*150;
// this.expLabel.sizeToText();
//update level ui
this.playerLevelLabel.text = "lv." + playerAI.level;
//update lives ui
this.livesCountLabel.text = "Lives: " + playerAI.lives;
//move background
@ -529,7 +539,12 @@ export default class GameLevel extends Scene {
this.shieldBar.borderWidth = 3;
this.shieldBar.color = Color.ORANGE;
this.expLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(70, 95), text: "EXP: "+ (<PlayerController>this.player.ai).CURRENT_EXP });
this.playerLevelLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(30, 95), text: "lv. "+ (<PlayerController>this.player.ai).level });
this.playerLevelLabel.textColor = Color.BLUE;
this.expLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(100, 95), text: "EXP: "+ (<PlayerController>this.player.ai).CURRENT_EXP });
this.expLabel.size.set(200, 50);
this.expLabel.setHAlign(HAlign.LEFT);
this.expLabel.textColor = Color.BLUE;
@ -667,6 +682,10 @@ export default class GameLevel extends Scene {
this.pauseSubmit.backgroundColor = Color.WHITE;
this.pauseSubmit.onClickEventId = "cheat";
this.pauseSubmit.borderWidth = 3;
this.livesCountLabel = <Label>this.add.uiElement(UIElementType.LABEL, "UI", {position: new Vec2(600, 30), text:"Lives: "});
this.livesCountLabel.textColor = Color.YELLOW;
}
//TODO - determine whether we will have weapon datatype
@ -942,6 +961,7 @@ export default class GameLevel extends Scene {
* Increments the amount of life the player has
* @param amt The amount to add to the player life
*/
/*
protected incPlayerLife(amt: number): void {
GameLevel.livesCount += amt;
this.livesCountLabel.text = "Lives: " + GameLevel.livesCount;
@ -952,6 +972,8 @@ export default class GameLevel extends Scene {
this.player.tweens.play("death");
}
}
*/
/**
* Returns the player to spawn
@ -961,7 +983,7 @@ export default class GameLevel extends Scene {
InputWrapper.enableInput();
this.player.position.copy(this.startpos);
(<PlayerController>this.player._ai).CURRENT_HP = (<PlayerController>this.player._ai).MAX_HP + (<PlayerController>this.player._ai).CURRENT_BUFFS.hp;
(<PlayerController>this.player._ai).lives --;
//(<PlayerController>this.player._ai).lives --;
}