Unified hunger and thirst/food and water, balanced energy a bit.
This commit is contained in:
parent
357c25e59a
commit
ec2689d4c0
|
@ -7,8 +7,7 @@ G.map = []; // List of island objects, generated/loaded and saved at game start,
|
|||
G.currentScreen = ""; // For pause screen, stats screen, inventory screen
|
||||
G.inventory = {
|
||||
money: 100,
|
||||
food: 10,
|
||||
water: 10,
|
||||
supplies: 20, // How much stuff you have to maintain your crew's illness with.
|
||||
cargo: []
|
||||
};
|
||||
G.stats = {
|
||||
|
@ -22,8 +21,7 @@ G.stats = {
|
|||
crew: 2, // How many crew members you have. Influences how fast your energy recovers.
|
||||
energy: 25, // Drains rate determined by current speed. When drained, currentSpeed reduces until you have enough energy to continue.
|
||||
maxEnergy: 50, // How much to refill your energy to. Can increase with upgrades.
|
||||
hunger: 0,
|
||||
thirst: 0
|
||||
illness: 1 // Your crew's overall health. When this is low, your ship slows down.
|
||||
}
|
||||
|
||||
G.itemSheet = new Image();
|
||||
|
|
|
@ -39,11 +39,9 @@ pr_ship.Do = function () {
|
|||
} else if (ct_down().down) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
if (this.currentSpeed > 1 && G.stats.maxEnergy / G.stats.energy > this.currentSpeed + G.stats.crew) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
this.AdjustSpeedBasedOnEnergy();
|
||||
this.currentSpeed = Math.clamp(this.currentSpeed, 0, 4);
|
||||
|
||||
|
||||
this.moveStepProgress += this.currentSpeed * this.moveStepAmount;
|
||||
if (this.moveStepProgress >= this.moveStepSize) {
|
||||
this.moveStepProgress -= this.moveStepSize;
|
||||
|
@ -129,18 +127,17 @@ pr_ship.CheckMovement = function () {
|
|||
|
||||
pr_ship.UpdateEnergy = function () {
|
||||
this.energyRefillTimer++;
|
||||
if (this.energyRefillTimer >= (100 / G.stats.crew) + ((G.stats.illness) * (100 / G.stats.crew))) {
|
||||
G.stats.energy += G.stats.crew;
|
||||
this.energyRefillTimer = 0;
|
||||
}
|
||||
|
||||
if (this.doTakeStep) {
|
||||
G.stats.energy -= ((this.currentSpeed / G.stats.speed) + ((G.stats.hunger + G.stats.thirst) * 0.1)) * 0.25;
|
||||
|
||||
if (this.energyRefillTimer >= (100 / G.stats.crew) + ((G.stats.hunger + G.stats.thirst) * 10)) {
|
||||
G.stats.energy += G.stats.crew;
|
||||
this.energyRefillTimer = 0;
|
||||
}
|
||||
|
||||
if (G.stats.energy < 0) G.stats.energy = 0;
|
||||
if (G.stats.energy > G.stats.maxEnergy) G.stats.energy = G.stats.maxEnergy;
|
||||
G.stats.energy -= ((this.currentSpeed / G.stats.speed) + ((G.stats.illness) * 0.1)) * 0.25;
|
||||
}
|
||||
|
||||
if (G.stats.energy < 0) G.stats.energy = 0;
|
||||
if (G.stats.energy > G.stats.maxEnergy) G.stats.energy = G.stats.maxEnergy;
|
||||
}
|
||||
|
||||
pr_ship.SeamlessScroll = function () {
|
||||
|
@ -161,3 +158,12 @@ pr_ship.SeamlessScroll = function () {
|
|||
OS.SetCamera({y: 0});
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.AdjustSpeedBasedOnEnergy = function () {
|
||||
if (this.currentSpeed > 3 && G.stats.energy < (G.stats.maxEnergy * 0.3) ||
|
||||
this.currentSpeed > 2 && G.stats.energy < (G.stats.maxEnergy * 0.15) ||
|
||||
this.currentSpeed > 1 && G.stats.energy < (G.stats.maxEnergy * 0.05))
|
||||
{
|
||||
this.currentSpeed--;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue