Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | import {AvatarParts, Avatar} from './Avatar'; import {GameData} from './GameData'; import {World} from './World'; import {Viewport} from 'pixi-viewport'; export class PeerAvatar extends Avatar { public socketID: string; constructor(world: World, socketID: string, viewport: Viewport) { super(world, viewport); this.socketID = socketID; const centerPos = GameData.getPeerCenterPos(socketID); if (centerPos === undefined) { console.error("Error: This Peer's CenterPos undefined"); } this.position.set(centerPos?.x, centerPos?.y); } update(): void { if (this.isAvatarChanged()) { const newAvatarImageEnum = GameData.getPeerAvatar(this.socketID); if (newAvatarImageEnum === undefined) return; this.setAvatar(newAvatarImageEnum); this.offCollidable(); } this.changePosition(); this.changeZIndex(); this.changePartRotationDegree(); this.changeLookDirection(); this.changeAvatarFace(); this.changeAvatarFaceScale(); this.changeDivPos(); this.changeVolume(); //Peer의 Avatar번호가 바뀌었으면 바꾸어준다. 아바타를 } private changeVolume(): void { GameData.updateVolumeByDistance(this.socketID); } private changePosition(): void { const centerPos = GameData.getPeerCenterPos(this.socketID); this.position.set(centerPos?.x, centerPos?.y); } private changeZIndex(): void { this.zIndex = this.y + this.height / 2; } private changePartRotationDegree(): void { const partRotateDegree = GameData.getPeerPartRotateDegree(this.socketID); if (partRotateDegree !== undefined) this.partRotateDegree = partRotateDegree; if (partRotateDegree) for (let i = 0; i < 6; ++i) { this.parts[i].angle = partRotateDegree[i]; } } private changeLookDirection(): void { const lookLeft = GameData.getPeerAvatarLookLeft(this.socketID); if (lookLeft === undefined) return; this.scale.x = lookLeft ? -1 : 1; } private isAvatarChanged(): boolean { return this.avatarImageEnum !== GameData.getPeerAvatar(this.socketID); } private changeAvatarFace(): void { const avatarFace = GameData.getPeerAvatarFace(this.socketID); if (avatarFace === undefined) return; this.avatarFace = avatarFace; this.swapFace(); } private changeAvatarFaceScale(): void { const avatarFaceScale = GameData.getPeerAvatarFaceScale(this.socketID); if (avatarFaceScale === undefined) return; this.avatarFaceScale = avatarFaceScale; this.parts[AvatarParts.FACE].scale.set(this.avatarFaceScale); } private changeDivPos(): void { const position = GameData.getPeerCenterPos(this.socketID); const nicknameDiv = GameData.getPeerAvatarNicknameDiv(this.socketID); const textMessage = GameData.getPeerAvatarTextMessage(this.socketID); const textMessageDiv = GameData.getPeerAvatarTextMessageDiv(this.socketID); if (!position || !nicknameDiv || !textMessageDiv) return; if (textMessage) { GameData.divVisibleOnOff(textMessageDiv, nicknameDiv); GameData.setPeerTextMessageDivPos(this, textMessageDiv, 130); } else { GameData.divVisibleOnOff(nicknameDiv, textMessageDiv); GameData.setPeerNicknameDivPos(this, nicknameDiv, 130); } return; } } |