From ec2689d4c0702c4fd239f34feaf194d8b47bbb04 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Fri, 8 Apr 2016 14:39:12 -0600 Subject: [PATCH] Unified hunger and thirst/food and water, balanced energy a bit. --- loadGameManager.js | 6 ++---- prefabs/shipPrefab.js | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/loadGameManager.js b/loadGameManager.js index e02c0e1..a0fa7ac 100644 --- a/loadGameManager.js +++ b/loadGameManager.js @@ -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(); diff --git a/prefabs/shipPrefab.js b/prefabs/shipPrefab.js index ff68318..f477dc0 100644 --- a/prefabs/shipPrefab.js +++ b/prefabs/shipPrefab.js @@ -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--; + } +}