Added Sepia Shader.
Fixes for movecamera command overlapping each other. Fix if a character changes pattern during a move tween it keeps the tween. Pre load checks for henshin01. Some changes and placeholders for custom effects.
This commit is contained in:
parent
6134339bc6
commit
63f79738b0
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let rootUrl = `${window.location.protocol}//${window.location.host}/`;
|
let rootUrl = `${window.location.protocol}//${window.location.host}/`;
|
||||||
|
const baseDimensions = {width: 1334, height: 750};
|
||||||
const screenRatio = 9/16;
|
const screenRatio = 9/16;
|
||||||
|
|
||||||
class commonFunctions {
|
class commonFunctions {
|
||||||
|
123
Js/Player.js
123
Js/Player.js
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const baseDimensions = {width: 1334, height: 750};
|
|
||||||
class Player {
|
class Player {
|
||||||
constructor(pixi, utage, text, audio, shaderscript) {
|
constructor(pixi, utage, text, audio, shaderscript) {
|
||||||
this.pixi = pixi;
|
this.pixi = pixi;
|
||||||
@ -70,7 +69,7 @@ class Player {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//Text
|
//Text
|
||||||
case "":
|
case "": {
|
||||||
//Character Text
|
//Character Text
|
||||||
let Arg2 = c.Arg2;
|
let Arg2 = c.Arg2;
|
||||||
if(c.Arg1 && this.utage.characterInfo[c.Arg1] && !Arg2) {
|
if(c.Arg1 && this.utage.characterInfo[c.Arg1] && !Arg2) {
|
||||||
@ -106,6 +105,38 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case "henshin01_bgmoff": {
|
||||||
|
let Arg2 = c.Arg2;
|
||||||
|
if(c.Arg1 && this.utage.characterInfo[c.Arg1] && !Arg2) {
|
||||||
|
Arg2 = this.defaultCharPattern;
|
||||||
|
}
|
||||||
|
if(this.utage.characterInfo[c.Arg1] && this.utage.characterInfo[c.Arg1][Arg2]) {
|
||||||
|
if(!this.loader.resources[`char|${c.Arg1}|${Arg2}`]) {
|
||||||
|
this.loader.add(`char|${c.Arg1}|${Arg2}`, this.utage.characterInfo[c.Arg1][Arg2].FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "henshin01": {
|
||||||
|
let Arg2 = c.Arg2;
|
||||||
|
if(c.Arg1 && this.utage.characterInfo[c.Arg1] && !Arg2) {
|
||||||
|
Arg2 = this.defaultCharPattern;
|
||||||
|
}
|
||||||
|
if(this.utage.characterInfo[c.Arg1] && this.utage.characterInfo[c.Arg1][Arg2]) {
|
||||||
|
if(!this.loader.resources[`char|${c.Arg1}|${Arg2}`]) {
|
||||||
|
this.loader.add(`char|${c.Arg1}|${Arg2}`, this.utage.characterInfo[c.Arg1][Arg2].FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.utage.soundInfo[c.Arg4]) {
|
||||||
|
if(!toLoadBgm[c.Arg4]) {
|
||||||
|
toLoadBgm[c.Arg4] = this.utage.soundInfo[c.Arg4];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`Failed to get BGM: ${c.Arg4}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "bgm":
|
case "bgm":
|
||||||
if(this.utage.soundInfo[c.Arg1]) {
|
if(this.utage.soundInfo[c.Arg1]) {
|
||||||
if(!toLoadBgm[c.Arg1]) {
|
if(!toLoadBgm[c.Arg1]) {
|
||||||
@ -193,7 +224,6 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//https://jsfiddle.net/60e5pp8d/1/
|
|
||||||
buildShaders() {
|
buildShaders() {
|
||||||
this.shaders.buildShaders();
|
this.shaders.buildShaders();
|
||||||
}
|
}
|
||||||
@ -441,6 +471,16 @@ class Player {
|
|||||||
this.processDivaFadeVert(cur, true, false);
|
this.processDivaFadeVert(cur, true, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "divasepiacamera": { //103500311
|
||||||
|
let filter = this.shaders.shaders['sepia'];
|
||||||
|
filter.uniforms.factor = 0.5;
|
||||||
|
this.layers["bg|mainparent"].container.filters = [filter];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "divasepiacameraclear": {
|
||||||
|
this.layers["bg|mainparent"].container.filters = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "bg": {
|
case "bg": {
|
||||||
let bgInfo = this.utage.textureInfo[cur.Arg1];
|
let bgInfo = this.utage.textureInfo[cur.Arg1];
|
||||||
let container = this.layers[this.bgLayerName].container;
|
let container = this.layers[this.bgLayerName].container;
|
||||||
@ -490,19 +530,23 @@ class Player {
|
|||||||
if(time) {
|
if(time) {
|
||||||
this.waitTime = time * 1000;
|
this.waitTime = time * 1000;
|
||||||
if(cont.scale.x !== scale) {
|
if(cont.scale.x !== scale) {
|
||||||
|
this.cancelLerpOfType('scale.x', cont);
|
||||||
this.lerpTargets.push({type: 'scale.x', object: cont, curTime: 0,
|
this.lerpTargets.push({type: 'scale.x', object: cont, curTime: 0,
|
||||||
time: this.waitTime, finalV: scale, initV: cont.scale.x });
|
time: this.waitTime, finalV: scale, initV: cont.scale.x });
|
||||||
}
|
}
|
||||||
if(cont.scale.y !== scale) {
|
if(cont.scale.y !== scale) {
|
||||||
|
this.cancelLerpOfType('scale.y', cont);
|
||||||
this.lerpTargets.push({type: 'scale.y', object: cont, curTime: 0,
|
this.lerpTargets.push({type: 'scale.y', object: cont, curTime: 0,
|
||||||
time: this.waitTime, finalV: scale, initV: cont.scale.y });
|
time: this.waitTime, finalV: scale, initV: cont.scale.y });
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cont.position.x !== x) {
|
if(cont.position.x !== x) {
|
||||||
|
this.cancelLerpOfType('position.x', cont);
|
||||||
this.lerpTargets.push({type: 'position.x', object: cont, curTime: 0,
|
this.lerpTargets.push({type: 'position.x', object: cont, curTime: 0,
|
||||||
time: this.waitTime, finalV: x, initV: cont.position.x });
|
time: this.waitTime, finalV: x, initV: cont.position.x });
|
||||||
}
|
}
|
||||||
if(cont.position.y !== y) {
|
if(cont.position.y !== y) {
|
||||||
|
this.cancelLerpOfType('position.y', cont);
|
||||||
this.lerpTargets.push({type: 'position.y', object: cont, curTime: 0,
|
this.lerpTargets.push({type: 'position.y', object: cont, curTime: 0,
|
||||||
time: this.waitTime, finalV: y, initV: cont.position.y });
|
time: this.waitTime, finalV: y, initV: cont.position.y });
|
||||||
}
|
}
|
||||||
@ -511,6 +555,10 @@ class Player {
|
|||||||
this.waitTime = 0;
|
this.waitTime = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.cancelLerpOfType('scale.x', cont);
|
||||||
|
this.cancelLerpOfType('scale.y', cont);
|
||||||
|
this.cancelLerpOfType('position.x', cont);
|
||||||
|
this.cancelLerpOfType('position.y', cont);
|
||||||
cont.scale.set(scale, scale);
|
cont.scale.set(scale, scale);
|
||||||
cont.position.set(x, y);
|
cont.position.set(x, y);
|
||||||
}
|
}
|
||||||
@ -525,7 +573,7 @@ class Player {
|
|||||||
if(curChar.charName === cur.Arg1) {
|
if(curChar.charName === cur.Arg1) {
|
||||||
let time = Number(cur.Arg6) * 1000;
|
let time = Number(cur.Arg6) * 1000;
|
||||||
if(!time) { time = 250; }
|
if(!time) { time = 250; }
|
||||||
this.lerpTargets.push({type: 'alpha', object: curChar.sprite, curTime: 0, time: time, finalV: 0, initV: 1, post: "destroy" });
|
this.lerpTargets.push({type: 'alpha', object: curChar.sprite, name: cur.Arg1, curTime: 0, time: time, finalV: 0, initV: 1, post: "destroy" });
|
||||||
this.currentCharacters[c] = undefined;
|
this.currentCharacters[c] = undefined;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -559,9 +607,19 @@ class Player {
|
|||||||
break;
|
break;
|
||||||
//custom effects
|
//custom effects
|
||||||
case "henshin01_bgmoff": //101000111
|
case "henshin01_bgmoff": //101000111
|
||||||
|
this.waitTime = 1000;
|
||||||
this.audio.stopSound('bgm');
|
this.audio.stopSound('bgm');
|
||||||
this.checkPutCharacterScreen(cur, true);
|
this.checkPutCharacterScreen(cur, true);
|
||||||
break;
|
break;
|
||||||
|
case "henshin01":
|
||||||
|
this.waitTime = 1000;
|
||||||
|
this.audio.stopSound('bgm');
|
||||||
|
if(this.utage.soundInfo[cur.Arg4]) {
|
||||||
|
this.audio.playSound(cur.Arg4, 'bgm');
|
||||||
|
}
|
||||||
|
cur.Arg4 = 0;
|
||||||
|
this.checkPutCharacterScreen(cur, true);
|
||||||
|
break;
|
||||||
case "attachit02": //103500221
|
case "attachit02": //103500221
|
||||||
break;
|
break;
|
||||||
case "attacshot12": //103500231
|
case "attacshot12": //103500231
|
||||||
@ -572,6 +630,38 @@ class Player {
|
|||||||
break;
|
break;
|
||||||
case "getitem01": //103400252
|
case "getitem01": //103400252
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "skillmovie": //103500341
|
||||||
|
break;
|
||||||
|
case "arcanoise_appearance02": { //103500341
|
||||||
|
if(cur.Arg1 && cur.Arg2) {
|
||||||
|
let customCommand1 = { Command: "", Arg1: cur.Arg1, Arg2: this.defaultCharPattern, Arg3: 'キャラ右', Arg6: .5 };
|
||||||
|
this.checkPutCharacterScreen(customCommand1, false);
|
||||||
|
let customCommand2 = { Command: "", Arg1: cur.Arg2, Arg2: this.defaultCharPattern, Arg3: 'キャラ左', Arg6: .5 };
|
||||||
|
this.checkPutCharacterScreen(customCommand2, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "noise_disappearance01": //103500331
|
||||||
|
this.waitTime = cur.Arg1 * 1000;
|
||||||
|
break;
|
||||||
|
case "noise_disappearance02": { //103500341
|
||||||
|
this.waitTime = cur.Arg1 * 1000;
|
||||||
|
//let c1 = this.currentCharacters['キャラ右'];
|
||||||
|
//if(c1) {
|
||||||
|
// this.lerpTargets.push({type: 'alpha', object: c1.sprite, curTime: 0, time: 200, finalV: 0, initV: 1, post: "destroy" });
|
||||||
|
// this.currentCharacters['キャラ右'] = undefined;
|
||||||
|
//}
|
||||||
|
//let c2 = this.currentCharacters['キャラ左'];
|
||||||
|
//if(c2) {
|
||||||
|
// this.lerpTargets.push({type: 'alpha', object: c2.sprite, curTime: 0, time: 200, finalV: 0, initV: 1, post: "destroy" });
|
||||||
|
// this.currentCharacters['キャラ左'] = undefined;
|
||||||
|
//}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "noise_disappearance11": //103500341
|
||||||
|
this.waitTime = cur.Arg1 * 1000;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@ -611,7 +701,6 @@ class Player {
|
|||||||
filter.uniforms.time = 0.0;
|
filter.uniforms.time = 0.0;
|
||||||
filter.uniforms.fadeincolor = (clear ? [0.0,0.0,0.0,0.0] : [rgbcolor[0],rgbcolor[1],rgbcolor[2],1.0]);
|
filter.uniforms.fadeincolor = (clear ? [0.0,0.0,0.0,0.0] : [rgbcolor[0],rgbcolor[1],rgbcolor[2],1.0]);
|
||||||
filter.uniforms.fadeoutcolor = (clear ? [rgbcolor[0],rgbcolor[1],rgbcolor[2],1.0] : [0.0,0.0,0.0,0.0]);
|
filter.uniforms.fadeoutcolor = (clear ? [rgbcolor[0],rgbcolor[1],rgbcolor[2],1.0] : [0.0,0.0,0.0,0.0]);
|
||||||
debugger;
|
|
||||||
sprite.filters = [filter];
|
sprite.filters = [filter];
|
||||||
this.lerpTargets.push({type: 'shader', object: sprite, curTime: 0, time: this.waitTime, post: `clearshader|${(clear ? '0' : `${color.alpha}`)}`});
|
this.lerpTargets.push({type: 'shader', object: sprite, curTime: 0, time: this.waitTime, post: `clearshader|${(clear ? '0' : `${color.alpha}`)}`});
|
||||||
}
|
}
|
||||||
@ -697,10 +786,17 @@ class Player {
|
|||||||
sprite.anchor.set(anchor.x, anchor.y);
|
sprite.anchor.set(anchor.x, anchor.y);
|
||||||
sprite.alpha = 0;
|
sprite.alpha = 0;
|
||||||
let fadeTime = 200;
|
let fadeTime = 200;
|
||||||
//If the character is already on screen put te new sprite in the same position as the old one.
|
//If the character is already on screen put the new sprite in the same position as the old one.
|
||||||
if(curChar) {
|
if(curChar) {
|
||||||
sprite.position.x = curChar.sprite.position.x;
|
sprite.position.x = curChar.sprite.position.x;
|
||||||
sprite.position.y = curChar.sprite.position.y;
|
sprite.position.y = curChar.sprite.position.y;
|
||||||
|
//if the current character is doing a tween transfer the tween to the new one.
|
||||||
|
for(let l of this.lerpTargets) {
|
||||||
|
if(l.type.includes('position') && l.object === curChar.sprite) {
|
||||||
|
l.object = sprite;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(cur.Arg4) {
|
if(cur.Arg4) {
|
||||||
sprite.position.x = Number(cur.Arg4);
|
sprite.position.x = Number(cur.Arg4);
|
||||||
@ -887,12 +983,7 @@ class Player {
|
|||||||
} else {
|
} else {
|
||||||
curChar.sprite.alpha = props.alpha;
|
curChar.sprite.alpha = props.alpha;
|
||||||
}
|
}
|
||||||
for(let l of this.lerpTargets) {
|
this.cancelLerpOfType('alpha', curChar.sprite);
|
||||||
if(l.type === 'alpha' && l.object === curChar.sprite) {
|
|
||||||
debugger;
|
|
||||||
l.cancel = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -961,6 +1052,14 @@ class Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelLerpOfType(type, object) {
|
||||||
|
for(let l of this.lerpTargets) {
|
||||||
|
if(l.type.includes(type) && l.object === object) {
|
||||||
|
l.cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processEndCommand(delta) {
|
processEndCommand(delta) {
|
||||||
let cur = this.currentCommand;
|
let cur = this.currentCommand;
|
||||||
switch(cur.Command) {
|
switch(cur.Command) {
|
||||||
|
@ -13,6 +13,7 @@ class Shaders {
|
|||||||
|
|
||||||
vec2 mapCoord( vec2 coord ) {
|
vec2 mapCoord( vec2 coord ) {
|
||||||
coord *= filterArea.xy;
|
coord *= filterArea.xy;
|
||||||
|
coord += filterArea.zw;
|
||||||
return coord;
|
return coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ class Shaders {
|
|||||||
|
|
||||||
vec2 mapCoord( vec2 coord ) {
|
vec2 mapCoord( vec2 coord ) {
|
||||||
coord *= filterArea.xy;
|
coord *= filterArea.xy;
|
||||||
|
coord += filterArea.zw;
|
||||||
return coord;
|
return coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +105,7 @@ class Shaders {
|
|||||||
|
|
||||||
vec2 mapCoord( vec2 coord ) {
|
vec2 mapCoord( vec2 coord ) {
|
||||||
coord *= filterArea.xy;
|
coord *= filterArea.xy;
|
||||||
|
coord += filterArea.zw;
|
||||||
return coord;
|
return coord;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +124,31 @@ class Shaders {
|
|||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
}`
|
}`
|
||||||
|
this.sepiaShader = `
|
||||||
|
precision mediump float;
|
||||||
|
varying vec2 vTextureCoord;
|
||||||
|
uniform sampler2D uSampler;
|
||||||
|
uniform vec2 dimensions;
|
||||||
|
uniform float factor;
|
||||||
|
|
||||||
|
vec4 Sepia( in vec4 color )
|
||||||
|
{
|
||||||
|
return vec4(
|
||||||
|
clamp(color.r * 0.393 + color.g * 0.769 + color.b * 0.189, 0.0, 1.0)
|
||||||
|
, clamp(color.r * 0.349 + color.g * 0.686 + color.b * 0.168, 0.0, 1.0)
|
||||||
|
, clamp(color.r * 0.272 + color.g * 0.534 + color.b * 0.131, 0.0, 1.0)
|
||||||
|
, color.a
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main (void) {
|
||||||
|
gl_FragColor = texture2D(uSampler, vTextureCoord);
|
||||||
|
gl_FragColor = mix(gl_FragColor, Sepia(gl_FragColor), clamp(factor,0.0,1.0));
|
||||||
|
}`
|
||||||
this.shaders = {};
|
this.shaders = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//https://jsfiddle.net/60e5pp8d/1/
|
||||||
buildShaders() {
|
buildShaders() {
|
||||||
let divalefttorightfade = new PIXI.Filter(null, this.leftToRightFadeShader, {
|
let divalefttorightfade = new PIXI.Filter(null, this.leftToRightFadeShader, {
|
||||||
time: { type: 'f', value: 0 },
|
time: { type: 'f', value: 0 },
|
||||||
@ -161,9 +186,16 @@ class Shaders {
|
|||||||
divadowntoupfade.apply = baseShaderApply;
|
divadowntoupfade.apply = baseShaderApply;
|
||||||
this.shaders['divadowntoupfade'] = divadowntoupfade;
|
this.shaders['divadowntoupfade'] = divadowntoupfade;
|
||||||
|
|
||||||
|
let sepia = new PIXI.Filter(null, this.sepiaShader, {
|
||||||
|
factor: { type: 'f', value: 0.5 },
|
||||||
|
dimensions: { type: 'v2', value: [baseDimensions.width, baseDimensions.height] }
|
||||||
|
});
|
||||||
|
sepia.apply = baseShaderApply;
|
||||||
|
this.shaders['sepia'] = sepia;
|
||||||
|
|
||||||
function baseShaderApply(filterManager, input, output) {
|
function baseShaderApply(filterManager, input, output) {
|
||||||
this.uniforms.dimensions[0] = input.sourceFrame.width
|
this.uniforms.dimensions[0] = input.sourceFrame.width;
|
||||||
this.uniforms.dimensions[1] = input.sourceFrame.height
|
this.uniforms.dimensions[1] = input.sourceFrame.height;
|
||||||
filterManager.applyFilter(this, input, output);
|
filterManager.applyFilter(this, input, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user