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

196 lines
6.1 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 Nore;
(function (Nore) {
var Sprite_ActorHp = /** @class */ (function (_super) {
__extends(Sprite_ActorHp, _super);
function Sprite_ActorHp(actor) {
var _this = _super.call(this) || this;
_this._actor = actor;
_this._frame.width = 135;
_this._frame.height = 57;
return _this;
}
Sprite_ActorHp.prototype.update = function () {
_super.prototype.update.call(this);
this.updateTouch();
if (this._lastSpeedUp) {
this.refresh();
} else if (
this._lastHp != Math.floor(this._actor.hpRate() * this.barWidth())
) {
this.refresh();
}
};
Sprite_ActorHp.prototype.barWidth = function () {
return 127;
};
Sprite_ActorHp.prototype.refresh = function () {
this._lastHp = Math.floor(this._actor.hpRate() * this.barWidth());
if (this._actor.hpRate() == 1) {
var gaugeSprite = this.getGaugeSprite(1, 1);
this.addChild(gaugeSprite);
} else {
this._lastSpeedUp = false;
var gaugeSprite = void 0;
if (this._actor.isLastSpeedUp()) {
this._actor.clearLastSpeedUp();
this._lastSpeedUp = true;
gaugeSprite = this.getGaugeSprite(2, this._actor.hpRate());
} else {
gaugeSprite = this.getGaugeSprite(0, this._actor.hpRate());
}
this.addChild(gaugeSprite);
}
};
Sprite_ActorHp.prototype.getGaugeSprite = function (index, rate) {
var baseTexture = Nore.getSystemBaseTexture("main");
var r = new Rectangle(0, 320 + index * 28, Math.floor(127 * rate), 20);
var texture = new PIXI.Texture(baseTexture, r);
return new PIXI.Sprite(texture);
};
Sprite_ActorHp.prototype.updateTouch = function () {
if (!TouchInput.isPressed()) {
return;
}
var touchPos = new Point(TouchInput.x, TouchInput.y);
var localPos = this.worldTransform.applyInverse(touchPos);
if (this._frame.contains(localPos.x, localPos.y + 7)) {
this._actor.speedUp();
}
};
return Sprite_ActorHp;
})(Sprite);
Nore.Sprite_ActorHp = Sprite_ActorHp;
var Sprite_ActorNinshinInfo = /** @class */ (function (_super) {
__extends(Sprite_ActorNinshinInfo, _super);
function Sprite_ActorNinshinInfo(actor, w, h) {
if (w === void 0) {
w = 110;
}
if (h === void 0) {
h = 13;
}
var _this = _super.call(this) || this;
_this._actor = actor;
_this._dousei = actor.dousei();
_this._barWidth = w;
_this._barHeight = h;
_this.bitmap = new Bitmap(_this._barWidth + 30, 20);
return _this;
}
Sprite_ActorNinshinInfo.prototype.update = function () {
_super.prototype.update.call(this);
/*if (this._lastNinshin != Math.floor(this._actor.ninshinRate() * this.barWidth())) {
this.refresh();
}*/
if (this.isChanged()) {
this.refresh();
}
};
Sprite_ActorNinshinInfo.prototype.isChanged = function () {
if (this._nextUpInfo != this._dousei.nextUpInfo()) {
return true;
}
if (this._lastBote != this._actor.boteId) {
return true;
}
return false;
};
Sprite_ActorNinshinInfo.prototype.barWidth = function () {
return this._barWidth;
};
Sprite_ActorNinshinInfo.prototype.refresh = function () {
this._nextUpInfo = this._dousei.nextUpInfo();
this._lastBote = this._actor.boteId;
this.bitmap.clear();
if (!this._nextUpInfo) {
return;
}
if (!this._dousei.isActive()) {
return;
}
this.drawText();
};
Sprite_ActorNinshinInfo.prototype.drawBg = function (type) {
var bitmap = ImageManager.loadSystem("main");
var offset = type == 0 ? 0 : 20;
this.bitmap.blt(bitmap, 169, 173 + offset, 100, 26, 0, 5);
};
Sprite_ActorNinshinInfo.prototype.drawText = function () {
this.bitmap.fontSize = 12;
var xx = 2;
var yy = 3;
var w = 76;
var h = 20;
var text = "";
var bgType = 0;
if (this._actor.isJusei()) {
text = TextManager.douseiJusei;
bgType = 1;
} else if (this._actor.isBote()) {
if (this._dousei.isDouseiNinshin()) {
text = TextManager.douseiSyusan;
} else {
text = TextManager.douseiNinshin;
}
} else if (!this.canNinshin()) {
return;
} else if (this._dousei.isCondom()) {
text = TextManager.douseiCondom;
bgType = 1;
} else {
var isMax = this._dousei.friendshipLevel() == FriendshipLevel.S;
var rate = this._actor.juseiRate(isMax);
var integer = Math.floor(rate);
text = TextManager.douseiFertilization.format(integer);
bgType = 1;
}
this.drawBg(bgType);
this.bitmap.drawText(text, xx, yy, w, h, "center");
};
Sprite_ActorNinshinInfo.prototype.canNinshin = function () {
if (!this._nextUpInfo) {
return false;
}
for (var _i = 0, _a = this._nextUpInfo; _i < _a.length; _i++) {
var info = _a[_i];
if (info.type == AvRequired.manko) {
return true;
}
}
return false;
};
return Sprite_ActorNinshinInfo;
})(Sprite);
Nore.Sprite_ActorNinshinInfo = Sprite_ActorNinshinInfo;
})(Nore || (Nore = {}));