Added checks to make sure objects exist before trying to reference them.
This commit is contained in:
parent
5224f69de2
commit
f8e2fa3cb9
|
@ -7,7 +7,7 @@ function inventoryGUI() {
|
|||
}
|
||||
|
||||
function drawInventoryGUI() {
|
||||
if (guiControl.inventory.show) {
|
||||
if (guiControl.inventory && guiControl.inventory.show) {
|
||||
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
||||
|
||||
if (ct_down().down) {
|
||||
|
|
|
@ -20,8 +20,10 @@ function tradeGUI() {
|
|||
}
|
||||
|
||||
function drawTradeGUI() {
|
||||
if (guiControl.trade.show) {
|
||||
if (guiControl.trade && guiControl.trade.show) {
|
||||
guiControl.trade.activateDelay -= (guiControl.trade.activateDelay > 0) ? 1 : 0;
|
||||
// console.log("trade screen island: " + guiControl.trade.island.name);
|
||||
// Draw background color.
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
Oversimplified.context.fillStyle = "#D9BEA5";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
|
|
|
@ -27,22 +27,24 @@ var pr_ship = OS.P.Add("Ship", {
|
|||
});
|
||||
|
||||
pr_ship.Do = function () {
|
||||
if (!guiControl.inventory.show && !guiControl.trade.show) {
|
||||
if (ct_left().down) {
|
||||
this.direction += 45;
|
||||
} else if (ct_right().down) {
|
||||
this.direction -= 45;
|
||||
}
|
||||
this.direction = Math.clampAngle(this.direction);
|
||||
|
||||
if (ct_up().down) {
|
||||
this.currentSpeed++;
|
||||
} else if (ct_down().down) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
this.AdjustSpeedBasedOnEnergy();
|
||||
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
||||
if (!guiControl.inventory.show && !guiControl.trade.show) {
|
||||
if (ct_left().down) {
|
||||
this.direction += 45;
|
||||
} else if (ct_right().down) {
|
||||
this.direction -= 45;
|
||||
}
|
||||
this.direction = Math.clampAngle(this.direction);
|
||||
|
||||
if (ct_up().down) {
|
||||
this.currentSpeed++;
|
||||
} else if (ct_down().down) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
this.AdjustSpeedBasedOnEnergy();
|
||||
|
||||
this.CheckInteraction();
|
||||
this.CheckInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
this.currentSpeed = Math.clamp(this.currentSpeed, 0, 4);
|
||||
|
@ -71,6 +73,7 @@ pr_ship.CheckInteraction = function () {
|
|||
if (objectsFound.length > 0) {
|
||||
for (var i = 0; i < objectsFound.length; i++) {
|
||||
if (objectsFound[i].canTrade) {
|
||||
// console.log("interacting with island: " + objectsFound[i].name);
|
||||
objectsFound[i].TradeWith();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ rm_Ocean.DoFirst = function () {
|
|||
}
|
||||
rm_Ocean.Do = function () {
|
||||
// Move G.oceanParticle around based on player's movement.
|
||||
G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction);
|
||||
if (G.oceanParticle.CheckPosition) G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction);
|
||||
|
||||
this.waveTimer--;
|
||||
if (this.waveTimer <= 0) {
|
||||
|
@ -50,13 +50,15 @@ rm_Ocean.Do = function () {
|
|||
this.waveTimer = Math.round(Math.randomRange(30, 150));
|
||||
}
|
||||
|
||||
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;
|
||||
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue