fix: testes bull and fixed bugs
This commit is contained in:
parent
f03d864ed6
commit
2969d90420
|
@ -36,8 +36,8 @@
|
|||
"repeat": false,
|
||||
"frames": [
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 20
|
||||
"index": 5,
|
||||
"duration": 60
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class ArcherAttack extends Attack {
|
|||
update(deltaT: number): void {
|
||||
|
||||
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();
|
||||
|
||||
(<ArcherAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0));
|
||||
|
|
|
@ -45,7 +45,7 @@ export default class AssassinAttack extends Attack {
|
|||
this.runTimer.start();
|
||||
(<AnimatedSprite>this.owner).animation.play("ATTACK", true);
|
||||
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;
|
||||
case this.attacked:
|
||||
this.parent.isAttacking = false;
|
||||
|
|
|
@ -5,6 +5,7 @@ import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
|||
export default class Attack extends EnemyState {
|
||||
protected charged: string;
|
||||
protected attacked: string;
|
||||
protected hasCharged: boolean;
|
||||
|
||||
onEnter(options: Record<string, any>): void {
|
||||
this.parent.attackTimer.start();
|
||||
|
@ -12,6 +13,7 @@ export default class Attack extends EnemyState {
|
|||
this.parent.isCharging = true;
|
||||
this.charged = this.owner.id+"charged";
|
||||
this.attacked = this.owner.id+"attacked";
|
||||
this.hasCharged = false;
|
||||
|
||||
// TODO replace DYING with CHARGING
|
||||
(<AnimatedSprite>this.owner).animation.play("CHARGE", false, this.charged);
|
||||
|
|
|
@ -56,7 +56,7 @@ export default class BossAttack extends Attack {
|
|||
switch( this.atknum){
|
||||
case 0: //archer atk
|
||||
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();
|
||||
|
||||
(<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();
|
||||
(<AnimatedSprite>this.owner).animation.play("ATTACK", true);
|
||||
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;
|
||||
case this.attacked:
|
||||
this.parent.isAttacking = false;
|
||||
|
@ -105,7 +105,7 @@ export default class BossAttack extends Attack {
|
|||
this.parent.isAttacking = true;
|
||||
this.runTimer.start();
|
||||
(<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;
|
||||
case this.attacked:
|
||||
this.parent.isAttacking = false;
|
||||
|
@ -129,7 +129,7 @@ export default class BossAttack extends Attack {
|
|||
this.parent.isAttacking = true;
|
||||
(<AnimatedSprite>this.owner).animation.play("ATTACK", true);
|
||||
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;
|
||||
break;
|
||||
case this.attacked:
|
||||
|
|
|
@ -5,7 +5,7 @@ import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
|
|||
import Attack from "./Attack";
|
||||
import Timer from "../../../Wolfie2D/Timing/Timer";
|
||||
|
||||
export default class TigerAttack extends Attack {
|
||||
export default class BullAttack extends Attack {
|
||||
runTimer: Timer;
|
||||
|
||||
onEnter(options: Record<string, any>): void {
|
||||
|
@ -14,18 +14,24 @@ export default class TigerAttack extends Attack {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
while (this.receiver.hasNextEvent()) {
|
||||
let event = this.receiver.getNextEvent().type;
|
||||
switch (event) {
|
||||
case this.charged:
|
||||
if (this.hasCharged) {
|
||||
break;
|
||||
}
|
||||
this.hasCharged = true;
|
||||
console.log("charged")
|
||||
this.parent.isCharging = false;
|
||||
this.parent.isAttacking = true;
|
||||
this.runTimer.start();
|
||||
(<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;
|
||||
case this.attacked:
|
||||
this.parent.isAttacking = false;
|
||||
|
@ -33,8 +39,10 @@ export default class TigerAttack extends Attack {
|
|||
break;
|
||||
}
|
||||
}
|
||||
this.parent.velocity.x = this.parent.direction * 1000;
|
||||
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ;
|
||||
if (this.parent.isAttacking) {
|
||||
this.parent.velocity.x = this.parent.direction * 600;
|
||||
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false;
|
||||
}
|
||||
super.update(deltaT);
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ export default class TigerAttack extends Attack {
|
|||
this.parent.isAttacking = true;
|
||||
(<AnimatedSprite>this.owner).animation.play("ATTACK", true);
|
||||
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;
|
||||
break;
|
||||
case this.attacked:
|
||||
|
|
|
@ -14,13 +14,7 @@ export default class Forest extends GameLevel {
|
|||
|
||||
//load enemies
|
||||
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");
|
||||
|
||||
//load music here
|
||||
}
|
||||
|
||||
updateScene(deltaT: number): void {
|
||||
|
|
|
@ -43,6 +43,7 @@ import GameOver from "./GameOver";
|
|||
import GameFinish from "./GameFinish";
|
||||
import MainMenu from "./MainMenu";
|
||||
import MapTemplate from "../Tools/DataTypes/MapTemplate";
|
||||
import BullAI from "../AI/BullAI";
|
||||
|
||||
// TODO
|
||||
/**
|
||||
|
@ -911,11 +912,14 @@ export default class GameLevel extends Scene {
|
|||
})
|
||||
break;
|
||||
|
||||
case "remus_werewolf":
|
||||
this.addEnemy("remus_werewolf", enemy.position.scale(32), EnemyAI, {
|
||||
case "Bull":
|
||||
this.addEnemy("Bull", enemy.position.scale(32), BullAI, {
|
||||
player: this.player,
|
||||
health: 200,
|
||||
tilemap: "Main",
|
||||
scale: 1.5,
|
||||
size: new Vec2(30,18),
|
||||
offset : new Vec2(0, 27),
|
||||
exp: 50,
|
||||
})
|
||||
break;
|
||||
|
|
|
@ -23,12 +23,8 @@ export default class Greatwall extends GameLevel {
|
|||
this.load.tilemapFromObject("map", this.map);
|
||||
|
||||
//load enemies
|
||||
|
||||
//can load enemy sprite here
|
||||
//sprites obtained from cse380 sprite wesbite
|
||||
// this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
|
||||
|
||||
//load music here
|
||||
this.load.spritesheet("Bull","shattered_sword_assets/spritesheets/Bull.json");
|
||||
this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json");
|
||||
}
|
||||
protected goToNextLevel(): void {
|
||||
this.viewport.setZoomLevel(1);
|
||||
|
|
|
@ -22,14 +22,6 @@ export default class Porcelain extends GameLevel {
|
|||
console.log(this.map);
|
||||
this.load.tilemapFromObject("map", this.map);
|
||||
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");
|
||||
|
||||
//load music here
|
||||
|
|
Loading…
Reference in New Issue
Block a user