From e576ecefeeba0bccbca2f26a7744bce65c7e33a9 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 16 Apr 2022 00:44:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=B0=86=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E6=8D=A2=E4=B8=BA=E7=BB=9F=E4=B8=80=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E8=A1=A8=E7=8E=B0=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同时做好准备开发游戏内变量的准备 --- src/Components/Stage/MainStage.tsx | 44 +++++++++---------- .../gamePlay/scripts/setBgFilter.ts | 34 +++++++------- .../gamePlay/scripts/setBgTransform.ts | 32 +++++++------- .../stateInterface/stageInterface.ts | 5 ++- src/Core/store/stage.ts | 8 ++-- 5 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/Components/Stage/MainStage.tsx b/src/Components/Stage/MainStage.tsx index 6b27ec8c8..0179d14d1 100644 --- a/src/Components/Stage/MainStage.tsx +++ b/src/Components/Stage/MainStage.tsx @@ -15,32 +15,32 @@ export const MainStage: FC = () => { const stageStore = useStore(stageStateStore); const GuiState = useStore(GuiStateStore); useEffect(() => { - // const effectList: Array = stageStore.stageState.effects; + const effectList: Array = stageStore.stageState.effects; // 设置效果 setTimeout(() => { - const bg = document.getElementById('MainStage_bg_MainContainer'); - // effectList.forEach(effect => { - // const target = document.getElementById(effect.target); - // if (target) { - // if (effect.filter !== '') { - // target.style.filter = effect.filter; - // } - // if (effect.transform !== '') { - // target.style.transform = effect.transform; - // } - // } - // }); - if (stageStore.stageState.bgTransform !== '') { - if(bg){ - bg.style.transform = stageStore.stageState.bgTransform; - } - } - if (stageStore.stageState.bgFilter !== '') { - if(bg){ - bg.style.filter= stageStore.stageState.bgFilter; + // const bg = document.getElementById('MainStage_bg_MainContainer'); + effectList.forEach(effect => { + const target = document.getElementById(effect.target); + if (target) { + if (effect.filter !== '') { + target.style.filter = effect.filter; + } + if (effect.transform !== '') { + target.style.transform = effect.transform; + } } - } + }); + // if (stageStore.stageState.bgTransform !== '') { + // if(bg){ + // bg.style.transform = stageStore.stageState.bgTransform; + // } + // } + // if (stageStore.stageState.bgFilter !== '') { + // if(bg){ + // bg.style.filter= stageStore.stageState.bgFilter; + // } + // } }, 100); }); return
diff --git a/src/Core/controller/gamePlay/scripts/setBgFilter.ts b/src/Core/controller/gamePlay/scripts/setBgFilter.ts index 5bad6c172..f2f3e9711 100644 --- a/src/Core/controller/gamePlay/scripts/setBgFilter.ts +++ b/src/Core/controller/gamePlay/scripts/setBgFilter.ts @@ -11,23 +11,23 @@ import { logger } from '@/Core/util/logger'; */ export const setBgFilter = (sentence: ISentence): IPerform => { const stageStore = getRef('stageRef'); - // const effectList: Array = __.cloneDeep(stageStore.stageState.effects); - // let isTargetSet = false; - // effectList.forEach((e) => { - // if (e.target === 'MainStage_bg_MainContainer') { - // logger.warn('已存在效果,正在修改'); - // isTargetSet = true; - // e.filter = sentence.content; - // } - // }); - // if (!isTargetSet) { - // effectList.push({ - // target: 'MainStage_bg_MainContainer', - // transform: '', - // filter: sentence.content - // }); - // } - stageStore.setStage('bgFilter', sentence.content); + const effectList: Array =stageStore.stageState.effects; + let isTargetSet = false; + effectList.forEach((e) => { + if (e.target === 'MainStage_bg_MainContainer') { + logger.warn('已存在效果,正在修改'); + isTargetSet = true; + e.filter = sentence.content; + } + }); + if (!isTargetSet) { + effectList.push({ + target: 'MainStage_bg_MainContainer', + transform: '', + filter: sentence.content + }); + } + // stageStore.setStage('bgFilter', sentence.content); return { performName: 'none', duration: 0, diff --git a/src/Core/controller/gamePlay/scripts/setBgTransform.ts b/src/Core/controller/gamePlay/scripts/setBgTransform.ts index 071ee1f3f..6a6bf7ee3 100644 --- a/src/Core/controller/gamePlay/scripts/setBgTransform.ts +++ b/src/Core/controller/gamePlay/scripts/setBgTransform.ts @@ -10,23 +10,23 @@ import * as __ from 'lodash'; */ export const setBgTransform = (sentence: ISentence): IPerform => { const stageStore = getRef('stageRef'); - // const effectList: Array = __.cloneDeep(stageStore.stageState.effects); - // let isTargetSet = false; - // effectList.forEach((e) => { - // if (e.target === 'MainStage_bg_MainContainer') { - // isTargetSet = true; - // e.transform = sentence.content; - // } - // }); - // if (!isTargetSet) { - // effectList.push({ - // target: 'MainStage_bg_MainContainer', - // transform: sentence.content, - // filter: '' - // }); - // } + const effectList: Array = stageStore.stageState.effects; + let isTargetSet = false; + effectList.forEach((e) => { + if (e.target === 'MainStage_bg_MainContainer') { + isTargetSet = true; + e.transform = sentence.content; + } + }); + if (!isTargetSet) { + effectList.push({ + target: 'MainStage_bg_MainContainer', + transform: sentence.content, + filter: '' + }); + } // stageStore.setStage('effects', effectList); - stageStore.setStage('bgTransform',sentence.content); + // stageStore.setStage('bgTransform',sentence.content); return { performName: 'none', duration: 0, diff --git a/src/Core/interface/stateInterface/stageInterface.ts b/src/Core/interface/stateInterface/stageInterface.ts index c19224dfd..c4bb6ac48 100644 --- a/src/Core/interface/stateInterface/stageInterface.ts +++ b/src/Core/interface/stateInterface/stageInterface.ts @@ -5,7 +5,8 @@ import { IRunPerform } from '../coreInterface/performInterface'; * @interface IGameVar */ export interface IGameVar { - [propName: string]: string | boolean | number // 游戏内变量可以是字符串、布尔值、数字 + key:string // 变量名称是字符串 + value: string | boolean | number // 游戏内变量可以是字符串、布尔值、数字 } /** @@ -44,7 +45,7 @@ export interface IStageState { vocal: string // 语音 文件地址(相对或绝对) bgm: string // 背景音乐 文件地址(相对或绝对) miniAvatar: string // 小头像 文件地址(相对或绝对) - GameVar: IGameVar // 游戏内变量 + GameVar: Array // 游戏内变量 effects: Array // 应用的变换 bgTransform:string, bgFilter:string, diff --git a/src/Core/store/stage.ts b/src/Core/store/stage.ts index fc866d11c..f10556678 100644 --- a/src/Core/store/stage.ts +++ b/src/Core/store/stage.ts @@ -20,14 +20,14 @@ export const initState: IStageState = { showText: '', // 文字 showName: '', // 人物名 command: '', // 语句指令 - choose: [], // 选项列表 + choose: [], // 选项列表,现在不用,先预留 vocal: '', // 语音 文件地址(相对或绝对) bgm: '', // 背景音乐 文件地址(相对或绝对) miniAvatar: '', // 小头像 文件地址(相对或绝对) - GameVar: {}, // 游戏内变量 + GameVar: [], // 游戏内变量 effects: [], // 应用的效果 - bgFilter:'', - bgTransform:'', + bgFilter:'', // 现在不用,先预留 + bgTransform:'', // 现在不用,先预留 PerformList: [], // 要启动的演出列表 };