little cleanup
This commit is contained in:
parent
06d403ebe3
commit
5ae039b987
@ -11,7 +11,7 @@ vim: ft=typescript
|
|||||||
|
|
||||||
function name(userId: number): string {
|
function name(userId: number): string {
|
||||||
const user = gameScene.MapPlayersByKey.get(userId);
|
const user = gameScene.MapPlayersByKey.get(userId);
|
||||||
return user ? user.PlayerValue : "";
|
return user ? user.playerName : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendFollowRequest() {
|
function sendFollowRequest() {
|
||||||
|
@ -30,8 +30,8 @@ const interactiveRadius = 35;
|
|||||||
|
|
||||||
export abstract class Character extends Container {
|
export abstract class Character extends Container {
|
||||||
private bubble: SpeechBubble | null = null;
|
private bubble: SpeechBubble | null = null;
|
||||||
private readonly playerName: Text;
|
private readonly playerNameText: Text;
|
||||||
public PlayerValue: string;
|
public playerName: string;
|
||||||
public sprites: Map<string, Sprite>;
|
public sprites: Map<string, Sprite>;
|
||||||
protected lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
protected lastDirection: PlayerAnimationDirections = PlayerAnimationDirections.Down;
|
||||||
//private teleportation: Sprite;
|
//private teleportation: Sprite;
|
||||||
@ -59,7 +59,7 @@ export abstract class Character extends Container {
|
|||||||
) {
|
) {
|
||||||
super(scene, x, y /*, texture, frame*/);
|
super(scene, x, y /*, texture, frame*/);
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.PlayerValue = name;
|
this.playerName = name;
|
||||||
this.invisible = true;
|
this.invisible = true;
|
||||||
|
|
||||||
this.sprites = new Map<string, Sprite>();
|
this.sprites = new Map<string, Sprite>();
|
||||||
@ -83,7 +83,7 @@ export abstract class Character extends Container {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.playerName = new Text(scene, 0, playerNameY, name, {
|
this.playerNameText = new Text(scene, 0, playerNameY, name, {
|
||||||
fontFamily: '"Press Start 2P"',
|
fontFamily: '"Press Start 2P"',
|
||||||
fontSize: "8px",
|
fontSize: "8px",
|
||||||
strokeThickness: 2,
|
strokeThickness: 2,
|
||||||
@ -94,8 +94,8 @@ export abstract class Character extends Container {
|
|||||||
fontSize: 35,
|
fontSize: 35,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.playerName.setOrigin(0.5).setDepth(DEPTH_INGAME_TEXT_INDEX);
|
this.playerNameText.setOrigin(0.5).setDepth(DEPTH_INGAME_TEXT_INDEX);
|
||||||
this.add(this.playerName);
|
this.add(this.playerNameText);
|
||||||
|
|
||||||
if (isClickable) {
|
if (isClickable) {
|
||||||
this.setInteractive({
|
this.setInteractive({
|
||||||
@ -114,10 +114,10 @@ export abstract class Character extends Container {
|
|||||||
|
|
||||||
this.outlineColorStoreUnsubscribe = this.outlineColorStore.subscribe((color) => {
|
this.outlineColorStoreUnsubscribe = this.outlineColorStore.subscribe((color) => {
|
||||||
if (color === undefined) {
|
if (color === undefined) {
|
||||||
this.getOutlinePlugin()?.remove(this.playerName);
|
this.getOutlinePlugin()?.remove(this.playerNameText);
|
||||||
} else {
|
} else {
|
||||||
this.getOutlinePlugin()?.remove(this.playerName);
|
this.getOutlinePlugin()?.remove(this.playerNameText);
|
||||||
this.getOutlinePlugin()?.add(this.playerName, {
|
this.getOutlinePlugin()?.add(this.playerNameText, {
|
||||||
thickness: 2,
|
thickness: 2,
|
||||||
outlineColor: color,
|
outlineColor: color,
|
||||||
});
|
});
|
||||||
@ -408,7 +408,7 @@ export abstract class Character extends Container {
|
|||||||
private destroyEmote() {
|
private destroyEmote() {
|
||||||
this.emote?.destroy();
|
this.emote?.destroy();
|
||||||
this.emote = null;
|
this.emote = null;
|
||||||
this.playerName.setVisible(true);
|
this.playerNameText.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get pictureStore(): PictureStore {
|
public get pictureStore(): PictureStore {
|
||||||
|
@ -57,24 +57,10 @@ export class RemotePlayer extends Character {
|
|||||||
actionsMenuStore.clear();
|
actionsMenuStore.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
actionsMenuStore.initialize(this.PlayerValue);
|
actionsMenuStore.initialize(this.playerName);
|
||||||
actionsMenuStore.addAction(
|
for (const action of this.getActionsMenuActions()) {
|
||||||
"Visiting Card", () => {
|
actionsMenuStore.addAction(action.actionName, action.callback);
|
||||||
requestVisitCardsStore.set(this.visitCardUrl);
|
}
|
||||||
actionsMenuStore.clear();
|
|
||||||
});
|
|
||||||
actionsMenuStore.addAction(
|
|
||||||
"Log Hello", () => {
|
|
||||||
console.log('HELLO');
|
|
||||||
});
|
|
||||||
actionsMenuStore.addAction(
|
|
||||||
"Log Goodbye", () => {
|
|
||||||
console.log('GOODBYE');
|
|
||||||
});
|
|
||||||
actionsMenuStore.addAction(
|
|
||||||
"Clear Goodbye Action", () => {
|
|
||||||
actionsMenuStore.removeAction("Log Goodbye");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -96,4 +82,34 @@ export class RemotePlayer extends Character {
|
|||||||
actionsMenuStore.clear();
|
actionsMenuStore.clear();
|
||||||
super.destroy();
|
super.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getActionsMenuActions(): { actionName: string, callback: Function }[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
actionName: "Visiting Card",
|
||||||
|
callback: () => {
|
||||||
|
requestVisitCardsStore.set(this.visitCardUrl);
|
||||||
|
actionsMenuStore.clear();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "Log Hello",
|
||||||
|
callback: () => {
|
||||||
|
console.log('HELLO');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "Log Goodbye",
|
||||||
|
callback: () => {
|
||||||
|
console.log('GOODBYE');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
actionName: "Clear Goodbye Action",
|
||||||
|
callback: () => {
|
||||||
|
actionsMenuStore.removeAction("Log Goodbye");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user