208 lines
5.3 KiB
JavaScript
208 lines
5.3 KiB
JavaScript
|
|
var OutSideType = {
|
|
LEFT: 0,
|
|
TOP: 1,
|
|
RIGHT: 2,
|
|
BOTTOM: 3,
|
|
LEFTRIGHT: 4,
|
|
TOPBOTTOM: 5
|
|
};
|
|
|
|
var OutSideManager = {
|
|
_leftRange: null,
|
|
_topRange: null,
|
|
_rightRange: null,
|
|
_bottomRange: null,
|
|
_outSideObject: null,
|
|
_outSideObject2: null,
|
|
_picCache: null,
|
|
_picCache2: null,
|
|
_picCacheAll: null,
|
|
_activeFlag: false,
|
|
_activeFlag2: false,
|
|
|
|
initSingleton: function() {
|
|
var type = this.getOutSideType();
|
|
var n = this.getOutSideSpace();
|
|
var width = root.getWindowWidth();
|
|
var height = root.getWindowHeight();
|
|
|
|
if (type === -1) {
|
|
return;
|
|
}
|
|
|
|
this._leftRange = createRangeObject(0, 0, n, height);
|
|
this._topRange = createRangeObject(0, 0, width, n);
|
|
this._rightRange = createRangeObject(width - n, 0, n, height);
|
|
this._bottomRange = createRangeObject(0, height - n, width, n);
|
|
|
|
this._createOutSideObject(type);
|
|
if (this._outSideObject !== null || this._outSideObject2 !== null) {
|
|
root.allocateOutSideSpace(type, n);
|
|
this._picCacheAll = root.getGraphicsManager().createCacheGraphics(root.getWindowWidth(), root.getWindowHeight());
|
|
}
|
|
},
|
|
|
|
moveOutSideManagerCycle: function() {
|
|
if (this._outSideObject !== null) {
|
|
this._outSideObject.moveOutSide();
|
|
}
|
|
|
|
if (this._outSideObject2 !== null) {
|
|
this._outSideObject2.moveOutSide();
|
|
}
|
|
|
|
return MoveResult.CONTINUE;
|
|
},
|
|
|
|
drawOutSideManagerCycle: function() {
|
|
var isActive = this._isActive();
|
|
|
|
if (!this._isOutSideAllowed()) {
|
|
return;
|
|
}
|
|
|
|
if (this._outSideObject !== null) {
|
|
if (isActive || !this._outSideObject.isCacheAllowed()) {
|
|
this._outSideObject.drawOutSide();
|
|
this._activeFlag = true;
|
|
}
|
|
else {
|
|
this._drawCache(this._outSideObject, this._picCache, this._activeFlag);
|
|
this._activeFlag = false;
|
|
}
|
|
}
|
|
|
|
if (this._outSideObject2 !== null) {
|
|
if (isActive || !this._outSideObject2.isCacheAllowed()) {
|
|
this._outSideObject2.drawOutSide();
|
|
this._activeFlag2 = true;
|
|
}
|
|
else {
|
|
this._drawCache(this._outSideObject2, this._picCache2, this._activeFlag2);
|
|
this._activeFlag2 = false;
|
|
}
|
|
}
|
|
|
|
this._drawFadeOut();
|
|
},
|
|
|
|
getOutSideObject: function() {
|
|
return this._outSideObject;
|
|
},
|
|
|
|
getOutSideObject2: function() {
|
|
return this._outSideObject2;
|
|
},
|
|
|
|
getOutSideType: function() {
|
|
return -1;
|
|
},
|
|
|
|
getOutSideSpace: function() {
|
|
return 0;
|
|
},
|
|
|
|
_isOutSideAllowed: function() {
|
|
return true;
|
|
},
|
|
|
|
_isActive: function() {
|
|
// 画面が表示されておらず、イベントでもなく、戦闘時でもない
|
|
return SceneManager.getScreenCount() === 0 && root.getCurrentScene() !== SceneType.EVENT && !AttackControl.isAttack();
|
|
},
|
|
|
|
_drawCache: function(outSideObject, picCache, activeFlag) {
|
|
var range = outSideObject.getOutSideRange();
|
|
var graphicsManager = root.getGraphicsManager();
|
|
|
|
if (!activeFlag && picCache.isCacheAvailable()) {
|
|
picCache.drawStretchParts(range.x, range.y, range.width, range.height, 0, 0, range.width, range.height);
|
|
return;
|
|
}
|
|
|
|
graphicsManager.setRenderCache(this._picCacheAll);
|
|
outSideObject.drawOutSide();
|
|
outSideObject.fillOutSide(this._getNonActiveColor(), this._getNonActiveAlpha());
|
|
graphicsManager.resetRenderCache();
|
|
|
|
graphicsManager.copyCache(picCache, 0, 0, this._picCacheAll, range.x, range.y, range.width, range.height);
|
|
picCache.drawStretchParts(range.x, range.y, range.width, range.height, 0, 0, range.width, range.height);
|
|
},
|
|
|
|
_drawFadeOut: function() {
|
|
var effect = root.getScreenEffect();
|
|
var sceneType = root.getBaseScene();
|
|
|
|
if (sceneType !== SceneType.BATTLERESULT) {
|
|
return;
|
|
}
|
|
|
|
if (this._outSideObject !== null) {
|
|
this._outSideObject.fillOutSide(effect.getColor(), effect.getAlpha());
|
|
}
|
|
|
|
if (this._outSideObject2 !== null) {
|
|
this._outSideObject2.fillOutSide(effect.getColor(), effect.getAlpha());
|
|
}
|
|
},
|
|
|
|
_getNonActiveColor: function() {
|
|
return 0x0;
|
|
},
|
|
|
|
_getNonActiveAlpha: function() {
|
|
return 20;
|
|
},
|
|
|
|
_createOutSideObject: function(type) {
|
|
var obj;
|
|
var range = null;
|
|
var range2 = null;
|
|
|
|
if (type === OutSideType.LEFT) {
|
|
range = this._leftRange;
|
|
}
|
|
else if (type === OutSideType.TOP) {
|
|
range = this._topRange;
|
|
}
|
|
else if (type === OutSideType.RIGHT) {
|
|
range = this._rightRange;
|
|
}
|
|
else if (type === OutSideType.BOTTOM) {
|
|
range = this._bottomRange;
|
|
}
|
|
else if (type === OutSideType.LEFTRIGHT) {
|
|
range = this._leftRange;
|
|
range2 = this._rightRange;
|
|
}
|
|
else if (type === OutSideType.TOPBOTTOM) {
|
|
range = this._topRange;
|
|
range2 = this._bottomRange;
|
|
}
|
|
|
|
obj = this._declareOutSideObject();
|
|
if (obj !== null) {
|
|
this._outSideObject = createObject(obj);
|
|
this._outSideObject.setOutSideRange(range);
|
|
this._outSideObject.prepareOutSideData();
|
|
this._picCache = root.getGraphicsManager().createCacheGraphics(range.width, range.height);
|
|
}
|
|
|
|
obj = this._declareOutSideObject2();
|
|
if (obj !== null) {
|
|
this._outSideObject2 = createObject(obj);
|
|
this._outSideObject2.setOutSideRange(range2);
|
|
this._outSideObject2.prepareOutSideData();
|
|
this._picCache2 = root.getGraphicsManager().createCacheGraphics(range2.width, range2.height);
|
|
}
|
|
},
|
|
|
|
_declareOutSideObject: function() {
|
|
return null;
|
|
},
|
|
|
|
_declareOutSideObject2: function() {
|
|
return null;
|
|
}
|
|
};
|