Resized the ocean. Added map! Updated trade so you can't haggle forever. Each island knows when it's been haggled.
This commit is contained in:
parent
d86b36883d
commit
d45246b3d5
|
@ -2,12 +2,15 @@ function inventoryGUI() {
|
||||||
guiControl.inventory = {
|
guiControl.inventory = {
|
||||||
screen: "main",
|
screen: "main",
|
||||||
cursorPosition: 0,
|
cursorPosition: 0,
|
||||||
show: false
|
show: false,
|
||||||
|
activateDelay: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawInventoryGUI() {
|
function drawInventoryGUI() {
|
||||||
if (guiControl.inventory && guiControl.inventory.show) {
|
if (guiControl.inventory && guiControl.inventory.show) {
|
||||||
|
guiControl.inventory.activateDelay -= (guiControl.inventory.activateDelay > 0) ? 1 : 0;
|
||||||
|
|
||||||
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
||||||
|
|
||||||
if (ct_down().down) {
|
if (ct_down().down) {
|
||||||
|
@ -28,6 +31,10 @@ function drawInventoryGUI() {
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
guiControl.drawPixelText("Storage", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
guiControl.drawPixelText("Storage", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
||||||
|
|
||||||
|
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||||
|
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||||
|
|
||||||
// Money icon
|
// Money icon
|
||||||
guiControl.drawIcon(7, 2, guiControl.leftBorder, guiControl.rowTop(0));
|
guiControl.drawIcon(7, 2, guiControl.leftBorder, guiControl.rowTop(0));
|
||||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(0) + pixel(), 8, "black", 6);
|
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(0) + pixel(), 8, "black", 6);
|
||||||
|
@ -45,23 +52,39 @@ function drawInventoryGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition));
|
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down) {
|
if (guiControl.inventory.activateDelay <= 0) {
|
||||||
switch (guiControl.inventory.cursorPosition) {
|
if (ct_confirm().down) {
|
||||||
case 0:
|
switch (guiControl.inventory.cursorPosition) {
|
||||||
guiControl.inventory.screen = "money";
|
case 0:
|
||||||
break;
|
guiControl.inventory.screen = "money";
|
||||||
case 1:
|
break;
|
||||||
guiControl.inventory.screen = "supplies";
|
case 1:
|
||||||
break;
|
guiControl.inventory.screen = "supplies";
|
||||||
case 2:
|
break;
|
||||||
guiControl.inventory.screen = "cargo";
|
case 2:
|
||||||
break;
|
guiControl.inventory.screen = "cargo";
|
||||||
default:
|
break;
|
||||||
guiControl.inventory.show = false;
|
default:
|
||||||
break;
|
guiControl.inventory.show = false;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
guiControl.inventory.cursorPosition = 0;
|
guiControl.inventory.cursorPosition = 0;
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
}
|
||||||
|
if (ct_cancel().down) {
|
||||||
|
guiControl.inventory.show = false;
|
||||||
|
}
|
||||||
|
if (ct_left().down) {
|
||||||
|
guiControl.inventory.show = false;
|
||||||
|
guiControl.map.activateDelay = 5;
|
||||||
|
guiControl.map.show = true;
|
||||||
|
}
|
||||||
|
if (ct_right().down) {
|
||||||
|
guiControl.inventory.show = false;
|
||||||
|
guiControl.map.activateDelay = 5;
|
||||||
|
guiControl.map.show = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.inventory.screen == "money") {
|
else if (guiControl.inventory.screen == "money") {
|
||||||
|
@ -88,9 +111,12 @@ function drawInventoryGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down || ct_cancel().down) {
|
if (guiControl.inventory.activateDelay <= 0) {
|
||||||
guiControl.inventory.screen = "main";
|
if (ct_confirm().down || ct_cancel().down) {
|
||||||
guiControl.inventory.cursorPosition = 0;
|
guiControl.inventory.screen = "main";
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
guiControl.inventory.cursorPosition = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.inventory.screen == "supplies") {
|
else if (guiControl.inventory.screen == "supplies") {
|
||||||
|
@ -115,7 +141,7 @@ function drawInventoryGUI() {
|
||||||
|
|
||||||
// Yes/No options
|
// Yes/No options
|
||||||
guiControl.drawPixelText("No", guiControl.leftBorder, guiControl.rowTop(2) - pixel(3), 3, "black", 6);
|
guiControl.drawPixelText("No", guiControl.leftBorder, guiControl.rowTop(2) - pixel(3), 3, "black", 6);
|
||||||
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - pixel(3), 3, "black", 6);
|
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - pixel(3), 3, (G.inventory.supplies > 0 && G.stats.illness > 0) ? "black" : "white", 6);
|
||||||
|
|
||||||
// Back Text
|
// Back Text
|
||||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||||
|
@ -124,24 +150,30 @@ function drawInventoryGUI() {
|
||||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition + 2) - pixel(4));
|
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition + 2) - pixel(4));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down) {
|
if (guiControl.inventory.activateDelay <= 0) {
|
||||||
switch (guiControl.inventory.cursorPosition) {
|
if (ct_confirm().down) {
|
||||||
case 1:
|
switch (guiControl.inventory.cursorPosition) {
|
||||||
if (G.inventory.supplies > 0 && G.stats.illness > 0) { //If cursor is over yes, heal illness with supplies.
|
case 1:
|
||||||
G.inventory.supplies--;
|
if (G.inventory.supplies > 0 && G.stats.illness > 0) { //If cursor is over yes, heal illness with supplies.
|
||||||
G.stats.illness--;
|
G.inventory.supplies--;
|
||||||
}
|
G.stats.illness--;
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
guiControl.inventory.screen = "main";
|
default:
|
||||||
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
guiControl.inventory.screen = "main";
|
||||||
break;
|
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct_cancel().down) {
|
// Give a cooldown so you don't accidentally do something you don't want.
|
||||||
guiControl.inventory.screen = "main";
|
guiControl.inventory.activateDelay = 5;
|
||||||
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
}
|
||||||
|
|
||||||
|
if (ct_cancel().down) {
|
||||||
|
guiControl.inventory.screen = "main";
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.inventory.screen == "cargo") {
|
else if (guiControl.inventory.screen == "cargo") {
|
||||||
|
@ -170,9 +202,12 @@ function drawInventoryGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down || ct_cancel().down) {
|
if (guiControl.inventory.activateDelay <= 0) {
|
||||||
guiControl.inventory.screen = "main";
|
if (ct_confirm().down || ct_cancel().down) {
|
||||||
guiControl.inventory.cursorPosition = 2;
|
guiControl.inventory.screen = "main";
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
guiControl.inventory.cursorPosition = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
function mapGUI() {
|
||||||
|
guiControl.map = {
|
||||||
|
show: false,
|
||||||
|
activateDelay: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawMapGUI() {
|
||||||
|
if (guiControl.map && guiControl.map.show) {
|
||||||
|
guiControl.map.activateDelay -= (guiControl.map.activateDelay > 0) ? 1 : 0;
|
||||||
|
|
||||||
|
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
||||||
|
|
||||||
|
// Title
|
||||||
|
guiControl.drawPixelText("Map", guiControl.leftBorder + pixel(10), guiControl.topOfBackground, 8, "black", 6);
|
||||||
|
|
||||||
|
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||||
|
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||||
|
|
||||||
|
var saveFillStyle = OS.context.fillStyle;
|
||||||
|
|
||||||
|
var mapLeft = guiControl.leftBorder - pixel(5);
|
||||||
|
var mapTop = guiControl.upperBorder;
|
||||||
|
|
||||||
|
OS.context.fillStyle = "#0000CC";
|
||||||
|
OS.context.fillRect(mapLeft, mapTop, pixel(50), pixel(45));
|
||||||
|
|
||||||
|
OS.context.fillStyle = "#00FF00";
|
||||||
|
for (var m = 0; m < G.map.length; m++) {
|
||||||
|
var pixelLeft = mapLeft + pixel(G.map[m].drawX);
|
||||||
|
var pixelTop = mapTop + pixel(G.map[m].drawY);
|
||||||
|
OS.context.fillRect(pixelLeft, pixelTop, pixel(), pixel());
|
||||||
|
}
|
||||||
|
|
||||||
|
OS.context.fillStyle = "#FF0000";
|
||||||
|
OS.context.fillRect(mapLeft + G.player.mapX, mapTop + G.player.mapY, pixel(), pixel());
|
||||||
|
|
||||||
|
OS.context.fillStyle = saveFillStyle;
|
||||||
|
|
||||||
|
// Button Action
|
||||||
|
if (guiControl.map.activateDelay <= 0) {
|
||||||
|
if (ct_cancel().down) {
|
||||||
|
guiControl.map.show = false;
|
||||||
|
}
|
||||||
|
if (ct_left().down) {
|
||||||
|
guiControl.map.show = false;
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
guiControl.inventory.show = true;
|
||||||
|
}
|
||||||
|
if (ct_right().down) {
|
||||||
|
guiControl.map.show = false;
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
|
guiControl.inventory.show = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
225
gui/tradeGUI.js
225
gui/tradeGUI.js
|
@ -8,7 +8,6 @@ function tradeGUI() {
|
||||||
activateDelay: 0,
|
activateDelay: 0,
|
||||||
|
|
||||||
island: null,
|
island: null,
|
||||||
haggleAmount: 0,
|
|
||||||
|
|
||||||
padding: pixel(2),
|
padding: pixel(2),
|
||||||
leftBorder: pixel(12),
|
leftBorder: pixel(12),
|
||||||
|
@ -82,36 +81,44 @@ function drawTradeGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition));
|
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (guiControl.trade.activateDelay <= 0 && ct_confirm().down) {
|
if (guiControl.trade.activateDelay <= 0) {
|
||||||
switch (guiControl.trade.cursorPosition) {
|
if (ct_confirm().down) {
|
||||||
case 0:
|
switch (guiControl.trade.cursorPosition) {
|
||||||
if (guiControl.trade.island.CheckInventory().length > 0) {
|
case 0:
|
||||||
guiControl.trade.screen = "buy";
|
if (guiControl.trade.island.CheckInventory().length > 0) {
|
||||||
}
|
guiControl.trade.screen = "buy";
|
||||||
else {
|
guiControl.trade.activateDelay = 5;
|
||||||
// Play Cannot_Buy sound.
|
}
|
||||||
}
|
else {
|
||||||
break;
|
// Play Cannot_Buy sound.
|
||||||
case 1:
|
}
|
||||||
if (G.inventory.CheckCargo().length > 0) {
|
break;
|
||||||
guiControl.trade.screen = "sell";
|
case 1:
|
||||||
} else {
|
if (G.inventory.CheckCargo().length > 0) {
|
||||||
// Play Cannot_Buy sound.
|
guiControl.trade.screen = "sell";
|
||||||
}
|
guiControl.trade.activateDelay = 5;
|
||||||
break;
|
} else {
|
||||||
case 2:
|
// Play Cannot_Buy sound.
|
||||||
guiControl.trade.screen = "gossip";
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case 2:
|
||||||
// Change music to Sail.
|
guiControl.trade.screen = "gossip";
|
||||||
guiControl.trade.show = false;
|
guiControl.trade.activateDelay = 5;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
// Change music to Sail.
|
||||||
|
guiControl.trade.show = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Play Select sound.
|
// Play Select sound.
|
||||||
guiControl.trade.cursorPosition = 0;
|
guiControl.trade.cursorPosition = 0;
|
||||||
guiControl.trade.page = 0;
|
guiControl.trade.page = 0;
|
||||||
// console.log(guiControl.trade.screen);
|
// console.log(guiControl.trade.screen);
|
||||||
|
}
|
||||||
|
if (ct_cancel().down) {
|
||||||
|
guiControl.trade.show = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.trade.screen == "buy") {
|
else if (guiControl.trade.screen == "buy") {
|
||||||
|
@ -143,7 +150,7 @@ function drawTradeGUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]] - guiControl.trade.haggleAmount;
|
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]] - guiControl.trade.island.haggleAmount;
|
||||||
if (itemPrice < 1) itemPrice = 1;
|
if (itemPrice < 1) itemPrice = 1;
|
||||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||||
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5));
|
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5));
|
||||||
|
@ -166,7 +173,7 @@ function drawTradeGUI() {
|
||||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length < G.stats.inventory) ? "black" : "yellow", 6);
|
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length < G.stats.inventory) ? "black" : "yellow", 6);
|
||||||
|
|
||||||
// Yes/No Options
|
// Yes/No Options
|
||||||
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (items.length > 0 && guiControl.trade.haggleAmount == 0) ? "black" : "white", 6);
|
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||||
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) ? "black" : "white", 6);
|
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) ? "black" : "white", 6);
|
||||||
|
|
||||||
// Back Text
|
// Back Text
|
||||||
|
@ -176,39 +183,43 @@ function drawTradeGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down) {
|
if (guiControl.trade.activateDelay <= 0) {
|
||||||
switch (guiControl.trade.cursorPosition) {
|
if (ct_confirm().down) {
|
||||||
case 0: // Haggle
|
switch (guiControl.trade.cursorPosition) {
|
||||||
if (items.length > 0 &&
|
case 0: // Haggle
|
||||||
guiControl.trade.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.
|
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.
|
||||||
guiControl.trade.haggleAmount = G.stats.haggling;
|
{
|
||||||
// Play Sell sound.
|
guiControl.trade.island.haggleAmount = G.stats.haggling;
|
||||||
} else {
|
// Play Sell sound.
|
||||||
// Play Cannot_Buy sound.
|
} else {
|
||||||
}
|
// Play Cannot_Buy sound.
|
||||||
break;
|
guiControl.trade.island.timesHaggledToday++;
|
||||||
case 1: // Buy
|
}
|
||||||
if (items.length > 0 &&
|
break;
|
||||||
G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) { //If cursor is over yes and you can buy, buy it.
|
case 1: // Buy
|
||||||
guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice);
|
if (items.length > 0 &&
|
||||||
} else {
|
G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) { //If cursor is over yes and you can buy, buy it.
|
||||||
// Play Cannot_Buy sound.
|
guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice);
|
||||||
}
|
} else {
|
||||||
break;
|
// Play Cannot_Buy sound.
|
||||||
default:
|
}
|
||||||
guiControl.trade.screen = "main";
|
break;
|
||||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
default:
|
||||||
break;
|
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) {
|
||||||
|
guiControl.trade.screen = "main";
|
||||||
|
guiControl.trade.activateDelay = 5;
|
||||||
|
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
||||||
|
// console.log(guiControl.trade.screen);
|
||||||
}
|
}
|
||||||
// Play Select sound.
|
|
||||||
// console.log(guiControl.trade.screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ct_cancel().down) {
|
|
||||||
guiControl.trade.screen = "main";
|
|
||||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
|
||||||
// console.log(guiControl.trade.screen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.trade.screen == "sell") {
|
else if (guiControl.trade.screen == "sell") {
|
||||||
|
@ -241,7 +252,7 @@ function drawTradeGUI() {
|
||||||
|
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]];
|
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]];
|
||||||
var priceCut = 0.5 + ((guiControl.trade.haggleAmount == 0) ? 0 : (G.stats.popularity * 0.01 * 0.5)); // If haggled successfully, lessen the price cut by half of your popularity's percent worth.
|
var priceCut = 0.5 + ((guiControl.trade.island.haggleAmount == 0) ? 0 : (G.stats.popularity * 0.01 * 0.5)); // If haggled successfully, lessen the price cut by half of your popularity's percent worth.
|
||||||
itemPrice = Math.round(itemPrice * priceCut);
|
itemPrice = Math.round(itemPrice * priceCut);
|
||||||
if (itemPrice < 1) itemPrice = 1;
|
if (itemPrice < 1) itemPrice = 1;
|
||||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||||
|
@ -265,7 +276,7 @@ function drawTradeGUI() {
|
||||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length > 0) ? "black" : "yellow", 6);
|
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length > 0) ? "black" : "yellow", 6);
|
||||||
|
|
||||||
// Yes/No Options
|
// Yes/No Options
|
||||||
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (items.length > 0 && guiControl.trade.haggleAmount == 0) ? "black" : "white", 6);
|
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||||
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanSell(items[guiControl.trade.page])) ? "black" : "white", 6);
|
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanSell(items[guiControl.trade.page])) ? "black" : "white", 6);
|
||||||
|
|
||||||
// Back Text
|
// Back Text
|
||||||
|
@ -275,40 +286,44 @@ function drawTradeGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down) {
|
if (guiControl.trade.activateDelay <= 0) {
|
||||||
switch (guiControl.trade.cursorPosition) {
|
if (ct_confirm().down) {
|
||||||
case 0: // Haggle
|
switch (guiControl.trade.cursorPosition) {
|
||||||
if (items.length > 0 &&
|
case 0: // Haggle
|
||||||
guiControl.trade.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.
|
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.
|
||||||
guiControl.trade.haggleAmount = G.stats.haggling;
|
{
|
||||||
// Play Sell sound.
|
// Play Sell sound.
|
||||||
} else {
|
guiControl.trade.island.haggleAmount = G.stats.haggling;
|
||||||
// Play Cannot_Buy sound.
|
} else {
|
||||||
}
|
// Play Cannot_Buy sound.
|
||||||
break;
|
guiControl.trade.island.timesHaggledToday++;
|
||||||
case 1: // Sell
|
}
|
||||||
if (items.length > 0 &&
|
break;
|
||||||
G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it.
|
case 1: // Sell
|
||||||
{
|
if (items.length > 0 &&
|
||||||
guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice);
|
G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it.
|
||||||
} else {
|
{
|
||||||
// Play Cannot_Buy sound.
|
guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice);
|
||||||
}
|
} else {
|
||||||
break;
|
// Play Cannot_Buy sound.
|
||||||
default:
|
}
|
||||||
guiControl.trade.screen = "main";
|
break;
|
||||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
default:
|
||||||
break;
|
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) {
|
||||||
|
guiControl.trade.screen = "main";
|
||||||
|
guiControl.trade.activateDelay = 5;
|
||||||
|
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
||||||
|
// console.log(guiControl.trade.screen);
|
||||||
}
|
}
|
||||||
// Play Select sound.
|
|
||||||
// console.log(guiControl.trade.screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ct_cancel().down) {
|
|
||||||
guiControl.trade.screen = "main";
|
|
||||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
|
||||||
// console.log(guiControl.trade.screen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (guiControl.trade.screen == "gossip") {
|
else if (guiControl.trade.screen == "gossip") {
|
||||||
|
@ -333,11 +348,13 @@ function drawTradeGUI() {
|
||||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(3));
|
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(3));
|
||||||
|
|
||||||
// Button Action
|
// Button Action
|
||||||
if (ct_confirm().down || ct_cancel().down) {
|
if (guiControl.trade.activateDelay <= 0) {
|
||||||
guiControl.trade.screen = "main";
|
if (ct_confirm().down || ct_cancel().down) {
|
||||||
guiControl.trade.cursorPosition = 2;
|
// Play Select sound.
|
||||||
// Play Select sound.
|
guiControl.trade.screen = "main";
|
||||||
// console.log(guiControl.trade.screen);
|
guiControl.trade.activateDelay = 5;
|
||||||
|
guiControl.trade.cursorPosition = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
function loadGUIs() {
|
function loadGUIs() {
|
||||||
OS.AddScript("gui/inventoryGUI.js");
|
OS.AddScript("gui/inventoryGUI.js");
|
||||||
|
OS.AddScript("gui/mapGUI.js");
|
||||||
OS.AddScript("gui/tradeGUI.js");
|
OS.AddScript("gui/tradeGUI.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// var rm_TitleScreen = OS.R.Add("Default");
|
// var rm_TitleScreen = OS.R.Add("Default");
|
||||||
// var rm_Ocean = OS.R.Add("Ocean", {
|
// var rm_Ocean = OS.R.Add("Ocean", {
|
||||||
var rm_Ocean = OS.R.Add("Default", {
|
var rm_Ocean = OS.R.Add("Default", {
|
||||||
width: pixel(64) * 50, //50x50 map of 64x64 squares. This will allow a single pixel on the map to represent a 64x square and fit comfortably on screen.
|
width: pixel(64) * 50, //50x45 map of 64x64 squares. This will allow a single pixel on the map to represent a 64x square and fit comfortably on screen.
|
||||||
height: pixel(64) * 50,
|
height: pixel(64) * 44,
|
||||||
backgroundColor: "#1b2632"
|
backgroundColor: "#1b2632"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ var pr_island = OS.P.Add("Island", {
|
||||||
mapColor: "#00AB00",
|
mapColor: "#00AB00",
|
||||||
|
|
||||||
canTrade: true,
|
canTrade: true,
|
||||||
|
haggleAmount: 0,
|
||||||
|
timesHaggledToday: 0,
|
||||||
|
|
||||||
inventory: [0, 0, 0, 0,
|
inventory: [0, 0, 0, 0,
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
|
|
|
@ -26,9 +26,13 @@ var pr_ship = OS.P.Add("Ship", {
|
||||||
energyRefillTimer: 0
|
energyRefillTimer: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
pr_ship.BeforeDo = function () {
|
||||||
|
this.GetMapPosition();
|
||||||
|
}
|
||||||
|
|
||||||
pr_ship.Do = function () {
|
pr_ship.Do = function () {
|
||||||
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
if (guiControl && guiControl.inventory && guiControl.map && guiControl.trade) { // Force it to wait until loaded.
|
||||||
if (!guiControl.inventory.show && !guiControl.trade.show) {
|
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||||
if (ct_left().down) {
|
if (ct_left().down) {
|
||||||
this.direction += 45;
|
this.direction += 45;
|
||||||
} else if (ct_right().down) {
|
} else if (ct_right().down) {
|
||||||
|
@ -67,6 +71,12 @@ pr_ship.AfterDo = function () {
|
||||||
this.UpdateEnergy();
|
this.UpdateEnergy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pr_ship.GetMapPosition = function () {
|
||||||
|
this.mapX = pixel(Math.round(this.x / pixel(64)));
|
||||||
|
this.mapY = pixel(Math.round(this.y / pixel(64)));
|
||||||
|
console.log(this.mapX + ", " + this.mapY);
|
||||||
|
}
|
||||||
|
|
||||||
pr_ship.CheckInteraction = function () {
|
pr_ship.CheckInteraction = function () {
|
||||||
if (ct_confirm().down) {
|
if (ct_confirm().down) {
|
||||||
var objectsFound = OS.GameObjectsAtPoint(this.pointInFront.x, this.pointInFront.y);
|
var objectsFound = OS.GameObjectsAtPoint(this.pointInFront.x, this.pointInFront.y);
|
||||||
|
|
|
@ -22,7 +22,7 @@ rm_Ocean.clockImg.src = "images/clock_sheet.png";
|
||||||
|
|
||||||
rm_Ocean.DoFirst = function () {
|
rm_Ocean.DoFirst = function () {
|
||||||
G.player.x = (pixel(64) * 25) - pixel(32) - G.player.xBound;
|
G.player.x = (pixel(64) * 25) - pixel(32) - G.player.xBound;
|
||||||
G.player.y = pixel(64) * 25;
|
G.player.y = pixel(64) * 22;
|
||||||
console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
||||||
|
|
||||||
G.oceanParticle.x = G.player.x + randomSmidge();
|
G.oceanParticle.x = G.player.x + randomSmidge();
|
||||||
|
@ -60,14 +60,11 @@ rm_Ocean.Do = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
||||||
if (!guiControl.inventory.show && !guiControl.trade.show) {
|
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||||
if (ct_cancel().down) {
|
if (ct_cancel().down) {
|
||||||
|
guiControl.inventory.activateDelay = 5;
|
||||||
guiControl.inventory.show = true;
|
guiControl.inventory.show = true;
|
||||||
}
|
}
|
||||||
if (ct_esc.down) {
|
|
||||||
guiControl.trade.show = true;
|
|
||||||
G.player.speed = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +110,8 @@ rm_Ocean.DrawClock = function () {
|
||||||
G.economy.UpdateEconomy();
|
G.economy.UpdateEconomy();
|
||||||
|
|
||||||
for (var i = 0; i < G.map.length; i++) {
|
for (var i = 0; i < G.map.length; i++) {
|
||||||
|
G.map[i].island.haggleAmount = 0;
|
||||||
|
G.map[i].island.timesHaggledToday = 0;
|
||||||
G.map[i].island.SimulateTrade();
|
G.map[i].island.SimulateTrade();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,21 +128,21 @@ rm_Ocean.DrawClock = function () {
|
||||||
rm_Ocean.GenerateMap = function () {
|
rm_Ocean.GenerateMap = function () {
|
||||||
var island1 = rm_Ocean.AddObject(OS.P["Island"], {
|
var island1 = rm_Ocean.AddObject(OS.P["Island"], {
|
||||||
x: pixel(64) * 25, //Exact center of map.
|
x: pixel(64) * 25, //Exact center of map.
|
||||||
y: pixel(64) * 25
|
y: pixel(64) * 22
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(island1.name + " created at " + island1.x + ", " + island1.y);
|
console.log(island1.name + " created at " + island1.x + ", " + island1.y);
|
||||||
G.map.push({
|
G.map.push({
|
||||||
island: island1,
|
island: island1,
|
||||||
drawX: 25,
|
drawX: 25,
|
||||||
drawY: 25,
|
drawY: 22,
|
||||||
drawWidth: 1,
|
drawWidth: 1,
|
||||||
drawHeight: 1
|
drawHeight: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
var usedXSquares = [];
|
var usedXSquares = [];
|
||||||
var usedYSquares = [];
|
var usedYSquares = [];
|
||||||
for (var i = 0; i < 5; i++) {
|
for (var i = 0; i < 9; i++) {
|
||||||
var xSquare = Math.round(Math.randomRange(1, 49));
|
var xSquare = Math.round(Math.randomRange(1, 49));
|
||||||
while (usedXSquares.indexOf(xSquare) != -1 &&
|
while (usedXSquares.indexOf(xSquare) != -1 &&
|
||||||
usedXSquares.indexOf(xSquare + 1) != -1 && usedXSquares.indexOf(xSquare - 1) != -1 &&
|
usedXSquares.indexOf(xSquare + 1) != -1 && usedXSquares.indexOf(xSquare - 1) != -1 &&
|
||||||
|
@ -153,7 +152,7 @@ rm_Ocean.GenerateMap = function () {
|
||||||
}
|
}
|
||||||
usedXSquares.push(xSquare);
|
usedXSquares.push(xSquare);
|
||||||
|
|
||||||
var ySquare = Math.round(Math.randomRange(1, 49));
|
var ySquare = Math.round(Math.randomRange(1, 43));
|
||||||
while (usedYSquares.indexOf(ySquare) != -1 &&
|
while (usedYSquares.indexOf(ySquare) != -1 &&
|
||||||
usedYSquares.indexOf(ySquare + 1) != -1 && usedYSquares.indexOf(ySquare - 1) != -1 &&
|
usedYSquares.indexOf(ySquare + 1) != -1 && usedYSquares.indexOf(ySquare - 1) != -1 &&
|
||||||
usedYSquares.indexOf(ySquare + 2) != -1 && usedYSquares.indexOf(ySquare - 2) != -1)
|
usedYSquares.indexOf(ySquare + 2) != -1 && usedYSquares.indexOf(ySquare - 2) != -1)
|
||||||
|
|
2
start.js
2
start.js
|
@ -1,5 +1,5 @@
|
||||||
OS.S.defaultStep = 1 / 120;
|
OS.S.defaultStep = 1 / 120;
|
||||||
OS.S.numberOfScriptsToLoad = 13; // Excludes the titleScreen.js room, which is not loaded yet.
|
OS.S.numberOfScriptsToLoad = 14; // Excludes the titleScreen.js room, which is not loaded yet.
|
||||||
OS.S.pixelScale = 4;
|
OS.S.pixelScale = 4;
|
||||||
OS.SetCamera({
|
OS.SetCamera({
|
||||||
width: pixel(64),
|
width: pixel(64),
|
||||||
|
|
Loading…
Reference in New Issue