diff --git a/gui/inventoryGUI.js b/gui/inventoryGUI.js index 87208a8..9bd1335 100644 --- a/gui/inventoryGUI.js +++ b/gui/inventoryGUI.js @@ -14,9 +14,11 @@ function drawInventoryGUI() { OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240); if (ct_down().down) { + snd_cursordown.Play(); guiControl.inventory.cursorPosition++; } if (ct_up().down) { + snd_cursorup.Play(); guiControl.inventory.cursorPosition--; } @@ -69,18 +71,22 @@ function drawInventoryGUI() { break; } + snd_select.Play(); guiControl.inventory.cursorPosition = 0; guiControl.inventory.activateDelay = 5; } if (ct_cancel().down) { + snd_select.Play(); guiControl.inventory.show = false; } if (ct_left().down) { + snd_cursorup.Play(); guiControl.inventory.show = false; guiControl.map.activateDelay = 5; guiControl.map.show = true; } if (ct_right().down) { + snd_cursordown.Play(); guiControl.inventory.show = false; guiControl.map.activateDelay = 5; guiControl.map.show = true; @@ -113,6 +119,7 @@ function drawInventoryGUI() { // Button Action if (guiControl.inventory.activateDelay <= 0) { if (ct_confirm().down || ct_cancel().down) { + snd_select.Play(); guiControl.inventory.screen = "main"; guiControl.inventory.activateDelay = 5; guiControl.inventory.cursorPosition = 0; @@ -147,6 +154,7 @@ function drawInventoryGUI() { // Button Action if (guiControl.inventory.activateDelay <= 0) { if (ct_confirm().down || ct_cancel().down) { + snd_select.Play(); guiControl.inventory.screen = "main"; guiControl.inventory.activateDelay = 5; guiControl.inventory.cursorPosition = 1; @@ -193,6 +201,7 @@ function drawInventoryGUI() { // Button Action if (guiControl.inventory.activateDelay <= 0) { if (ct_confirm().down || ct_cancel().down) { + snd_select.Play(); guiControl.inventory.screen = "main"; guiControl.inventory.activateDelay = 5; guiControl.inventory.cursorPosition = 2; // The position where "Supplies" is on main screen. diff --git a/gui/mapGUI.js b/gui/mapGUI.js index 74dfd50..35346d0 100644 --- a/gui/mapGUI.js +++ b/gui/mapGUI.js @@ -40,14 +40,17 @@ function drawMapGUI() { // Button Action if (guiControl.map.activateDelay <= 0) { if (ct_cancel().down) { + snd_select.Play(); guiControl.map.show = false; } if (ct_left().down) { + snd_cursorup.Play(); guiControl.map.show = false; guiControl.inventory.activateDelay = 5; guiControl.inventory.show = true; } if (ct_right().down) { + snd_cursordown.Play(); guiControl.map.show = false; guiControl.inventory.activateDelay = 5; guiControl.inventory.show = true; diff --git a/gui/tradeGUI.js b/gui/tradeGUI.js index 4c836bb..7d0562a 100644 --- a/gui/tradeGUI.js +++ b/gui/tradeGUI.js @@ -29,19 +29,19 @@ function drawTradeGUI() { Oversimplified.context.fillStyle = tmp; if (ct_down().down) { - // Play Move_Cursor sound. + snd_cursordown.Play(); guiControl.trade.cursorPosition++; } if (ct_up().down) { - // Play Move_Cursor_Up sound. + snd_cursorup.Play(); guiControl.trade.cursorPosition--; } if (ct_right().down) { - // Play Move_Cursor sound. + snd_cursordown.Play(); guiControl.trade.page++; } if (ct_left().down) { - // Play Move_Cursor_Up sound. + snd_cursorup.Play(); guiControl.trade.page--; } @@ -86,37 +86,45 @@ function drawTradeGUI() { switch (guiControl.trade.cursorPosition) { case 0: if (guiControl.trade.island.CheckInventory().length > 0) { + snd_select.Play(); guiControl.trade.screen = "buy"; guiControl.trade.activateDelay = 5; } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); } break; case 1: + snd_select.Play(); if (G.inventory.CheckCargo().length > 0) { guiControl.trade.screen = "sell"; guiControl.trade.activateDelay = 5; } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); } break; case 2: + snd_select.Play(); guiControl.trade.screen = "tavern"; guiControl.trade.activateDelay = 5; break; default: - // Change music to Sail. + snd_select.Play(); + mus_trade.Stop(); + mus_sail.Play(); guiControl.trade.show = false; break; } - // Play Select sound. + // snd_select.Play(); guiControl.trade.cursorPosition = 0; guiControl.trade.page = 0; // console.log(guiControl.trade.screen); } if (ct_cancel().down) { + snd_select.Play(); + mus_trade.Stop(); + mus_sail.Play(); guiControl.trade.show = false; } } @@ -190,31 +198,34 @@ function drawTradeGUI() { if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) && // If there are items and you haven't haggled too much guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // Or you haven't haggled yet and get a random number less than your popularity, haggle successfully. { + snd_sell.Play(); guiControl.trade.island.haggleAmount = G.stats.haggling; - // Play Sell sound. } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); guiControl.trade.island.timesHaggledToday++; } break; case 1: // Buy if (items.length > 0 && - G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) { //If cursor is over yes and you can buy, buy it. + G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) //If cursor is over yes and you can buy, buy it. + { + snd_buy.Play(); guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice); } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); } break; default: + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen. break; } - // Play Select sound. // console.log(guiControl.trade.screen); } if (ct_cancel().down) { + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen. @@ -293,10 +304,10 @@ function drawTradeGUI() { if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) && guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // If you haven't haggled yet and get a random number less than your popularity, haggle successfully. { - // Play Sell sound. + snd_sell.Play(); guiControl.trade.island.haggleAmount = G.stats.haggling; } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); guiControl.trade.island.timesHaggledToday++; } break; @@ -304,21 +315,23 @@ function drawTradeGUI() { if (items.length > 0 && G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it. { + snd_sell.Play(); guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice); } else { - // Play Cannot_Buy sound. + snd_cannotbuy.Play(); } break; default: + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen. break; } - // Play Select sound. // console.log(guiControl.trade.screen); } if (ct_cancel().down) { + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen. @@ -363,18 +376,21 @@ function drawTradeGUI() { if (ct_confirm().down) { switch (guiControl.trade.cursorPosition) { case 0: + snd_select.Play(); guiControl.trade.screen = "gossip"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. break; case 1: if (G.stats.illness > 0 && G.inventory.money > innPrice) { //If cursor is over yes, heal illness with supplies. + snd_heal.Play(); guiControl.trade.island.StayAtInn(); } else { - // Play Cant_Buy sound. + snd_cannotbuy.Play(); } break; default: + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. @@ -386,6 +402,7 @@ function drawTradeGUI() { } if (ct_cancel().down) { + snd_select.Play(); guiControl.trade.screen = "main"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. @@ -416,7 +433,7 @@ function drawTradeGUI() { // Button Action if (guiControl.trade.activateDelay <= 0) { if (ct_confirm().down || ct_cancel().down) { - // Play Select sound. + snd_select.Play(); guiControl.trade.screen = "tavern"; guiControl.trade.activateDelay = 5; guiControl.trade.cursorPosition = 0; diff --git a/prefabs/islandPrefab.js b/prefabs/islandPrefab.js index 9153a91..b649048 100644 --- a/prefabs/islandPrefab.js +++ b/prefabs/islandPrefab.js @@ -117,6 +117,8 @@ pr_island.CheckInventory = function () { // Returns an array of indices that hav pr_island.TradeWith = function () { // Change music to Trade. // console.log(this.inventory); + mus_sail.Stop(); + mus_trade.Play(); guiControl.trade.island = this; guiControl.trade.haggleAmount = 0; guiControl.trade.activateDelay = 5; diff --git a/prefabs/shipPrefab.js b/prefabs/shipPrefab.js index 1f7757a..8e4ebb1 100644 --- a/prefabs/shipPrefab.js +++ b/prefabs/shipPrefab.js @@ -214,7 +214,7 @@ pr_ship.AdjustSpeedBasedOnEnergy = function () { pr_ship.CheckIllnessIncrease = function () { var percentChance = G.stats.crew + ((this.currentSpeed / (G.stats.energy + 0.001)) * G.stats.illness); // +0.001 on the off-chance that energy reaches 0. if (Math.randomRange(0, 100) < percentChance) { - // Play Illness sound. + snd_illness.Play(); G.stats.illness++; this.drawSickIndicator += secondsWorthOfFrames(1.5); } diff --git a/prefabs/wavePrefab.js b/prefabs/wavePrefab.js index 7f42df6..712dae6 100644 --- a/prefabs/wavePrefab.js +++ b/prefabs/wavePrefab.js @@ -10,6 +10,11 @@ var pr_wave = OS.P.Add("Wave Particle", { lifeTimer: 100, }); +pr_wave.DoFirst = function () { + if (!snd_wave.IsPlaying()) { + snd_wave.Play(); + } +} pr_wave.Do = function () { // Move around randomly. this.lifeTimer--; diff --git a/rooms/oceanRoom.js b/rooms/oceanRoom.js index 6db75a1..8773b4f 100644 --- a/rooms/oceanRoom.js +++ b/rooms/oceanRoom.js @@ -14,6 +14,8 @@ rm_Ocean.waveTimer = Math.round(Math.randomRange(30, 150)); rm_Ocean.clockTimerCount = 1; // Set it to 1 so it doesn't check for player illness immediately! rm_Ocean.DoFirst = function () { + mus_sail.Play(); + G.player.x = (this.squareSize * (this.squaresX / 2)) - (this.squareSize / 2) - G.player.xBound; G.player.y = (this.squareSize * (this.squaresY / 2)); // console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y); @@ -40,21 +42,22 @@ rm_Ocean.DoFirst = function () { // G.economy.UpdateEconomy(); } rm_Ocean.Do = function () { - // Move G.oceanParticle around based on player's movement. - if (G.oceanParticle.CheckPosition) G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction); - - this.waveTimer--; - if (this.waveTimer <= 0) { - var wave = this.AddObject(OS.P["Wave Particle"]); - wave.x = G.player.x + (randomSmidge() * 4); - wave.y = G.player.y + (randomSmidge() * 4); - - this.waveTimer = Math.round(Math.randomRange(30, 150)); - } - if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded. if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) { + // Move G.oceanParticle around based on player's movement. + if (G.oceanParticle.CheckPosition) G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction); + + this.waveTimer--; + if (this.waveTimer <= 0) { + var wave = this.AddObject(OS.P["Wave Particle"]); + wave.x = G.player.x + (randomSmidge() * 4); + wave.y = G.player.y + (randomSmidge() * 4); + + this.waveTimer = Math.round(Math.randomRange(30, 150)); + } + if (ct_cancel().down) { + snd_select.Play(); guiControl.inventory.activateDelay = 5; guiControl.inventory.show = true; }