mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-22 00:21:34 +00:00
Implemented dynamic factory size
This commit is contained in:
parent
e8124b94c3
commit
156ed9268a
1 changed files with 43 additions and 21 deletions
|
@ -107,11 +107,6 @@ function getDirection(dir: Direction) {
|
||||||
return "v";
|
return "v";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const factorySize = {
|
|
||||||
width: 7,
|
|
||||||
height: 7
|
|
||||||
};
|
|
||||||
const blockSize = 50;
|
const blockSize = 50;
|
||||||
|
|
||||||
const factory = createLayer(id, () => {
|
const factory = createLayer(id, () => {
|
||||||
|
@ -151,6 +146,14 @@ const factory = createLayer(id, () => {
|
||||||
}))
|
}))
|
||||||
]);
|
]);
|
||||||
const computedTickRate = computed(() => tickRate.apply(1));
|
const computedTickRate = computed(() => tickRate.apply(1));
|
||||||
|
const factorySize = createSequentialModifier(() => [
|
||||||
|
createAdditiveModifier(() => ({
|
||||||
|
addend: expandFactory.amount,
|
||||||
|
description: "Expand Factory",
|
||||||
|
enabled: () => Decimal.gt(expandFactory.amount.value, 0)
|
||||||
|
}))
|
||||||
|
]);
|
||||||
|
const computedFactorySize = computed(() => new Decimal(factorySize.apply(7)).toNumber());
|
||||||
|
|
||||||
const energyBar = createBar(() => ({
|
const energyBar = createBar(() => ({
|
||||||
width: 680,
|
width: 680,
|
||||||
|
@ -671,6 +674,11 @@ const factory = createLayer(id, () => {
|
||||||
const trainedElves = createResource<DecimalSource>(sumElves, "trained elves");
|
const trainedElves = createResource<DecimalSource>(sumElves, "trained elves");
|
||||||
const elvesEffect = computed(() => Decimal.add(trainedElves.value, 1).log10().add(1));
|
const elvesEffect = computed(() => Decimal.add(trainedElves.value, 1).log10().add(1));
|
||||||
|
|
||||||
|
const expandFactory = createBuyable(() => ({
|
||||||
|
canPurchase: true
|
||||||
|
}));
|
||||||
|
const factoryBuyables = { expandFactory };
|
||||||
|
|
||||||
// pixi
|
// pixi
|
||||||
|
|
||||||
// load every sprite here so pixi doesn't complain about loading multiple times
|
// load every sprite here so pixi doesn't complain about loading multiple times
|
||||||
|
@ -709,16 +717,20 @@ const factory = createLayer(id, () => {
|
||||||
app.stage.addChild(spriteContainer);
|
app.stage.addChild(spriteContainer);
|
||||||
|
|
||||||
const floorGraphics = new Graphics();
|
const floorGraphics = new Graphics();
|
||||||
floorGraphics.beginFill(0x70645d);
|
|
||||||
floorGraphics.drawRect(
|
|
||||||
(-factorySize.width * blockSize) / 2,
|
|
||||||
(-factorySize.height * blockSize) / 2,
|
|
||||||
factorySize.width * blockSize,
|
|
||||||
factorySize.height * blockSize
|
|
||||||
);
|
|
||||||
floorGraphics.endFill();
|
|
||||||
spriteContainer.addChild(floorGraphics);
|
spriteContainer.addChild(floorGraphics);
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
floorGraphics.clear();
|
||||||
|
floorGraphics.beginFill(0x70645d);
|
||||||
|
floorGraphics.drawRect(
|
||||||
|
(-computedFactorySize.value * blockSize) / 2,
|
||||||
|
(-computedFactorySize.value * blockSize) / 2,
|
||||||
|
computedFactorySize.value * blockSize,
|
||||||
|
computedFactorySize.value * blockSize
|
||||||
|
);
|
||||||
|
floorGraphics.endFill();
|
||||||
|
});
|
||||||
|
|
||||||
await assetsLoading;
|
await assetsLoading;
|
||||||
|
|
||||||
if (Array.isArray(components.value)) {
|
if (Array.isArray(components.value)) {
|
||||||
|
@ -956,16 +968,23 @@ const factory = createLayer(id, () => {
|
||||||
y: number,
|
y: number,
|
||||||
data: Partial<FactoryComponent> & { type: BuildableCompName }
|
data: Partial<FactoryComponent> & { type: BuildableCompName }
|
||||||
) {
|
) {
|
||||||
if (x < -factorySize.width / 2 || x >= factorySize.width / 2) return;
|
if (x < -computedFactorySize.value / 2 || x >= computedFactorySize.value / 2) return;
|
||||||
if (y < -factorySize.height / 2 || y >= factorySize.height / 2) return;
|
if (y < -computedFactorySize.value / 2 || y >= computedFactorySize.value / 2) return;
|
||||||
|
|
||||||
const factoryBaseData = FACTORY_COMPONENTS[data.type];
|
const factoryBaseData = FACTORY_COMPONENTS[data.type];
|
||||||
if (factoryBaseData == undefined) return;
|
if (factoryBaseData == undefined) return;
|
||||||
const sheet = Assets.get(factoryBaseData.imageSrc);
|
const sheet = Assets.get(factoryBaseData.imageSrc);
|
||||||
const sprite = new Sprite(sheet);
|
const sprite = new Sprite(sheet);
|
||||||
|
|
||||||
sprite.x = x * blockSize;
|
watchEffect(() => {
|
||||||
sprite.y = y * blockSize;
|
if (computedFactorySize.value % 2 === 0) {
|
||||||
|
sprite.x = (x + 0.5) * blockSize;
|
||||||
|
sprite.y = (y + 0.5) * blockSize;
|
||||||
|
} else {
|
||||||
|
sprite.x = x * blockSize;
|
||||||
|
sprite.y = y * blockSize;
|
||||||
|
}
|
||||||
|
});
|
||||||
sprite.width = blockSize;
|
sprite.width = blockSize;
|
||||||
sprite.height = blockSize;
|
sprite.height = blockSize;
|
||||||
sprite.anchor.x = 0.5;
|
sprite.anchor.x = 0.5;
|
||||||
|
@ -1104,12 +1123,12 @@ const factory = createLayer(id, () => {
|
||||||
// the maximum you can see currently
|
// the maximum you can see currently
|
||||||
// total size of blocks - current size = amount you should move
|
// total size of blocks - current size = amount you should move
|
||||||
mapOffset.x = Math.min(
|
mapOffset.x = Math.min(
|
||||||
Math.max(mapOffset.x, (-factorySize.width + 1) / 2),
|
Math.max(mapOffset.x, (-computedFactorySize.value + 1) / 2),
|
||||||
(factorySize.width + 1) / 2
|
(computedFactorySize.value + 1) / 2
|
||||||
);
|
);
|
||||||
mapOffset.y = Math.min(
|
mapOffset.y = Math.min(
|
||||||
Math.max(mapOffset.y, (-factorySize.height + 1) / 2),
|
Math.max(mapOffset.y, (-computedFactorySize.value + 1) / 2),
|
||||||
(factorySize.height + 1) / 2
|
(computedFactorySize.value + 1) / 2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!pointerDown.value && !pointerDrag.value) {
|
if (!pointerDown.value && !pointerDrag.value) {
|
||||||
|
@ -1395,6 +1414,8 @@ const factory = createLayer(id, () => {
|
||||||
)}x`}
|
)}x`}
|
||||||
/>
|
/>
|
||||||
{renderRow(...Object.values(elfBuyables))}
|
{renderRow(...Object.values(elfBuyables))}
|
||||||
|
<Spacer />
|
||||||
|
{renderRow(...Object.values(factoryBuyables))}
|
||||||
</>
|
</>
|
||||||
))
|
))
|
||||||
})),
|
})),
|
||||||
|
@ -1503,6 +1524,7 @@ const factory = createLayer(id, () => {
|
||||||
components,
|
components,
|
||||||
elfBuyables,
|
elfBuyables,
|
||||||
tabs,
|
tabs,
|
||||||
|
factoryBuyables,
|
||||||
generalTabCollapsed,
|
generalTabCollapsed,
|
||||||
hotkeys,
|
hotkeys,
|
||||||
display: jsx(() => (
|
display: jsx(() => (
|
||||||
|
|
Loading…
Reference in a new issue