Commit b884b1aa authored by haiyoucuv's avatar haiyoucuv

init

parent 8d5c2119
...@@ -5,6 +5,7 @@ import store from "@/store/store.ts"; ...@@ -5,6 +5,7 @@ import store from "@/store/store.ts";
import { _asyncThrottle, prefixInteger } from "@/utils/utils.ts"; import { _asyncThrottle, prefixInteger } from "@/utils/utils.ts";
import API from "@/api"; import API from "@/api";
import { GameEvent, globalEvent } from "@/pages/HomePage/Top/GameEvent.ts"; import { GameEvent, globalEvent } from "@/pages/HomePage/Top/GameEvent.ts";
import { BubbleMgr } from "@/pages/HomePage/Top/Components/BubbleMgr.ts";
export interface IBubbleInfo { export interface IBubbleInfo {
id: string; id: string;
...@@ -53,12 +54,21 @@ export class Bubble extends Container implements IBase { ...@@ -53,12 +54,21 @@ export class Bubble extends Container implements IBase {
} }
onPointerUp = _asyncThrottle(async () => { onPointerUp = _asyncThrottle(async () => {
const { x, y, parent } = this;
const { bubbleArr, bubbleMap } = parent as BubbleMgr;
const i = bubbleArr.indexOf(this);
if (i !== -1) bubbleArr[i] = null;
bubbleMap.delete(this.id);
this.removeFromParent();
this.destroy();
const { success, data } = await API.receiveBubble({ id: this.id }); const { success, data } = await API.receiveBubble({ id: this.id });
store.updateIndexThrottle(); store.updateIndexThrottle();
if (success) { if (success) {
globalEvent.emit(GameEvent.ReceiveEffect, this.position); globalEvent.emit(GameEvent.ReceiveEffect, { x, y });
this.removeFromParent();
this.destroy();
} }
}); });
......
...@@ -25,7 +25,6 @@ export class BubbleMgr extends Base { ...@@ -25,7 +25,6 @@ export class BubbleMgr extends Base {
@reactor(() => store.indexData.bubbleRecords) @reactor(() => store.indexData.bubbleRecords)
updateBubble(bubbleRecords: IBubbleInfo[]) { updateBubble(bubbleRecords: IBubbleInfo[]) {
const newBubbleKeys = []; const newBubbleKeys = [];
bubbleRecords.forEach((info) => newBubbleKeys.push(info.id)); bubbleRecords.forEach((info) => newBubbleKeys.push(info.id));
...@@ -43,6 +42,7 @@ export class BubbleMgr extends Base { ...@@ -43,6 +42,7 @@ export class BubbleMgr extends Base {
const { id } = info; const { id } = info;
let bubble = this.bubbleMap.get(id); let bubble = this.bubbleMap.get(id);
if (!bubble) { if (!bubble) {
bubble = this.addChild(new Bubble()); bubble = this.addChild(new Bubble());
...@@ -55,8 +55,6 @@ export class BubbleMgr extends Base { ...@@ -55,8 +55,6 @@ export class BubbleMgr extends Base {
} }
} }
console.log(emptyPos);
bubble.position.set(posArr[emptyPos].x, posArr[emptyPos].y) bubble.position.set(posArr[emptyPos].x, posArr[emptyPos].y)
bubble.ideaEffect(150 * index, Math.random() > 0.5 ? 1 : -1); bubble.ideaEffect(150 * index, Math.random() > 0.5 ? 1 : -1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment