added dot effects

need to add dot dmg buff
This commit is contained in:
OfficialCHenry 2022-04-20 15:11:30 -04:00
parent e0b399af43
commit c1a00694f6
3 changed files with 54 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import MathUtils from "../../Wolfie2D/Utils/MathUtils";
import { Player_Events } from "../sword_enums"; import { Player_Events } from "../sword_enums";
import InputWrapper from "../Tools/InputWrapper"; import InputWrapper from "../Tools/InputWrapper";
import Timer from "../../Wolfie2D/Timing/Timer";
export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
/** The owner of this AI */ /** The owner of this AI */
owner: AnimatedSprite; owner: AnimatedSprite;
@ -65,6 +66,16 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
exp_val: number =0; //exp value to give player when this dies exp_val: number =0; //exp value to give player when this dies
poisonTimer : Timer;
poisonCounter : number = 0;
burnTimer : Timer ;
burnCounter : number =0;
bleedTimer : Timer;
bleedCounter :number = 0;
initializeAI(owner: AnimatedSprite, options: Record<string, any>): void { initializeAI(owner: AnimatedSprite, options: Record<string, any>): void {
this.owner = owner; this.owner = owner;
@ -107,6 +118,12 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
//exp value //exp value
this.exp_val = options.exp; this.exp_val = options.exp;
//TODO - dots every 1 sec? can change
this.burnTimer = new Timer(1000);
this.bleedTimer = new Timer(1000);
this.poisonTimer = new Timer(1000);
} }
activate(options: Record<string, any>): void { } activate(options: Record<string, any>): void { }
@ -116,7 +133,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
this.CURRENT_HP -= damage; this.CURRENT_HP -= damage;
//TODO - //TODO -
this.owner.animation.play("HURT",false); this.owner.animation.play("HURT",false);
//console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left");
// If we're low enough, add Low Health status to enemy // If we're low enough, add Low Health status to enemy
if (this.CURRENT_HP <= Math.floor(this.maxHealth/2)) { if (this.CURRENT_HP <= Math.floor(this.maxHealth/2)) {
@ -203,6 +220,22 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
} }
*/ */
//TODO - add extra dot damage
if(this.burnTimer.isStopped() && this.burnCounter >0){
this.burnCounter --;
this.burnTimer.start();
this.damage(5);
}
if(this.poisonTimer.isStopped() && this.poisonCounter >0){
this.poisonCounter --;
this.poisonTimer.start();
this.damage(5);
}
if(this.bleedTimer.isStopped() && this.bleedCounter >0){
this.bleedCounter --;
this.bleedTimer.start();
this.damage(5);
}
} }
} }

View File

@ -3,6 +3,7 @@ import GameNode from "../../Wolfie2D/Nodes/GameNode";
import BattlerAI from "../AI/BattlerAI"; import BattlerAI from "../AI/BattlerAI";
import Weapon from "./items/Weapon"; import Weapon from "./items/Weapon";
import PlayerController from "../Player/PlayerController"; import PlayerController from "../Player/PlayerController";
import EnemyAI from "../AI/EnemyAI";
export default class BattleManager { export default class BattleManager {
players: Array<BattlerAI>; players: Array<BattlerAI>;
@ -23,7 +24,20 @@ export default class BattleManager {
//TODO - test shield, //TODO - test shield,
//add checking for each onhit buff here //add checking for each onhit buff here
(<PlayerController>this.players[0]).addShield(1); let player = (<PlayerController>this.players[0]);
player.addShield(1);
//DOTS
if(player.hasBleed){
(<EnemyAI>enemy).bleedCounter +=3;
}
if(player.hasPoison){
(<EnemyAI>enemy).poisonCounter =5 ;
}
if(player.hasBurn){
(<EnemyAI>enemy).burnCounter =5 ;
}
} }
} }
} }

View File

@ -154,8 +154,6 @@ export default class PlayerController extends StateMachineAI implements BattlerA
this.CURRENT_BUFFS = {hp:0, atk:0, def:0, speed:0, range:0}; this.CURRENT_BUFFS = {hp:0, atk:0, def:0, speed:0, range:0};
//to test the buffs
//this.addBuff( {type:BuffType.HEALTH, value:1} );
//i frame timer //i frame timer
PlayerController.invincibilityTimer = new Timer(2000); PlayerController.invincibilityTimer = new Timer(2000);
@ -170,6 +168,11 @@ export default class PlayerController extends StateMachineAI implements BattlerA
PlayerController.buffPool.push(BuffCategory.HEALTH); PlayerController.buffPool.push(BuffCategory.HEALTH);
} }
//to test the buffs
//this.addBuff( {type:BuffType.HEALTH, value:1} );
this.addBuff({type:BuffType.BLEED, value:1, category:BuffCategory.DOT});
} }
initializePlatformer(): void { initializePlatformer(): void {