fix: testes bull and fixed bugs

This commit is contained in:
Renge 2022-05-09 12:44:44 -04:00
parent f03d864ed6
commit 2969d90420
11 changed files with 32 additions and 36 deletions

View File

@ -36,8 +36,8 @@
"repeat": false, "repeat": false,
"frames": [ "frames": [
{ {
"index": 0, "index": 5,
"duration": 20 "duration": 60
} }
] ]
}, },

View File

@ -17,7 +17,7 @@ export default class ArcherAttack extends Attack {
update(deltaT: number): void { update(deltaT: number): void {
if(this.pauseTimer.isStopped()){ if(this.pauseTimer.isStopped()){
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
let dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize(); let dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize();
(<ArcherAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0)); (<ArcherAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0));

View File

@ -45,7 +45,7 @@ export default class AssassinAttack extends Attack {
this.runTimer.start(); this.runTimer.start();
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
if(this.parent.getPlayerPosition() !==null) if(this.parent.getPlayerPosition() !==null)
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
break; break;
case this.attacked: case this.attacked:
this.parent.isAttacking = false; this.parent.isAttacking = false;

View File

@ -5,6 +5,7 @@ import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
export default class Attack extends EnemyState { export default class Attack extends EnemyState {
protected charged: string; protected charged: string;
protected attacked: string; protected attacked: string;
protected hasCharged: boolean;
onEnter(options: Record<string, any>): void { onEnter(options: Record<string, any>): void {
this.parent.attackTimer.start(); this.parent.attackTimer.start();
@ -12,6 +13,7 @@ export default class Attack extends EnemyState {
this.parent.isCharging = true; this.parent.isCharging = true;
this.charged = this.owner.id+"charged"; this.charged = this.owner.id+"charged";
this.attacked = this.owner.id+"attacked"; this.attacked = this.owner.id+"attacked";
this.hasCharged = false;
// TODO replace DYING with CHARGING // TODO replace DYING with CHARGING
(<AnimatedSprite>this.owner).animation.play("CHARGE", false, this.charged); (<AnimatedSprite>this.owner).animation.play("CHARGE", false, this.charged);

View File

@ -56,7 +56,7 @@ export default class BossAttack extends Attack {
switch( this.atknum){ switch( this.atknum){
case 0: //archer atk case 0: //archer atk
if(this.pauseTimer.isStopped()){ if(this.pauseTimer.isStopped()){
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
let dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize(); let dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize();
(<BossAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0)); (<BossAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0));
@ -79,7 +79,7 @@ export default class BossAttack extends Attack {
this.runTimer.start(); this.runTimer.start();
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
if(this.parent.getPlayerPosition() !==null) if(this.parent.getPlayerPosition() !==null)
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
break; break;
case this.attacked: case this.attacked:
this.parent.isAttacking = false; this.parent.isAttacking = false;
@ -105,7 +105,7 @@ export default class BossAttack extends Attack {
this.parent.isAttacking = true; this.parent.isAttacking = true;
this.runTimer.start(); this.runTimer.start();
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
break; break;
case this.attacked: case this.attacked:
this.parent.isAttacking = false; this.parent.isAttacking = false;
@ -129,7 +129,7 @@ export default class BossAttack extends Attack {
this.parent.isAttacking = true; this.parent.isAttacking = true;
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5; this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5;
this.parent.direction = this.velocity >= 0 ? 1 : 0; this.parent.direction = this.velocity >= 0 ? 1 : -1;
this.parent.velocity.y = -800; this.parent.velocity.y = -800;
break; break;
case this.attacked: case this.attacked:

View File

@ -5,7 +5,7 @@ import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
import Attack from "./Attack"; import Attack from "./Attack";
import Timer from "../../../Wolfie2D/Timing/Timer"; import Timer from "../../../Wolfie2D/Timing/Timer";
export default class TigerAttack extends Attack { export default class BullAttack extends Attack {
runTimer: Timer; runTimer: Timer;
onEnter(options: Record<string, any>): void { onEnter(options: Record<string, any>): void {
@ -14,18 +14,24 @@ export default class TigerAttack extends Attack {
} }
update(deltaT: number): void { update(deltaT: number): void {
if (this.runTimer.isStopped() && this.parent.isAttacking || !this.canWalk()) { if ((this.runTimer.isStopped() && this.parent.isAttacking) || !this.canWalk()) {
this.parent.velocity.x = 0;
this.emitter.fireEvent(this.attacked); this.emitter.fireEvent(this.attacked);
} }
while (this.receiver.hasNextEvent()) { while (this.receiver.hasNextEvent()) {
let event = this.receiver.getNextEvent().type; let event = this.receiver.getNextEvent().type;
switch (event) { switch (event) {
case this.charged: case this.charged:
if (this.hasCharged) {
break;
}
this.hasCharged = true;
console.log("charged")
this.parent.isCharging = false; this.parent.isCharging = false;
this.parent.isAttacking = true; this.parent.isAttacking = true;
this.runTimer.start(); this.runTimer.start();
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
break; break;
case this.attacked: case this.attacked:
this.parent.isAttacking = false; this.parent.isAttacking = false;
@ -33,8 +39,10 @@ export default class TigerAttack extends Attack {
break; break;
} }
} }
this.parent.velocity.x = this.parent.direction * 1000; if (this.parent.isAttacking) {
this.parent.velocity.x = this.parent.direction * 600;
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false; (<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false;
}
super.update(deltaT); super.update(deltaT);
} }
} }

View File

@ -25,7 +25,7 @@ export default class TigerAttack extends Attack {
this.parent.isAttacking = true; this.parent.isAttacking = true;
(<AnimatedSprite>this.owner).animation.play("ATTACK", true); (<AnimatedSprite>this.owner).animation.play("ATTACK", true);
this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5; this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5;
this.parent.direction = this.velocity >= 0 ? 1 : 0; this.parent.direction = this.velocity >= 0 ? 1 : -1;
this.parent.velocity.y = -800; this.parent.velocity.y = -800;
break; break;
case this.attacked: case this.attacked:

View File

@ -14,13 +14,7 @@ export default class Forest extends GameLevel {
//load enemies //load enemies
this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json"); this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json");
//can load enemy sprite here
//sprites obtained from cse380 sprite wesbite
this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json");
this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
//load music here
} }
updateScene(deltaT: number): void { updateScene(deltaT: number): void {

View File

@ -43,6 +43,7 @@ import GameOver from "./GameOver";
import GameFinish from "./GameFinish"; import GameFinish from "./GameFinish";
import MainMenu from "./MainMenu"; import MainMenu from "./MainMenu";
import MapTemplate from "../Tools/DataTypes/MapTemplate"; import MapTemplate from "../Tools/DataTypes/MapTemplate";
import BullAI from "../AI/BullAI";
// TODO // TODO
/** /**
@ -911,11 +912,14 @@ export default class GameLevel extends Scene {
}) })
break; break;
case "remus_werewolf": case "Bull":
this.addEnemy("remus_werewolf", enemy.position.scale(32), EnemyAI, { this.addEnemy("Bull", enemy.position.scale(32), BullAI, {
player: this.player, player: this.player,
health: 200, health: 200,
tilemap: "Main", tilemap: "Main",
scale: 1.5,
size: new Vec2(30,18),
offset : new Vec2(0, 27),
exp: 50, exp: 50,
}) })
break; break;

View File

@ -23,12 +23,8 @@ export default class Greatwall extends GameLevel {
this.load.tilemapFromObject("map", this.map); this.load.tilemapFromObject("map", this.map);
//load enemies //load enemies
this.load.spritesheet("Bull","shattered_sword_assets/spritesheets/Bull.json");
//can load enemy sprite here this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
//sprites obtained from cse380 sprite wesbite
// this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
//load music here
} }
protected goToNextLevel(): void { protected goToNextLevel(): void {
this.viewport.setZoomLevel(1); this.viewport.setZoomLevel(1);

View File

@ -22,14 +22,6 @@ export default class Porcelain extends GameLevel {
console.log(this.map); console.log(this.map);
this.load.tilemapFromObject("map", this.map); this.load.tilemapFromObject("map", this.map);
this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json"); this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json");
// //load enemies
// this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json");
// this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json");
// //can load enemy sprite here
// //sprites obtained from cse380 sprite wesbite
// this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json");
this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
//load music here //load music here