From 1e2638c1f04cfcff8d4c59a455bb42694546ff96 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Mon, 11 Apr 2016 22:47:01 -0600 Subject: [PATCH] Little bit of work on Trade screen. --- gui/tradeGUI.js | 12 +++++++++--- prefabs/islandPrefab.js | 8 +++++--- prefabs/shipPrefab.js | 2 +- rooms/oceanRoom.js | 15 +++++++++------ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/gui/tradeGUI.js b/gui/tradeGUI.js index c7bf441..0ef9abb 100644 --- a/gui/tradeGUI.js +++ b/gui/tradeGUI.js @@ -2,7 +2,9 @@ function tradeGUI() { guiControl.trade = { screen: "main", // "main", "buy", "sell", "gossip" cursorPosition: 0, - show: true, // Leaving this in just in case I change my mind about stopping time while trading. + show: false, + + island: null, padding: 2 * OS.S.pixelScale, leftBorder: 12 * OS.S.pixelScale, @@ -15,6 +17,11 @@ function tradeGUI() { function drawTradeGUI() { if (guiControl.trade.show) { + var tmp = Oversimplified.context.fillStyle; + Oversimplified.context.fillStyle = "#D9BEA5"; + Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height); + Oversimplified.context.fillStyle = tmp; + if (ct_down().down) { guiControl.trade.cursorPosition++; } @@ -62,8 +69,7 @@ function drawTradeGUI() { guiControl.trade.screen = "gossip"; break; default: - OS.SetRoom(rm_Ocean); - // guiControl.trade.show = false; + guiControl.trade.show = false; break; } diff --git a/prefabs/islandPrefab.js b/prefabs/islandPrefab.js index cdf8e4c..33f3f94 100644 --- a/prefabs/islandPrefab.js +++ b/prefabs/islandPrefab.js @@ -13,6 +13,7 @@ var pr_island = OS.P.Add("Island", { mapHeight: 1, mapColor: "#00AB00", + inventory: [], priceDifferences: [], itemsSold: [0, 0, 0, 0, // The more you sell, the lower the price gets 0, 0, 0, 0, @@ -21,7 +22,7 @@ var pr_island = OS.P.Add("Island", { itemsBought: [0, 0, 0, 0, // The more you buy, the higher the price gets 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0], + 0, 0, 0, 0] }); pr_island.DoFirst = function () { @@ -34,9 +35,10 @@ pr_island.GetMapPosition = function () { this.mapY = (this.y / OS.S.pixelScale) / (OS.camera.height / OS.S.pixelScale); } -pr_island.SetUpPrices = function () { +pr_island.SetUp = function () { for (var i = 0; i < 15; i++) { - this.priceDifferences[i] = Math.randomRange(-100, 100); + this.inventory[i] = Math.round(Math.randomRange(0, 20)); + this.priceDifferences[i] = Math.round(Math.randomRange(-100, 100)); } } diff --git a/prefabs/shipPrefab.js b/prefabs/shipPrefab.js index bc0e323..efff019 100644 --- a/prefabs/shipPrefab.js +++ b/prefabs/shipPrefab.js @@ -27,7 +27,7 @@ var pr_ship = OS.P.Add("Ship", { }); pr_ship.Do = function () { - if (!guiControl.inventory.show) { + if (!guiControl.inventory.show && !guiControl.trade.show) { if (ct_left().down) { this.direction += 45; } else if (ct_right().down) { diff --git a/rooms/oceanRoom.js b/rooms/oceanRoom.js index 3b642e1..5094bd0 100644 --- a/rooms/oceanRoom.js +++ b/rooms/oceanRoom.js @@ -54,12 +54,14 @@ rm_Ocean.Do = function () { this.waveTimer = Math.round(Math.randomRange(30, 150)); } - if (!guiControl.inventory.show && ct_cancel().down) { - guiControl.inventory.show = true; - } - - if (!guiControl.inventory.show && ct_esc.down) { - OS.SetRoom(rm_Trade); + if (!guiControl.inventory.show && !guiControl.trade.show) { + if (ct_cancel().down) { + guiControl.inventory.show = true; + } + if (ct_esc.down) { + guiControl.trade.show = true; + G.player.speed = 0; + } } } @@ -73,6 +75,7 @@ rm_Ocean.DrawAbove = function () { // drawPixelText("Testing 1 2 3!", 0, 0, 0, "white", 4); // drawPixelText("Testing 1 2 3!", 0, 64, 0, "white", 6); drawInventoryGUI(); + drawTradeGUI(); } rm_Ocean.DoLast = function () {