2023-09-21 02:17:18 +08:00
|
|
|
import { enemyDamageInfo } from "./enemyDamageInfo";
|
2023-09-16 05:42:42 +08:00
|
|
|
import { physicsObject } from "./physicsObject";
|
|
|
|
import { playerInventory } from "./playerInventory";
|
|
|
|
|
|
|
|
export class playerData{
|
2023-09-16 17:24:44 +08:00
|
|
|
id : number
|
2023-09-18 18:33:06 +08:00
|
|
|
level : number = 1
|
2023-09-21 02:17:18 +08:00
|
|
|
room : string = "0_0"
|
2023-09-16 05:42:42 +08:00
|
|
|
characterId : number
|
|
|
|
inventory : playerInventory = new playerInventory()
|
|
|
|
rigidbody : physicsObject = new physicsObject()
|
2023-09-21 02:17:18 +08:00
|
|
|
damageInfo : enemyDamageInfo[] = []
|
2023-09-16 05:42:42 +08:00
|
|
|
|
2023-11-02 02:46:59 +08:00
|
|
|
copyStart(){
|
2023-09-16 17:24:44 +08:00
|
|
|
let player : any = {}
|
2023-09-18 18:33:06 +08:00
|
|
|
player.id = this.id
|
2023-11-02 02:46:59 +08:00
|
|
|
player.characterId = this.characterId
|
|
|
|
player.rigidbody = physicsObject.characterOnly(this.rigidbody)
|
|
|
|
return player
|
|
|
|
}
|
|
|
|
|
|
|
|
copyUpdate(){
|
|
|
|
let player : any = {}
|
|
|
|
player.id = this.id
|
|
|
|
if(this.rigidbody == null){
|
|
|
|
console.log(this)
|
|
|
|
}
|
|
|
|
player.rigidbody = physicsObject.characterOnly(this.rigidbody)
|
|
|
|
if(this.damageInfo.length > 0) player.damageInfo = this.damageInfo
|
|
|
|
return player
|
|
|
|
}
|
|
|
|
|
|
|
|
copyInventory(){
|
|
|
|
let player : any = {}
|
|
|
|
player.id = this.id
|
|
|
|
player.inventory = this.inventory
|
2023-09-16 05:42:42 +08:00
|
|
|
return player
|
|
|
|
}
|
2023-09-18 18:33:06 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2023-09-16 05:42:42 +08:00
|
|
|
}
|