dead-bunny/js/plugins/Nore_FacilityTree.js
2025-01-12 01:21:39 -06:00

688 lines
21 KiB
JavaScript

var __extends =
(this && this.__extends) ||
(function () {
var extendStatics = function (d, b) {
extendStatics =
Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array &&
function (d, b) {
d.__proto__ = b;
}) ||
function (d, b) {
for (var p in b)
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
};
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError(
"Class extends value " + String(b) + " is not a constructor or null"
);
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype =
b === null
? Object.create(b)
: ((__.prototype = b.prototype), new __());
};
})();
var Window_FacilityTree = /** @class */ (function (_super) {
__extends(Window_FacilityTree, _super);
function Window_FacilityTree() {
var _this = this;
var r = new Rectangle(Nore.MAIN_MENU_W, Nore.TOP_Y, 1040, 636);
_this = _super.call(this, r) || this;
_this._timeGaugeEventSpriteList = [];
ImageManager.loadSystem("tree");
_this.createHelpWindow();
return _this;
}
Window_FacilityTree.prototype.start = function () {
this.makeItems();
this.refresh();
//this.selectInitialAv();
this.setHandler("change", this.onChange.bind(this));
};
Window_FacilityTree.prototype.refresh = function () {
this.removeTutoArrow();
this._windowContentsBackSprite.removeChildren();
this._windowContentsBackSprite2.removeChildren();
this._windowContentsSprite.removeChildren();
this._timeGaugeEventSpriteList = [];
_super.prototype.refresh.call(this);
};
Window_FacilityTree.prototype.removeTutoArrow = function () {
if (!this._tutoArrow) {
return;
}
this._windowContentsSprite.removeChild(this._tutoArrow);
this._tutoArrow = null;
};
Window_FacilityTree.prototype.onChange = function () {
var item = this.selectedItem();
if (item) {
if (item.isTaikenbanNg()) {
this._helpWindow.setText(TextManager.facilityTaikenbanNg);
} else {
this._helpWindow.setText(item.facility().description());
}
} else {
this._helpWindow.clear();
}
};
Window_FacilityTree.prototype.updateHelp = function () {};
Window_FacilityTree.prototype.createHelpWindow = function () {
var rect = this.helpWindowRect();
this._helpWindow = new Window_Help2(rect);
this.addChild(this._helpWindow);
};
Window_FacilityTree.prototype.helpWindowRect = function () {
var wx = 0;
var wy = this.height;
var ww = this.width;
var wh = 120;
return new Rectangle(wx, wy, ww, wh);
};
Window_FacilityTree.prototype.selectInitialAv = function () {
if ($gameTemp.av) {
var av = this.findAv($gameTemp.av.itemId());
if (!av) {
this.selectCenter();
return;
}
var index = this.indexOf(av);
if (index >= 0) {
this.select(index);
}
} else {
this.selectCenter();
}
};
Window_FacilityTree.prototype.selectCenter = function () {};
Window_FacilityTree.prototype.indexOf = function (av) {
return av.y * this.maxCols() + av.x;
};
Window_FacilityTree.prototype.refreshCursor = function () {
if (this._cursorAll) {
this.refreshCursorForAll();
} else if (this.index() >= 0) {
var rect = this.itemRect(this.index());
this.setCursorRect(
rect.x - 5,
rect.y - 5,
rect.width - 9,
rect.height - 14
);
} else {
this.setCursorRect(0, 0, 0, 0);
}
};
Window_FacilityTree.prototype.itemWidth = function () {
var w = _super.prototype.itemWidth.call(this);
return w - 5;
};
Window_FacilityTree.prototype.itemRect = function (index) {
var rect = _super.prototype.itemRect.call(this, index);
rect.x += 22;
rect.y += 40;
return rect;
};
Window_FacilityTree.prototype.findAv = function (itemId) {
for (var key in this._avMap) {
var av = this._avMap[key];
if (av.itemId() == itemId) {
return av;
}
}
return null;
};
Window_FacilityTree.prototype.makeItems = function () {
this._avMap = {};
var list = FACILITY_LIST;
for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
var f = list_1[_i];
if (!f.isVisible()) {
continue;
}
this._avMap[this.createKey(f.x, f.y)] = f;
}
};
Window_FacilityTree.prototype.checkFinished = function (list) {
var avList = $slg.avInfo().actorAvList(this._actor.actorId());
for (var _i = 0, list_2 = list; _i < list_2.length; _i++) {
var FacilityItem_1 = list_2[_i];
FacilityItem_1.clear();
}
for (var _a = 0, list_3 = list; _a < list_3.length; _a++) {
var FacilityItem_2 = list_3[_a];
if (this.contains(FacilityItem_2, avList)) {
FacilityItem_2.countUp();
}
}
};
Window_FacilityTree.prototype.contains = function (FacilityItem, avList) {
for (var _i = 0, avList_1 = avList; _i < avList_1.length; _i++) {
var av = avList_1[_i];
if (av.itemId() == FacilityItem.itemId()) {
return true;
}
}
return false;
};
Window_FacilityTree.prototype.maxCols = function () {
return 5;
};
Window_FacilityTree.prototype.itemHeight = function () {
return 70;
};
Window_FacilityTree.prototype.maxItems = function () {
if (!this._avMap) {
return 0;
}
return this.maxY() * this.maxCols();
};
Window_FacilityTree.prototype.maxY = function () {
var max = 0;
for (var key in this._avMap) {
var num = parseInt(key);
var y = Math.round(num / AV_ITEM_Y);
if (max < y) {
max = y;
}
}
return max + 1;
};
Window_FacilityTree.prototype.createKey = function (x, y) {
return x + y * AV_ITEM_Y;
};
Window_FacilityTree.prototype.drawAllItems = function () {
_super.prototype.drawAllItems.call(this);
};
Window_FacilityTree.prototype.drawItemBackground = function (index) {};
Window_FacilityTree.prototype.isCurrentItemEnabled = function () {
var av = this.selectedItem();
if (!av) {
return false;
}
return this.isItemEnabled(av);
};
Window_FacilityTree.prototype.drawAvBg = function (facility, rect) {
if (facility.isFinished() || facility.isConstruction()) {
var sprite_1 = this.getSprite(0, 48 * 2, 172, 48);
sprite_1.x = rect.x;
sprite_1.y = rect.y;
this._windowContentsBackSprite.addChild(sprite_1);
return;
}
if (facility.canSelect(this._avMap)) {
var index = 10;
if (facility.price() <= $gameParty.gold()) {
index = 6;
}
var sprite_2 = this.getSprite(0, 48 * index, 172, 48);
sprite_2.x = rect.x;
sprite_2.y = rect.y;
this._windowContentsBackSprite.addChild(sprite_2);
return;
}
var sprite = this.getSprite(0, 48 * 5, 172, 48);
sprite.x = rect.x;
sprite.y = rect.y;
this._windowContentsBackSprite.addChild(sprite);
};
Window_FacilityTree.prototype.getSprite = function (x, y, w, h) {
var baseTexture = Nore.getSystemBaseTexture("tree");
var r = new Rectangle(x, y, w, h);
var texture = new PIXI.Texture(baseTexture, r);
var s = new PIXI.Sprite(texture);
return s;
};
Window_FacilityTree.prototype.isItemEnabled = function (av) {
return av.canSelect(this._avMap);
};
Window_FacilityTree.prototype.drawItem = function (index) {
var rect = this.itemRect(index);
var key = this.createKey(
index % this.maxCols(),
Math.floor(index / this.maxCols())
);
var f = this._avMap[key];
if (!f) {
return;
}
if (!f.isVisible()) {
return;
}
rect.y -= 2;
this.drawAvBg(f, rect);
this.drawFacilityName(f, rect);
this.drawLock(f, rect);
this.drawTaikenbanNg(f, rect);
this.drawGold(f, rect);
this.drawAvLine(f, rect);
this.drawConstruction(f, rect);
this.drawTutoArrow(f, rect);
};
Window_FacilityTree.prototype.drawTutoArrow = function (f, rect) {
if (!this.isDrawTutoArrow(f)) {
return;
}
var baseTexture2 = Nore.getSystemBaseTexture("0213_sys");
var texture = new PIXI.Texture(baseTexture2);
var sprite = new PIXI.Sprite(texture);
sprite.x = rect.x + 147;
sprite.y = rect.y + 50;
sprite.rotation = (90 / 180) * Math.PI;
this._tutoArrow = sprite;
this._windowContentsSprite.addChild(sprite);
};
Window_FacilityTree.prototype.isDrawTutoArrow = function (f) {
if (f.itemId() == 31) {
if ($gameTutorial.nextTarget() == TextManager.target_1_3) {
if (f.isConstruction()) {
return false;
}
return true;
}
}
if (f.itemId() == 46) {
if ($gameTutorial.nextTarget() == TextManager.target_2_2) {
if (f.isConstruction()) {
return false;
}
return true;
}
}
if (f.itemId() == 48) {
if ($gameTutorial.nextTarget() == TextManager.target_0_2) {
if (f.isConstruction()) {
return false;
}
return true;
}
}
if (f.itemId() == 50) {
if ($gameTutorial.nextTarget() == TextManager.target_4_2) {
if (f.isConstruction()) {
return false;
}
return true;
}
}
if (f.itemId() == 53) {
if ($gameTutorial.nextTarget() == TextManager.target_5_2) {
if (f.isConstruction()) {
return false;
}
return true;
}
}
return false;
};
Window_FacilityTree.prototype.drawTaikenbanNg = function (f, rect) {
if (!f.isTaikenbanNg()) {
return;
}
this.contents.fontSize = 11;
this.drawText(TextManager.taikenbanNg, rect.x - 5, rect.y - 24, 100);
};
Window_FacilityTree.prototype.drawLock = function (f, rect) {
if (!f.isLocked(this._avMap)) {
return;
}
this.drawIcon(Icon.lock, rect.x - 5, rect.y - 20);
};
Window_FacilityTree.prototype.drawGold = function (f, rect) {
if (f.isFinished()) {
return;
}
this.contents.fontSize = 12;
var yy = rect.y + 17;
this.drawIcon(Icon.gold, rect.x + 106, yy + 1);
if (f.price() > $gameParty.gold()) {
if (f.canSelect(this._avMap)) {
this.contents.textColor = ColorManager.deathColor();
} else {
this.contents.textColor = ColorManager.normalColor();
}
} else {
this.contents.textColor = ColorManager.normalColor();
}
this.drawText(f.price(), rect.x + 136, yy, 84);
this.contents.textColor = ColorManager.normalColor();
};
Window_FacilityTree.prototype.drawFacilityName = function (facility, rect) {
var left = rect.x;
this.contents.textColor = ColorManager.normalColor();
if (facility.canSelect(this._avMap)) {
this.changePaintOpacity(true);
if (facility.isFinished()) {
//this.contents.textColor = '#ffffBB'
//this.contents.textColor = ColorManager.crisisColor();
}
} else {
this.changePaintOpacity(false);
}
this.drawIcon(facility.iconIndex(), left + 5, rect.y + 7);
this.contents.fontSize = 16;
if (facility.isFinished()) {
this.drawText(facility.name(), left + 42, rect.y + 4, rect.width - 72);
} else {
this.drawText(facility.name(), left + 42, rect.y - 4, rect.width - 72);
}
};
Window_FacilityTree.prototype.drawConstruction = function (f, rect) {
var e = f.timeGaugeEvent();
if (!e) {
return;
}
var left = rect.x;
var miniSprite = new Sprite_MiniTimeGaugeEvent(
e,
5,
true,
TextManager.facilityConstrunction
);
miniSprite.x = left;
miniSprite.y = rect.y;
this._windowContentsSprite.addChild(miniSprite);
this._timeGaugeEventSpriteList.push(miniSprite);
};
Window_FacilityTree.prototype.drawAvLine = function (av, rect) {
switch (av.direction) {
case AvItemDirection.left:
this.drawLineLeft(rect);
break;
case AvItemDirection.top:
this.drawLineTop(rect);
break;
case AvItemDirection.bottom:
this.drawLineBottom(rect);
break;
case AvItemDirection.right:
this.drawLineRight(rect);
break;
}
};
Window_FacilityTree.prototype.drawLineLeft = function (rect) {
this.contents.fillRect(rect.x - 38, rect.y + 15, 38, 8, "#bbbbbb");
};
Window_FacilityTree.prototype.drawLineRight = function (rect) {
this.contents.fillRect(rect.x + 130, rect.y + 15, 38, 8, "#bbbbbb");
};
Window_FacilityTree.prototype.drawLineTop = function (rect) {
var s = this.getSprite(0, 48 * 8, 10, 40);
s.x = rect.x + 85;
s.y = rect.y - 27;
this._windowContentsBackSprite2.addChild(s);
//this.contents.fillRect(rect.x + 60, rect.y - 27, 8, 28, '#bbbbbb');
};
Window_FacilityTree.prototype.drawLineBottom = function (rect) {
var s = this.getSprite(0, 48 * 8, 10, 40);
s.x = rect.x + 85;
s.y = rect.y + 41;
this._windowContentsBackSprite2.addChild(s);
//this.contents.fillRect(rect.x + 60, rect.y + 42, 8, 28, '#bbbbbb');
};
Window_FacilityTree.prototype.selectedItem = function () {
var index = this.index();
var key = this.createKey(
index % this.maxCols(),
Math.floor(index / this.maxCols())
);
var av = this._avMap[key];
return av;
};
Window_FacilityTree.prototype.selectedFacility = function () {
return this.selectedItem();
};
Window_FacilityTree.prototype.commandX = function () {
var rect = this.itemRect(this.index());
var x = rect.x + this.x + 140;
if (x > 1000) {
return 1000;
}
return x;
};
Window_FacilityTree.prototype.commandY = function () {
var rect = this.itemRect(this.index());
var y = rect.y + this.y + 0;
if (y > 700 + y) {
return 700;
}
return y;
};
return Window_FacilityTree;
})(Window_Selectable);
var FacilityItem = /** @class */ (function () {
function FacilityItem(itemId, x, y, direction) {
if (direction === void 0) {
direction = null;
}
this._itemId = itemId;
this.x = x;
this.y = y;
this.direction = direction;
}
FacilityItem.prototype.itemId = function () {
return this._itemId;
};
FacilityItem.prototype.canSelect = function (map) {
if (this.isConstruction()) {
return false;
}
if (!this.isStageConditionOk()) {
return false;
}
if (this.isInitial()) {
return true;
}
var before = this.searchBeforeAv(map);
if (!before) {
return true;
}
return before.isFinished();
};
FacilityItem.prototype.isStageConditionOk = function () {
var stage = parseInt(this.item().meta["stage"]);
if (stage > 1) {
return stage <= $slg.stage();
}
return true;
};
FacilityItem.prototype.isLocked = function (map) {
if (this.isConstruction()) {
return false;
}
if (this.isFinished()) {
return false;
}
if (this.isTaikenbanNg()) {
return false;
}
return !this.canSelect(map);
};
FacilityItem.prototype.isTaikenbanNg = function () {
if (Nore.isTaikenban()) {
if (this.item().meta["taikenbanNg"]) {
return true;
}
}
return false;
};
FacilityItem.prototype.isConstruction = function () {
return this.timeGaugeEvent() != null;
};
FacilityItem.prototype.timeGaugeEvent = function () {
for (var _i = 0, _a = $slg.timeGaugeEventList(); _i < _a.length; _i++) {
var e = _a[_i];
if (e.type() == TimeGaugeEventType.facility) {
var event_1 = e;
if (event_1.facilityId() == this.itemId()) {
return event_1;
}
}
}
return null;
};
FacilityItem.prototype.isInitial = function () {
return this.item().meta["initial"];
};
FacilityItem.prototype.searchBeforeAv = function (map) {
var x = this.x;
var y = this.y;
switch (this.direction) {
case AvItemDirection.top:
y--;
break;
case AvItemDirection.bottom:
y++;
break;
case AvItemDirection.left:
x--;
break;
case AvItemDirection.right:
x++;
break;
}
for (var key in map) {
var av = map[key];
if (av.x == x && av.y == y) {
return av;
}
}
return null;
};
FacilityItem.prototype.isFinished = function () {
return $slg.facilityInfo().hasFacility(this.itemId());
};
FacilityItem.prototype.isStageVisible = function () {
var stage = parseInt(this.item().meta["stage"]);
if (stage > 1) {
return $slg.stage() >= stage;
} else {
return true;
}
};
FacilityItem.prototype.item = function () {
return $dataItems[this._itemId];
};
FacilityItem.prototype.iconIndex = function () {
var item = this.item();
if (!item) {
return 0;
}
return item.iconIndex;
};
FacilityItem.prototype.name = function () {
var item = this.item();
if (!item) {
return "";
}
switch (ConfigManager.language) {
case "en":
if (item.meta["nameEn"]) {
return item.meta["nameEn"];
}
break;
case "ch":
case "jp":
break;
}
return item.name;
};
FacilityItem.prototype.level = function () {
return parseInt(this.item().meta["lv"]);
};
FacilityItem.prototype.price = function () {
return this.item().price;
};
FacilityItem.prototype.facility = function () {
return $slg.facilityInfo().facilityAt(this.itemId());
};
FacilityItem.prototype.isVisible = function () {
if (!this.isVisibleStage()) {
return false;
}
if (!this.isVisibleSw()) {
return false;
}
return true;
};
FacilityItem.prototype.isVisibleStage = function () {
var stage = parseInt(this.item().meta["stage"]);
if (!isNaN(stage)) {
if ($slg.stage() < stage) {
return false;
}
}
return true;
};
FacilityItem.prototype.isVisibleSw = function () {
var sw = parseInt(this.item().meta["sw"]);
if (!isNaN(sw)) {
if (!$gameSwitches.value(sw)) {
return false;
}
}
return true;
};
return FacilityItem;
})();
var FACILITY_LIST = [
new FacilityItem(31, 0, 0), // 工場 LV1
new FacilityItem(32, 0, 1, AvItemDirection.top), // 工場 LV2
new FacilityItem(33, 0, 2, AvItemDirection.top), // 工場 LV3
//new FacilityItem(34, 0, 3, AvItemDirection.top), // 工場 LV4
//new FacilityItem(38, 0, 4), // 武器 Lv1
//new FacilityItem(39, 0, 5, AvItemDirection.top), // 武器 Lv2
//new FacilityItem(40, 0, 6, AvItemDirection.top), // 武器 Lv3
new FacilityItem(75, 0, 3), // ライブ
new FacilityItem(76, 0, 4, AvItemDirection.top), // ライブ Lv2
new FacilityItem(28, 2, 0), // 訓練 Lv1
new FacilityItem(29, 2, 1, AvItemDirection.top), // 訓練 Lv2
new FacilityItem(30, 2, 2, AvItemDirection.top), // 訓練 Lv3
new FacilityItem(26, 2, 3, AvItemDirection.top), // 訓練 Lv4
new FacilityItem(27, 2, 4, AvItemDirection.top), // 訓練 Lv5
new FacilityItem(24, 2, 5), // 促進
new FacilityItem(71, 1, 0), // 研究所
new FacilityItem(72, 1, 1, AvItemDirection.top), // 研究所 Lv2
new FacilityItem(73, 1, 2, AvItemDirection.top), // 研究所 Lv3
new FacilityItem(74, 1, 3, AvItemDirection.top), // 研究所 Lv4
new FacilityItem(77, 1, 4, AvItemDirection.top), // 研究所 Lv5
new FacilityItem(64, 1, 5), // レーダー
new FacilityItem(79, 1, 6), // ニセ施設
new FacilityItem(80, 1, 7), // ミサイル施設
//new FacilityItem(37, 2, 0), // 兵舎
new FacilityItem(43, 3, 0), // 炊き出し所
new FacilityItem(44, 3, 1, AvItemDirection.top), // 炊き出し所
new FacilityItem(45, 3, 2, AvItemDirection.top), // 炊き出し所
new FacilityItem(46, 4, 0), // 同棲部屋
//new FacilityItem(52, 4, 1, AvItemDirection.top), // 同棲部屋(センリ)
new FacilityItem(48, 4, 1, AvItemDirection.top), // 同棲部屋(マリナ)
new FacilityItem(50, 4, 2, AvItemDirection.top), // 同棲部屋(サキ)
new FacilityItem(53, 4, 3, AvItemDirection.top), // 同棲部屋(ココナ)
//new FacilityItem(47, 4, 1, AvItemDirection.top), // 同棲部屋(ノノカ)
//new FacilityItem(49, 4, 3, AvItemDirection.top), // 同棲部屋(マリナ)
//new FacilityItem(51, 4, 5, AvItemDirection.top), // 同棲部屋(サキ)
//new FacilityItem(55, 0, 4), // 催眠研究所
//new FacilityItem(61, 3, 3), // SM部屋
new FacilityItem(59, 0, 5), // ピアススタジオ
new FacilityItem(60, 0, 6), // アロマ LV1
new FacilityItem(61, 0, 7, AvItemDirection.top), // アロマ LV2
//new FacilityItem(58, 0, 6), // タトゥースタジオ
new FacilityItem(68, 3, 3), // 分娩室
new FacilityItem(69, 3, 4, AvItemDirection.top), // 分娩室LV2
new FacilityItem(67, 3, 5), // 調理室
new FacilityItem(65, 2, 6), // 遺伝子実験センター LV1
new FacilityItem(66, 2, 7, AvItemDirection.top), // 遺伝子実験センター LV2
new FacilityItem(57, 3, 6), // 妊娠促進所
new FacilityItem(56, 3, 7), // 受精研究所
new FacilityItem(23, 4, 4), // 加速器
new FacilityItem(62, 4, 5), // 宣伝広告室
new FacilityItem(83, 4, 6), // 同棲条件なくす
new FacilityItem(82, 4, 7), // 肉体改造研究所
];