Merge branch 'twemojiEmoteMenu' of github.com:Lurkars/workadventure into twemojiEmoteMenuSvelte
This commit is contained in:
commit
d23820227e
10 changed files with 225 additions and 89 deletions
|
@ -3,7 +3,7 @@ import type { GameScene } from "../Game/GameScene";
|
|||
import { UserInputEvent, UserInputManager } from "../UserInput/UserInputManager";
|
||||
import { Character } from "../Entity/Character";
|
||||
import { userMovingStore } from "../../Stores/GameStore";
|
||||
import { RadialMenu, RadialMenuClickEvent, RadialMenuItem } from "../Components/RadialMenu";
|
||||
import { EmoteMenu, EmoteMenuClickEvent } from "../Components/EmoteMenu";
|
||||
|
||||
export const hasMovedEventName = "hasMoved";
|
||||
export const requestEmoteEventName = "requestEmote";
|
||||
|
@ -11,7 +11,7 @@ export const requestEmoteEventName = "requestEmote";
|
|||
export class Player extends Character {
|
||||
private previousDirection: string = PlayerAnimationDirections.Down;
|
||||
private wasMoving: boolean = false;
|
||||
private emoteMenu: RadialMenu | null = null;
|
||||
private emoteMenu: EmoteMenu | null = null;
|
||||
private updateListener: () => void;
|
||||
|
||||
constructor(
|
||||
|
@ -94,21 +94,26 @@ export class Player extends Character {
|
|||
return this.wasMoving;
|
||||
}
|
||||
|
||||
openOrCloseEmoteMenu(emotes: RadialMenuItem[]) {
|
||||
if (this.emoteMenu) {
|
||||
openOrCloseEmoteMenu() {
|
||||
if (!this.emoteMenu) {
|
||||
this.emoteMenu = new EmoteMenu(this.scene, this.x, this.y, this.userInputManager);
|
||||
}
|
||||
|
||||
if (this.emoteMenu.isOpen()) {
|
||||
this.closeEmoteMenu();
|
||||
} else {
|
||||
this.openEmoteMenu(emotes);
|
||||
this.openEmoteMenu();
|
||||
}
|
||||
}
|
||||
|
||||
openEmoteMenu(emotes: RadialMenuItem[]): void {
|
||||
openEmoteMenu(): void {
|
||||
this.cancelPreviousEmote();
|
||||
this.emoteMenu = new RadialMenu(this.scene, this.x, this.y, emotes);
|
||||
this.emoteMenu.on(RadialMenuClickEvent, (item: RadialMenuItem) => {
|
||||
if (!this.emoteMenu) return;
|
||||
this.emoteMenu.openPicker();
|
||||
this.emoteMenu.on(EmoteMenuClickEvent, (emote: string) => {
|
||||
this.closeEmoteMenu();
|
||||
this.emit(requestEmoteEventName, item.name);
|
||||
this.playEmote(item.name);
|
||||
this.emit(requestEmoteEventName, emote);
|
||||
this.playEmote(emote);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -121,8 +126,7 @@ export class Player extends Character {
|
|||
|
||||
closeEmoteMenu(): void {
|
||||
if (!this.emoteMenu) return;
|
||||
this.emoteMenu.destroy();
|
||||
this.emoteMenu = null;
|
||||
this.emoteMenu.closePicker();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue