feat: tiger AI
This commit is contained in:
parent
3511dbae8b
commit
9aa76b7963
|
@ -40,6 +40,12 @@
|
|||
"type": "player",
|
||||
"x": 5,
|
||||
"y": 10
|
||||
},
|
||||
{
|
||||
"type": "Tiger",
|
||||
"x": 3,
|
||||
"y": 7,
|
||||
"possibility": 1
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -19,11 +19,6 @@ export default class Attack extends EnemyState {
|
|||
this.receiver.subscribe(this.attacked);
|
||||
}
|
||||
|
||||
update(deltaT: number): void {
|
||||
this.finished(EnemyStates.ALERT);
|
||||
super.update(deltaT);
|
||||
}
|
||||
|
||||
onExit(): Record<string, any> {
|
||||
this.parent.isCharging = false;
|
||||
(<AnimatedSprite>this.owner).animation.stop();
|
||||
|
|
|
@ -31,7 +31,15 @@ export default abstract class EnemyState extends State {
|
|||
this.parent.velocity.x = 0;
|
||||
}
|
||||
// Do gravity
|
||||
if (this.owner.onGround) {
|
||||
this.parent.velocity.y = 0;
|
||||
}
|
||||
else if (this.owner.onCeiling) {
|
||||
this.parent.velocity.y += this.gravity * deltaT * 2;
|
||||
}
|
||||
else {
|
||||
this.parent.velocity.y += this.gravity * deltaT;
|
||||
}
|
||||
this.owner.move(this.parent.velocity.scaled(deltaT));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import Attack from "./Attack";
|
|||
export default class TigerAttack extends Attack {
|
||||
protected velocity: number;
|
||||
protected distance: number;
|
||||
protected attacking: boolean = false;
|
||||
|
||||
onEnter(options: Record<string, any>): void {
|
||||
super.onEnter(options);
|
||||
|
@ -15,7 +14,7 @@ export default class TigerAttack extends Attack {
|
|||
}
|
||||
|
||||
update(deltaT: number): void {
|
||||
if (this.attacking && this.owner.onGround) {
|
||||
if (this.parent.isAttaking && this.owner.onGround) {
|
||||
this.emitter.fireEvent(this.attacked);
|
||||
}
|
||||
while (this.receiver.hasNextEvent()) {
|
||||
|
@ -25,9 +24,9 @@ export default class TigerAttack extends Attack {
|
|||
this.parent.isCharging = false;
|
||||
this.parent.isAttaking = true;
|
||||
(<AnimatedSprite>this.owner).animation.play("ATTACK", true);
|
||||
this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/2;
|
||||
this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5;
|
||||
this.parent.direction = this.velocity >= 0 ? 1 : 0;
|
||||
this.attacking = true;
|
||||
this.parent.velocity.y = -800;
|
||||
break;
|
||||
case this.attacked:
|
||||
this.parent.isAttaking = false;
|
||||
|
|
|
@ -22,6 +22,7 @@ import BattleManager from "../GameSystems/BattleManager";
|
|||
import EnemyAI from "../AI/EnemyAI";
|
||||
import SnakeAI from "../AI/SnakeAI";
|
||||
import SlimeAI from "../AI/SlimeAI";
|
||||
import TigerAI from "../AI/TigerAI";
|
||||
import BattlerAI from "../AI/BattlerAI";
|
||||
import InventoryManager from "../GameSystems/InventoryManager";
|
||||
import Item from "../GameSystems/items/Item";
|
||||
|
@ -865,10 +866,13 @@ export default class GameLevel extends Scene {
|
|||
})
|
||||
break;
|
||||
case "Tiger": //Tiger can be miniboss for now?
|
||||
this.addEnemy("Tiger", enemy.position.scale(32), EnemyAI, {
|
||||
this.addEnemy("Tiger", enemy.position.scale(32), TigerAI, {
|
||||
player: this.player,
|
||||
health: 200,
|
||||
tilemap: "Main",
|
||||
scale: 1.5,
|
||||
size: new Vec2(30,18),
|
||||
offset : new Vec2(0, 27),
|
||||
exp: 100,
|
||||
})
|
||||
break;
|
||||
|
|
|
@ -20,6 +20,7 @@ export default class Porcelain extends GameLevel {
|
|||
this.map = this.rmg.getMap();
|
||||
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");
|
||||
|
|
|
@ -14,7 +14,6 @@ export default class Tutorial extends GameLevel {
|
|||
|
||||
//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
|
||||
|
|
Loading…
Reference in New Issue
Block a user