50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { game } from "../game";
|
|
import { enemyDamageInfo } from "./enemyDamageInfo";
|
|
import { physicsObject } from "./physicsObject";
|
|
import { playerInventory } from "./playerInventory";
|
|
|
|
export class playerData{
|
|
id : number
|
|
level : number = 1
|
|
room : string = "0_0"
|
|
characterId : number
|
|
inventory : playerInventory = new playerInventory()
|
|
rigidbody : physicsObject = new physicsObject()
|
|
damageInfo : enemyDamageInfo[] = []
|
|
|
|
copyLight(){
|
|
let player : any = {}
|
|
player.id = this.id
|
|
player.room = this.room
|
|
player.rigidbody = this.rigidbody
|
|
player.damageInfo = this.damageInfo
|
|
return player
|
|
}
|
|
|
|
getItemById(id : number){
|
|
let item = this.inventory.items.find(i=>i.id == id)
|
|
return item
|
|
}
|
|
|
|
validateEquipment(){
|
|
if(this.inventory.weapon != -1){
|
|
if(this.getItemById(this.inventory.weapon) == null){
|
|
this.inventory.weapon == -1;
|
|
}
|
|
}
|
|
if(this.inventory.equipment[0] != -1){
|
|
if(this.getItemById(this.inventory.equipment[0]) == null){
|
|
this.inventory.equipment[0] == -1;
|
|
}
|
|
}
|
|
if(this.inventory.equipment[1] != -1){
|
|
if(this.getItemById(this.inventory.equipment[1]) == null){
|
|
this.inventory.equipment[1] == -1;
|
|
}
|
|
}
|
|
}
|
|
|
|
constructor(init?: Partial<playerData>) {
|
|
Object.assign(this, init);
|
|
}
|
|
} |