forked from OpenWebGAL/WebGAL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59960ea
commit ee7ef35
Showing
20 changed files
with
380 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
bgm:夏影.mp3; | ||
changeBg:0000.png -next; | ||
WebGAL:这是一条测试语句。 -V1.ogg; | ||
pixiPerform:snow -next; | ||
miniAvatar:minipic_test.png -next; | ||
intro:慢慢地|慢慢地|如雪花一般|凋零 -next; | ||
慢慢地,慢慢地,如雪花一般,凋零。 | ||
callScene:test2.txt; | ||
back; | ||
pixiInit: -next; | ||
停止下雪。 | ||
WebGAL4x:这是测试场景的第二条语句,这是测试场景的第二条语句,这是测试场景的第二条语句,这是测试场景的第二条语句; | ||
changeBg:0000e.png -next; | ||
WebGAL4x_Build_4.0.2:这是测试场景的第三条语句; | ||
changeFigure:testFigure04.png -left; | ||
changeFigure: -left -clear -next; | ||
changeFigure:testFigure04.png -right; | ||
changeFigure:testFigure04.png -right; | ||
测试结束; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {ISentence} from '../../../interface/coreInterface/sceneInterface'; | ||
import {IPerform} from '../../../interface/coreInterface/performInterface'; | ||
import {getRef} from "../../../../Core/store/storeRef"; | ||
|
||
/** | ||
* 语句执行的模板代码 | ||
* @param sentence | ||
*/ | ||
export const miniAvatar = (sentence: ISentence): IPerform => { | ||
getRef('stageRef').setStage('miniAvatar', sentence.content); | ||
return { | ||
performName: 'none', | ||
duration: 0, | ||
isOver: false, | ||
isHoldOn: true, | ||
stopFunction: () => { | ||
}, | ||
blockingNext: () => false, | ||
blockingAuto: () => true, | ||
stopTimeout: undefined, // 暂时不用,后面会交给自动清除 | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {ISentence} from '../../../interface/coreInterface/sceneInterface'; | ||
import {IPerform} from '../../../interface/coreInterface/performInterface'; | ||
import {runtime_gamePlay} from "../../../../Core/runtime/gamePlay"; | ||
import pixiRain from "../../../../Core/controller/perform/pixi/pixiScripts/rain"; | ||
import {pixiSnow} from "../../../../Core/controller/perform/pixi/pixiScripts/snow"; | ||
import {pixiController} from "../../../../Core/controller/perform/pixi/pixiController"; | ||
import {logger} from "../../../../Core/util/logger"; | ||
|
||
/** | ||
* 语句执行的模板代码 | ||
* @param sentence | ||
*/ | ||
export const pixi = (sentence: ISentence): IPerform => { | ||
const pixiPerformName = 'PixiPerform' + sentence.content; | ||
runtime_gamePlay.performList.forEach(e => { | ||
if (e.performName === pixiPerformName) { | ||
return { | ||
performName: 'none', | ||
duration: 0, | ||
isOver: false, | ||
isHoldOn: true, | ||
stopFunction: () => { | ||
}, | ||
blockingNext: () => false, | ||
blockingAuto: () => false, | ||
stopTimeout: undefined, // 暂时不用,后面会交给自动清除 | ||
}; | ||
} | ||
}); | ||
let container: any; | ||
switch (sentence.content) { | ||
case 'rain': | ||
container = pixiRain(6, 10); | ||
break; | ||
case 'snow': | ||
container = pixiSnow(3); | ||
break; | ||
} | ||
return { | ||
performName: pixiPerformName, | ||
duration: 0, | ||
isOver: false, | ||
isHoldOn: true, | ||
stopFunction: () => { | ||
logger.warn('卸载pixi演出'); | ||
container.destroy({texture: true, baseTexture: true}); | ||
}, | ||
blockingNext: () => false, | ||
blockingAuto: () => false, | ||
stopTimeout: undefined, // 暂时不用,后面会交给自动清除 | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {commandType, ISentence} from '../../../interface/coreInterface/sceneInterface'; | ||
import {IPerform, IRunPerform} from '../../../interface/coreInterface/performInterface'; | ||
import {runtime_gamePlay} from "../../../../Core/runtime/gamePlay"; | ||
import {logger} from "../../../../Core/util/logger"; | ||
import {getRef} from "../../../../Core/store/storeRef"; | ||
|
||
/** | ||
* 语句执行的模板代码 | ||
* @param sentence | ||
*/ | ||
export const pixiInit = (sentence: ISentence): IPerform => { | ||
runtime_gamePlay.performList.forEach((e) => { | ||
if (e.performName.match(/PixiPerform/)) { | ||
logger.warn('pixi 被脚本重新初始化', e.performName); | ||
/** | ||
* 卸载演出 | ||
*/ | ||
for (let i = 0; i < runtime_gamePlay.performList.length; i++) { | ||
const e2 = runtime_gamePlay.performList[i]; | ||
if (e2.performName === e.performName) { | ||
e2.stopFunction(); | ||
clearTimeout(e2.stopTimeout); | ||
runtime_gamePlay.performList.splice(i, 1); | ||
i--; | ||
} | ||
} | ||
/** | ||
* 从状态表里清除演出 | ||
*/ | ||
const stageStore: any = getRef('stageRef'); | ||
for (let i = 0; i < stageStore.stageState.PerformList.length; i++) { | ||
const e2: IRunPerform = stageStore.stageState.PerformList[i]; | ||
if (e2.script.command === commandType.pixi) { | ||
stageStore.stageState.PerformList.splice(i, 1); | ||
i--; | ||
} | ||
} | ||
} | ||
} | ||
); | ||
return { | ||
performName: 'none', | ||
duration: 0, | ||
isOver: false, | ||
isHoldOn: false, | ||
stopFunction: () => { | ||
}, | ||
blockingNext: () => false, | ||
blockingAuto: () => true, | ||
stopTimeout: undefined, // 暂时不用,后面会交给自动清除 | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
export const pixiController = () => {}; | ||
import * as PIXI from "pixi.js"; | ||
import {runtime_gamePlay} from "../../../../Core/runtime/gamePlay"; | ||
|
||
export const pixiController = (active: boolean) => { | ||
if (active) { | ||
let app = new PIXI.Application({ | ||
backgroundAlpha: 0 | ||
}); | ||
// 清空原节点 | ||
const pixiContainer = document.getElementById('pixiContianer'); | ||
if (pixiContainer) { | ||
pixiContainer.innerHTML = ''; | ||
pixiContainer.appendChild(app.view); | ||
} | ||
|
||
app.renderer.view.style.position = "absolute"; | ||
app.renderer.view.style.display = "block"; | ||
// @ts-ignore | ||
app.renderer.autoResize = true; | ||
const appRoot = document.getElementById('root'); | ||
if (appRoot) { | ||
app.renderer.resize(appRoot.clientWidth, appRoot.clientHeight); | ||
} | ||
app.renderer.view.style.zIndex = '5'; | ||
runtime_gamePlay.currentPixi = app; | ||
} else { | ||
// 清空原节点 | ||
const pixiContainer = document.getElementById('pixiContianer'); | ||
if (pixiContainer) { | ||
pixiContainer.innerHTML = ''; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import * as PIXI from "pixi.js"; | ||
import {runtime_gamePlay} from "../../../../../Core/runtime/gamePlay"; | ||
|
||
export const pixiRain = (rainSpeed: number, number: number) => { | ||
// 动画参数 | ||
// 设置缩放的系数 | ||
const scalePreset = 0.3; | ||
|
||
|
||
const app = runtime_gamePlay.currentPixi; | ||
const container = new PIXI.Container(); | ||
app.stage.addChild(container); | ||
// 创建纹理 | ||
const texture = PIXI.Texture.from('./game/tex/raindrop.png'); | ||
// 将容器移到中心 | ||
container.x = app.screen.width / 2; | ||
container.y = app.screen.height / 2; | ||
container.pivot.x = container.width / 2; | ||
container.pivot.y = container.height / 2; | ||
// 调整缩放 | ||
container.scale.x = 1; | ||
container.scale.y = 1; | ||
// container.rotation = -0.2; | ||
const bunnyList: any = []; | ||
// 监听动画更新 | ||
app.ticker.add((delta: any) => { | ||
// 获取长宽,用于控制雪花出现位置 | ||
const stageWidth = 1600; | ||
const stageHeight = 900; | ||
for (let i = 0; i < number; i++) { | ||
// 创建对象 | ||
const bunny = new PIXI.Sprite(texture); | ||
// 随机雨点大小 | ||
let scaleRand = Math.random(); | ||
if (scaleRand <= 0.5) { | ||
scaleRand = 0.5; | ||
} | ||
bunny.scale.x = scalePreset * scaleRand; | ||
bunny.scale.y = scalePreset * scaleRand; | ||
// 设置锚点 | ||
bunny.anchor.set(0.5); | ||
// 随机雪花位置 | ||
bunny.x = Math.random() * stageWidth - 0.5 * stageWidth; | ||
bunny.y = 0 - 0.5 * stageHeight; | ||
// @ts-ignore | ||
bunny['dropSpeed'] = Math.random() * 2; | ||
// @ts-ignore | ||
bunny['acc'] = Math.random(); | ||
bunny['alpha'] = Math.random(); | ||
if (bunny['alpha'] >= 0.5) { | ||
bunny["alpha"] = 0.5; | ||
} | ||
if (bunny['alpha'] <= 0.2) { | ||
bunny['alpha'] = 0.2; | ||
} | ||
container.addChild(bunny); | ||
// 控制每片雨点 | ||
bunnyList.push(bunny); | ||
} | ||
// 雨点落下 | ||
for (const e of bunnyList) { | ||
e['dropSpeed'] = e['acc'] * 0.01 + e['dropSpeed']; | ||
e.y += delta * rainSpeed * e['dropSpeed'] * 1.1 + 3; | ||
} | ||
// 控制同屏雨点数 | ||
if (bunnyList.length >= 2500) { | ||
bunnyList.unshift(); | ||
container.removeChild(container.children[0]); | ||
} | ||
}); | ||
return container; | ||
}; | ||
|
||
|
||
export default pixiRain; |
Oops, something went wrong.