Skip to content

Commit

Permalink
✨ 增加了一些新的音效
Browse files Browse the repository at this point in the history
  • Loading branch information
Littlefean committed Nov 26, 2024
1 parent ad4de27 commit a4dbf70
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/core/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export namespace Settings {
// 音效相关
soundEnabled: boolean;
cuttingLineStartSoundFile: string;
connectLineStartSoundFile: string;
connectFindTargetSoundFile: string;
cuttingLineReleaseSoundFile: string;
// github 相关
githubToken: string;
githubUser: string;
Expand Down Expand Up @@ -78,7 +81,9 @@ export namespace Settings {
// 音效相关
soundEnabled: true,
cuttingLineStartSoundFile: "",

connectLineStartSoundFile: "",
connectFindTargetSoundFile: "",
cuttingLineReleaseSoundFile: "",
// github 相关
githubToken: "",
githubUser: "",
Expand Down
22 changes: 22 additions & 0 deletions src/core/SoundService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ import { Settings } from "./Settings";
export namespace SoundService {

let cuttingLineStartSoundFile = "";
let connectLineStartSoundFile = "";
let connectFindTargetSoundFile = "";
let cuttingLineReleaseSoundFile = "";

export function init() {
Settings.watch("cuttingLineStartSoundFile", (value) => {
cuttingLineStartSoundFile = value;
});
Settings.watch("connectLineStartSoundFile", (value) => {
connectLineStartSoundFile = value;
});
Settings.watch("connectFindTargetSoundFile", (value) => {
connectFindTargetSoundFile = value;
});
Settings.watch("cuttingLineReleaseSoundFile", (value) => {
cuttingLineReleaseSoundFile = value;
});
}

export namespace play {
Expand All @@ -27,14 +39,24 @@ export namespace SoundService {
}

// 开始连接
export function connectLineStart() {
loadAndPlaySound(connectLineStartSoundFile);
}

// 连接吸附到目标点
export function connectFindTarget() {
loadAndPlaySound(connectFindTargetSoundFile);
}

// 自动保存执行特效
// 自动备份执行特效

// 框选增加物体音效

// 切断特效声音
export function cuttingLineRelease() {
loadAndPlaySound(cuttingLineReleaseSoundFile);
}
// 连接成功
}

Expand Down
1 change: 1 addition & 0 deletions src/core/controller/concrete/ControllerCutting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ ControllerCutting.mouseup = (event: MouseEvent) => {
cuttingStartLocation.distance(ControllerCutting.lastMoveLocation) / 10,
),
);
SoundService.play.cuttingLineRelease();
};
6 changes: 5 additions & 1 deletion src/core/controller/concrete/ControllerNodeConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { EdgeRenderer } from "../../render/canvas2d/entityRenderer/edge/EdgeRend
import { ConnectableEntity } from "../../stageObject/StageObject";
import { ConnectPoint } from "../../stageObject/entity/ConnectPoint";
import { v4 } from "uuid";
import { SoundService } from "../../SoundService";

/**
* 右键连线功能 的控制器
Expand Down Expand Up @@ -109,6 +110,8 @@ ControllerNodeConnection.mousedown = (event: MouseEvent) => {
),
);
}
// 播放音效
SoundService.play.connectLineStart();
}
};

Expand All @@ -126,9 +129,10 @@ ControllerNodeConnection.mousemove = (event: MouseEvent) => {
let isFindConnectToNode = false;
for (const entity of StageManager.getConnectableEntity()) {
if (entity.collisionBox.isPointInCollisionBox(worldLocation)) {
// 找到了连接的节点,吸附上去
Stage.connectToEntity = entity;
isFindConnectToNode = true;

SoundService.play.connectFindTarget();
break;
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/pages/settings/sounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ export default function Sounds() {
details={"右键按下时刚开始创建切割线准备切割东西时播放的音效文件。"}
type="text"
/>
<SettingField
icon={<Folder />}
settingKey="connectLineStartSoundFile"
title={"连接线开始音效"}
details={"右键按下时刚开始创建连接时播放的音效文件。"}
type="text"
/>
<SettingField
icon={<Folder />}
settingKey="connectFindTargetSoundFile"
title={"连接线查找目标音效"}
details={"当"}
type="text"
/>
<SettingField
icon={<Folder />}
settingKey="cuttingLineReleaseSoundFile"
title={"切断线释放特效"}
details={"纯粹解压用的"}
type="text"
/>
</>
);
}

0 comments on commit a4dbf70

Please sign in to comment.