Create enemy type
This commit is contained in:
@@ -3,6 +3,8 @@ export type EntityId = number;
|
||||
export type Vec2 = { x: number; y: number };
|
||||
|
||||
export type Tile = number;
|
||||
export type EnemyType = "rat" | "bat" | "spider";
|
||||
export type ActorType = "player" | EnemyType;
|
||||
|
||||
export type Action =
|
||||
| { type: "move"; dx: number; dy: number }
|
||||
@@ -15,7 +17,7 @@ export type SimEvent =
|
||||
| { type: "damaged"; targetId: EntityId; amount: number; hp: number; x: number; y: number; isCrit?: boolean; isBlock?: boolean }
|
||||
| { type: "dodged"; targetId: EntityId; x: number; y: number }
|
||||
| { type: "healed"; actorId: EntityId; amount: number; x: number; y: number }
|
||||
| { type: "killed"; targetId: EntityId; killerId: EntityId; x: number; y: number; victimType?: "player" | "rat" | "bat" }
|
||||
| { type: "killed"; targetId: EntityId; killerId: EntityId; x: number; y: number; victimType?: ActorType }
|
||||
|
||||
| { type: "waited"; actorId: EntityId }
|
||||
| { type: "exp-collected"; actorId: EntityId; amount: number; x: number; y: number }
|
||||
@@ -107,7 +109,7 @@ export interface BaseActor {
|
||||
export interface CombatantActor extends BaseActor {
|
||||
category: "combatant";
|
||||
isPlayer: boolean;
|
||||
type: "player" | "rat" | "bat";
|
||||
type: ActorType;
|
||||
speed: number;
|
||||
energy: number;
|
||||
stats: Stats;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { World, EntityId, Action, SimEvent, Actor, CombatantActor, CollectibleActor } from "../../core/types";
|
||||
import type { World, EntityId, Action, SimEvent, Actor, CombatantActor, CollectibleActor, ActorType } from "../../core/types";
|
||||
|
||||
import { isBlocked } from "../world/world-logic";
|
||||
import { GAME_CONFIG } from "../../core/config/GameConfig";
|
||||
@@ -181,7 +181,7 @@ function handleAttack(w: World, actor: Actor, action: { targetId: EntityId }): S
|
||||
killerId: actor.id,
|
||||
x: target.pos.x,
|
||||
y: target.pos.y,
|
||||
victimType: target.type as "player" | "rat" | "bat"
|
||||
victimType: target.type as ActorType
|
||||
});
|
||||
w.actors.delete(target.id);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Phaser from "phaser";
|
||||
import { type World, type EntityId, type Vec2 } from "../core/types";
|
||||
import { type World, type EntityId, type Vec2, type ActorType } from "../core/types";
|
||||
import { TILE_SIZE } from "../core/constants";
|
||||
import { idx, isWall } from "../engine/world/world-logic";
|
||||
import { GAME_CONFIG } from "../core/config/GameConfig";
|
||||
@@ -264,7 +264,7 @@ export class DungeonRenderer {
|
||||
this.fxRenderer.showHeal(x, y, amount);
|
||||
}
|
||||
|
||||
spawnCorpse(x: number, y: number, type: "player" | "rat" | "bat") {
|
||||
spawnCorpse(x: number, y: number, type: ActorType) {
|
||||
this.fxRenderer.spawnCorpse(x, y, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Phaser from "phaser";
|
||||
import { type EntityId } from "../core/types";
|
||||
import { type EntityId, type ActorType } from "../core/types";
|
||||
import { TILE_SIZE } from "../core/constants";
|
||||
import { GAME_CONFIG } from "../core/config/GameConfig";
|
||||
|
||||
@@ -109,7 +109,7 @@ export class FxRenderer {
|
||||
});
|
||||
}
|
||||
|
||||
spawnCorpse(x: number, y: number, type: "player" | "rat" | "bat") {
|
||||
spawnCorpse(x: number, y: number, type: ActorType) {
|
||||
const textureKey = type === "player" ? "warrior" : type;
|
||||
|
||||
const corpse = this.scene.add.sprite(
|
||||
|
||||
Reference in New Issue
Block a user