/**** 
* Plugins
****/ 
var storage = LK.import("@upit/storage.v1", {
	moneyMultiplier: 1
});
/**** 
* Classes
****/ 
// Fish class representing different types of fish
var Fish = Container.expand(function (type) {
	var self = Container.call(this);
	// Attach a fish asset with random color
	var fishGraphics = self.attachAsset('Fish' + type, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set base speed and money value for each fish type
	var baseSpeed;
	var moneyValue;
	switch (type) {
		case 1:
			baseSpeed = 1.5;
			moneyValue = 2;
			break;
		case 2:
			baseSpeed = 10;
			moneyValue = 25;
			break;
		case 3:
			baseSpeed = 2;
			moneyValue = 5;
			break;
		case 4:
			baseSpeed = 3;
			moneyValue = 8;
			break;
		case 5:
			baseSpeed = 3;
			moneyValue = 8;
			break;
		case 6:
			baseSpeed = 5;
			moneyValue = 25;
			break;
		case 7:
			baseSpeed = 2;
			moneyValue = 3;
			break;
		case 8:
			baseSpeed = 8;
			moneyValue = 30;
			break;
		case 9:
			baseSpeed = 3;
			moneyValue = 4;
			break;
		case 10:
			baseSpeed = 25;
			moneyValue = 2500;
			break;
		default:
			baseSpeed = 2;
			moneyValue = 2;
	}
	self.moneyValue = moneyValue;
	// Adjust the base speed randomly by 10% for all fish except Fish1 which can have a speed change from the base of 50%
	if (type === 1) {
		self.speed = baseSpeed * (1 + (Math.random() - 0.5));
	} else {
		self.speed = baseSpeed * (1 + (Math.random() - 0.5) / 5);
	}
	// Update function to move fish
	self.update = function () {
		self.x += self.speed;
		if (self.x > 2048) {
			self.x = -100; // Reset position if fish goes off screen
		}
		if (type === 5) {
			self.y = Math.max(self.y, shop.y + shop.height + 10); // Ensure fish5 is always below the shopgui asset
		}
	};
});
// FishingRod class representing the player's fishing rod
var FishingRod = Container.expand(function () {
	var self = Container.call(this);
	// Attach a fishing rod asset
	var rodGraphics = self.attachAsset('net', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set initial position
	self.x = 1024;
	self.y = 2000;
	// Event handler for dragging the rod
	self.down = function (x, y, obj) {
		if (self.intersects(shop)) {
			var updateUnlockMoreText = function updateUnlockMoreText() {
				var upgradesNeeded = 5 - Math.floor((moneyMultiplier - 1) * 10);
				if (moneyMultiplier >= 1.1 && moneyMultiplier < 1.2) {
					upgradesNeeded = 4;
				} else if (moneyMultiplier >= 1.2 && moneyMultiplier < 1.3) {
					upgradesNeeded = 3;
				} else if (moneyMultiplier >= 1.3 && moneyMultiplier < 1.4) {
					upgradesNeeded = 2;
				} else if (moneyMultiplier >= 1.4 && moneyMultiplier < 1.5) {
					upgradesNeeded = 1;
				} else if (moneyMultiplier >= 1.5) {
					upgradesNeeded = 0;
				}
				if (upgradesNeeded > 0) {
					unlockMoreText.setText('Unlock More With ' + upgradesNeeded + ' More Upgrades!');
					upgradeFishermen.visible = false; // Hide upgradeFishermen button
					upgradeCostTextFishermen.visible = false; // Hide the upgrade cost text for fishermen
					currentMultiplierTextFishermen.visible = false; // Hide the current multiplier text for fishermen
				} else {
					unlockMoreText.setText('Fishermen');
					if (moneyMultiplier >= 1.5) {
						upgradeFishermen.down = function (x, y, obj) {
							if (score >= fishermenCost) {
								score -= fishermenCost;
								fishermenCount += 1;
								fishermenCost += 1000;
								storage.fishermenCount = fishermenCount;
								storage.fishermenCost = fishermenCost;
								storage.moneyTotal = score;
								currentMultiplierTextFishermen.setText('Current: ' + fishermenCount);
								upgradeCostTextFishermen.setText('Cost: ' + fishermenCost / 1000 + 'k');
								if (score >= 1000000) {
									var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
									scoreTxt.setText('$' + abbreviatedScore);
								} else if (score >= 1000) {
									var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
									scoreTxt.setText('$' + abbreviatedScore);
								} else {
									scoreTxt.setText('$' + score.toFixed(2));
								}
							}
						};
						upgradeFishermen.visible = true; // Show upgradeFishermen button
						upgradeCostTextFishermen.setText('Cost: ' + (storage.fishermenCost || 1000) / 1000 + 'k'); // Load and display the fishermen cost
						currentMultiplierTextFishermen.setText('Current: ' + (storage.fishermenCount || 0)); // Load and display the current fishermen count
						upgradeCostTextFishermen.visible = true; // Show the upgrade cost text for fishermen
						currentMultiplierTextFishermen.visible = true; // Show the current multiplier text for fishermen
					} else {
						upgradeFishermen.visible = false; // Hide upgradeFishermen button
					}
				}
			};
			// Create a ShopGUI1 asset and make it visible when the shop button is clicked
			var shopGUI = game.addChild(LK.getAsset('ShopGUI1', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 1024,
				y: 1366
			}));
			shopGUI.visible = false;
			// Create a ShopGuiClose asset and make it visible when the shop button is clicked
			var shopGuiClose = game.addChild(LK.getAsset('ShopGuiClose', {
				anchorX: 1.0,
				// Anchor to the top right
				anchorY: 0.0,
				// Anchor to the top right
				x: 1024 + 825 - 25,
				// Position it 25 pixels from the right within the shopgui
				y: 50 // Position it 50 pixels below the top of the ShopGUI1
			}));
			shopGuiClose.visible = false;
			shopGuiClose.down = function (x, y, obj) {
				shopGUI.visible = false;
				shopGuiClose.visible = false;
				moneyMultiplierText.visible = false; // Hide the Money Multiplier text
				moneyUpgrade.visible = false; // Hide the moneyUpgrade asset 
				upgradeFishermen.visible = false; // Hide the upgradeFishermen button
				upgradeCostText.visible = false; // Hide the upgrade cost text
				currentMultiplierText.visible = false; // Hide the current multiplier text
				comingSoonText.visible = false; // Hide the 'Coming Soon!' text
				upgradeCostTextFishermen.visible = false; // Hide the upgrade cost text for fishermen
				currentMultiplierTextFishermen.visible = false; // Hide the current multiplier text for fishermen
				scoreTxt.setStyle({
					stroke: 0xFFFFFF,
					strokeThickness: 5 // Restore white stroke when shopgui is closed
				});
				self.visible = true; // Make the fishingnet visible again when the shopgui is closed
			};
			shopGUI.visible = true;
			// Add "Money Multiplier" text to the shopgui
			var moneyMultiplierText = new Text2('Money Multiplier', {
				size: 100,
				fill: 0x000000
			});
			moneyMultiplierText.anchor.set(0.5, 0);
			moneyMultiplierText.x = 1024; // Centered horizontally within the shopgui
			moneyMultiplierText.y = 1366 - 1250 + 100; // Offset by 100 pixels from the Y position of the shopgui
			game.addChild(moneyMultiplierText);
			scoreTxt.setStyle({
				stroke: 0x000000,
				// Add black stroke
				strokeThickness: 10 // Set stroke thickness to 10
			});
			shopGuiClose.visible = true;
			// Add a new asset 'moneyUpgrade' 25 pixels below the Money Multiplier text
			var moneyUpgrade = LK.getAsset('fishingRod', {
				anchorX: 0.5,
				anchorY: 0.0,
				x: 1024,
				// Centered horizontally within the shopgui
				y: moneyMultiplierText.y + 150 // 150 pixels below the Money Multiplier text
			});
			game.addChild(moneyUpgrade);
			// Add text to display current money multiplier
			var currentMultiplierText = new Text2('Current: ' + moneyMultiplier.toFixed(1) + 'x', {
				size: 80,
				fill: 0x000000
			});
			currentMultiplierText.anchor.set(0.5, 0);
			currentMultiplierText.x = moneyUpgrade.x - 550; // 550 pixels to the left of moneyUpgrade
			currentMultiplierText.y = moneyUpgrade.y;
			game.addChild(currentMultiplierText);
			currentMultiplierText.visible = true; // Show the current multiplier text
			var upgradeCost = storage.upgradeCost || 250; // Initialize upgrade cost from storage or set to starting value
			// Add text to display the cost of the money multiplier upgrade
			var upgradeCostText = new Text2('Cost: $' + upgradeCost.toFixed(2), {
				size: 80,
				fill: 0x000000
			});
			if (upgradeCost >= 1000000) {
				var abbreviatedCost = (upgradeCost / 1000000).toFixed(2) + 'm';
				upgradeCostText.setText('Cost: $' + abbreviatedCost);
			} else if (upgradeCost >= 1000) {
				var abbreviatedCost = (upgradeCost / 1000).toFixed(2) + 'k';
				upgradeCostText.setText('Cost: $' + abbreviatedCost);
			} else {
				upgradeCostText.setText('Cost: $' + upgradeCost.toFixed(2));
			}
			upgradeCostText.anchor.set(0.5, 0);
			upgradeCostText.x = moneyUpgrade.x + 500; // 500 pixels to the right of moneyUpgrade
			upgradeCostText.y = moneyUpgrade.y;
			game.addChild(upgradeCostText);
			// Add "Unlock More With 5 More Upgrades!" text 150 pixels below the money multiplier button 
			var unlockMoreText = new Text2('', {
				size: 100,
				// Same size as "Money Multiplier" text 
				fill: 0x000000
			});
			unlockMoreText.anchor.set(0.5, 0);
			unlockMoreText.x = 1024; // Centered horizontally within the shopgui 
			unlockMoreText.y = moneyUpgrade.y + 150; // 150 pixels below the moneyUpgrade button 
			game.addChild(unlockMoreText);
			unlockMoreText.visible = true; // Show the text 
			// Define comingSoonText to avoid ReferenceError 
			var comingSoonText = unlockMoreText;
			// Add a new asset 'upgradeFishermen' 50 pixels below the Fishermen text
			var upgradeFishermen = LK.getAsset('fishingRod', {
				anchorX: 0.5,
				anchorY: 0.0,
				x: 1024,
				// Centered horizontally within the shopgui
				y: unlockMoreText.y + 150 // 150 pixels below the unlockMoreText
			});
			game.addChild(upgradeFishermen);
			// Add text 'Cost: 1k' 550 pixels to the right of the middle of the upgradeFishermen
			var upgradeCostTextFishermen = new Text2('Cost: 1k', {
				size: 80,
				fill: 0x000000
			});
			upgradeCostTextFishermen.anchor.set(0.5, 0);
			upgradeCostTextFishermen.x = upgradeFishermen.x + 550;
			upgradeCostTextFishermen.y = upgradeFishermen.y;
			game.addChild(upgradeCostTextFishermen);
			upgradeCostTextFishermen.visible = false; // Initially hidden
			// Add text 'Current: 0' 550 pixels to the left of the middle of the upgradeFishermen
			var currentMultiplierTextFishermen = new Text2('Current: 0', {
				size: 80,
				fill: 0x000000
			});
			currentMultiplierTextFishermen.anchor.set(0.5, 0);
			currentMultiplierTextFishermen.x = upgradeFishermen.x - 550;
			currentMultiplierTextFishermen.y = upgradeFishermen.y;
			game.addChild(currentMultiplierTextFishermen);
			currentMultiplierTextFishermen.visible = false; // Initially hidden
			// Update the unlockMoreText based on the current money multiplier 
			updateUnlockMoreText();
			moneyUpgrade.down = function (x, y, obj) {
				if (score >= upgradeCost) {
					// Check if the player has enough money
					score -= upgradeCost; // Deduct the cost from the player's score
					moneyMultiplier += 0.1; // Increase multiplier by 0.1x
					currentMultiplierText.setText('Current: ' + moneyMultiplier.toFixed(1) + 'x'); // Update text
					storage.moneyMultiplier = moneyMultiplier; // Persist updated multiplier
					updateUnlockMoreText(); // Update unlockMoreText instantly
					if (moneyMultiplier >= 1.7) {
						upgradeCost += 2500 + 1000 * (moneyMultiplier - 1.7) / 0.1; // Increase by 2500 plus 1k for each 0.1x above 1.7x
					} else {
						upgradeCost *= 1.5; // Original cost increase logic
					}
					storage.upgradeCost = upgradeCost; // Persist updated upgrade cost
					if (upgradeCost >= 1000000) {
						var abbreviatedCost = (upgradeCost / 1000000).toFixed(2) + 'm';
						upgradeCostText.setText('Cost: $' + abbreviatedCost);
					} else if (upgradeCost >= 1000) {
						var abbreviatedCost = (upgradeCost / 1000).toFixed(2) + 'k';
						upgradeCostText.setText('Cost: $' + abbreviatedCost);
					} else {
						upgradeCostText.setText('Cost: $' + upgradeCost.toFixed(2));
					}
					// Update the score text immediately
					if (score >= 1000000) {
						// Abbreviate to 'm' if score is 1,000,000 or more
						var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
						scoreTxt.setText('$' + abbreviatedScore);
					} else if (score >= 1000) {
						// Abbreviate to 'k' if score is 1,000 or more
						var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
						scoreTxt.setText('$' + abbreviatedScore);
					} else {
						scoreTxt.setText('$' + score.toFixed(2));
					}
				}
			};
			self.visible = false; // Make the fishingnet invisible when the shopgui is open
		}
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Init game with sky blue background
});
/**** 
* Game Code
****/ 
// Generate money from fishermen every 5 seconds
LK.setInterval(function () {
	score += fishermenCount * 10;
	storage.moneyTotal = score;
	if (score >= 1000000) {
		var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
		scoreTxt.setText('$' + abbreviatedScore);
	} else if (score >= 1000) {
		var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
		scoreTxt.setText('$' + abbreviatedScore);
	} else {
		scoreTxt.setText('$' + score.toFixed(2));
	}
}, 5000);
var bottomGUI = LK.getAsset('bottomGUI', {
	anchorX: 0.5,
	anchorY: 1.0,
	x: 1024,
	y: 2732
});
game.addChild(bottomGUI);
//<Assets used in the game will automatically appear here>
// Initialize arrays and variables
function generateFishType() {
	var rand = Math.random() * 100;
	if (rand < 30) {
		return 1;
	} else if (rand < 32) {
		return 2;
	} else if (rand < 47) {
		return 3;
	} else if (rand < 57) {
		return 4;
	} else if (rand < 67) {
		return 5;
	} else if (rand < 72) {
		return 6;
	} else if (rand < 87) {
		return 7;
	} else if (rand < 89.95) {
		return 8;
	} else if (rand < 99.95) {
		return 9;
	} else {
		return 10;
	}
}
var fishes = [];
var score = storage.moneyTotal || 0;
var fishermenCount = storage.fishermenCount || 0;
var fishermenCost = storage.fishermenCost || 1000;
var moneyMultiplier = storage.moneyMultiplier || 1.0; // Initialize money multiplier from storage
var scoreTxt = new Text2('$0', {
	size: 100,
	fill: 0x00FF00,
	// Green fill
	stroke: 0xFFFFFF,
	// White outline
	strokeThickness: 5 // Thickness of the outline
});
var shop = LK.getAsset('shop', {
	anchorX: 0.5,
	anchorY: 0.0,
	x: 1024,
	y: 200
});
game.addChild(shop);
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create and add fishing rod to the game
var fishingRod = game.addChild(new FishingRod());
// Function to spawn fish
function spawnFish(type) {
	var fish = new Fish(type);
	fish.x = 0; // Spawn fish only at the left side of the screen
	fish.y = Math.random() * 1500 + 500;
	fishes.push(fish);
	game.addChild(fish);
}
// Spawn initial fish
for (var i = 0; i < 10; i++) {
	spawnFish(generateFishType());
}
// Update function for the game
game.update = function () {
	// Update all fish
	var _loop = function _loop() {
			fishes[i].update();
			// Check for collision with fishing rod
			if (fishingRod.intersects(fishes[i])) {
				var _animateMessage = function animateMessage() {
					var elapsedTime = Date.now() - startTime;
					if (elapsedTime < slideUpDuration) {
						var progress = elapsedTime / slideUpDuration;
						caughtFishMessage.y = 2732 - progress * 100; // Slide up 100 pixels
						LK.setTimeout(_animateMessage, 16);
					} else {
						// Keep the message in place for the remaining duration
						LK.setTimeout(function () {
							caughtFishMessage.destroy();
						}, stayDuration);
					}
				};
				score += fishes[i].moneyValue * moneyMultiplier; // Multiply fish value by money multiplier
				storage.moneyTotal = score;
				if (score >= 1000000) {
					// Abbreviate to 'm' if score is 1,000,000 or more
					abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
					scoreTxt.setText('$' + abbreviatedScore);
				} else if (score >= 1000) {
					// Abbreviate to 'k' if score is 1,000 or more
					abbreviatedScore = (score / 1000).toFixed(2) + 'k';
					scoreTxt.setText('$' + abbreviatedScore);
				} else {
					scoreTxt.setText('$' + score.toFixed(2));
				}
				fishes[i].destroy();
				fishes.splice(i, 1);
				spawnFish(generateFishType());
			}
		},
		abbreviatedScore,
		abbreviatedScore,
		caughtFishMessage,
		slideUpDuration,
		stayDuration,
		startTime;
	for (var i = 0; i < fishes.length; i++) {
		_loop();
	}
};
// Event handler for dragging the fishing rod
game.move = function (x, y, obj) {
	fishingRod.x = x;
	fishingRod.y = y;
	if (fishingRod.y <= shop.y + 270) {
		fishingRod.alpha = 0;
	} else {
		fishingRod.alpha = 1;
	}
}; /**** 
* Plugins
****/ 
var storage = LK.import("@upit/storage.v1", {
	moneyMultiplier: 1
});
/**** 
* Classes
****/ 
// Fish class representing different types of fish
var Fish = Container.expand(function (type) {
	var self = Container.call(this);
	// Attach a fish asset with random color
	var fishGraphics = self.attachAsset('Fish' + type, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set base speed and money value for each fish type
	var baseSpeed;
	var moneyValue;
	switch (type) {
		case 1:
			baseSpeed = 1.5;
			moneyValue = 2;
			break;
		case 2:
			baseSpeed = 10;
			moneyValue = 25;
			break;
		case 3:
			baseSpeed = 2;
			moneyValue = 5;
			break;
		case 4:
			baseSpeed = 3;
			moneyValue = 8;
			break;
		case 5:
			baseSpeed = 3;
			moneyValue = 8;
			break;
		case 6:
			baseSpeed = 5;
			moneyValue = 25;
			break;
		case 7:
			baseSpeed = 2;
			moneyValue = 3;
			break;
		case 8:
			baseSpeed = 8;
			moneyValue = 30;
			break;
		case 9:
			baseSpeed = 3;
			moneyValue = 4;
			break;
		case 10:
			baseSpeed = 25;
			moneyValue = 2500;
			break;
		default:
			baseSpeed = 2;
			moneyValue = 2;
	}
	self.moneyValue = moneyValue;
	// Adjust the base speed randomly by 10% for all fish except Fish1 which can have a speed change from the base of 50%
	if (type === 1) {
		self.speed = baseSpeed * (1 + (Math.random() - 0.5));
	} else {
		self.speed = baseSpeed * (1 + (Math.random() - 0.5) / 5);
	}
	// Update function to move fish
	self.update = function () {
		self.x += self.speed;
		if (self.x > 2048) {
			self.x = -100; // Reset position if fish goes off screen
		}
		if (type === 5) {
			self.y = Math.max(self.y, shop.y + shop.height + 10); // Ensure fish5 is always below the shopgui asset
		}
	};
});
// FishingRod class representing the player's fishing rod
var FishingRod = Container.expand(function () {
	var self = Container.call(this);
	// Attach a fishing rod asset
	var rodGraphics = self.attachAsset('net', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Set initial position
	self.x = 1024;
	self.y = 2000;
	// Event handler for dragging the rod
	self.down = function (x, y, obj) {
		if (self.intersects(shop)) {
			var updateUnlockMoreText = function updateUnlockMoreText() {
				var upgradesNeeded = 5 - Math.floor((moneyMultiplier - 1) * 10);
				if (moneyMultiplier >= 1.1 && moneyMultiplier < 1.2) {
					upgradesNeeded = 4;
				} else if (moneyMultiplier >= 1.2 && moneyMultiplier < 1.3) {
					upgradesNeeded = 3;
				} else if (moneyMultiplier >= 1.3 && moneyMultiplier < 1.4) {
					upgradesNeeded = 2;
				} else if (moneyMultiplier >= 1.4 && moneyMultiplier < 1.5) {
					upgradesNeeded = 1;
				} else if (moneyMultiplier >= 1.5) {
					upgradesNeeded = 0;
				}
				if (upgradesNeeded > 0) {
					unlockMoreText.setText('Unlock More With ' + upgradesNeeded + ' More Upgrades!');
					upgradeFishermen.visible = false; // Hide upgradeFishermen button
					upgradeCostTextFishermen.visible = false; // Hide the upgrade cost text for fishermen
					currentMultiplierTextFishermen.visible = false; // Hide the current multiplier text for fishermen
				} else {
					unlockMoreText.setText('Fishermen');
					if (moneyMultiplier >= 1.5) {
						upgradeFishermen.down = function (x, y, obj) {
							if (score >= fishermenCost) {
								score -= fishermenCost;
								fishermenCount += 1;
								fishermenCost += 1000;
								storage.fishermenCount = fishermenCount;
								storage.fishermenCost = fishermenCost;
								storage.moneyTotal = score;
								currentMultiplierTextFishermen.setText('Current: ' + fishermenCount);
								upgradeCostTextFishermen.setText('Cost: ' + fishermenCost / 1000 + 'k');
								if (score >= 1000000) {
									var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
									scoreTxt.setText('$' + abbreviatedScore);
								} else if (score >= 1000) {
									var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
									scoreTxt.setText('$' + abbreviatedScore);
								} else {
									scoreTxt.setText('$' + score.toFixed(2));
								}
							}
						};
						upgradeFishermen.visible = true; // Show upgradeFishermen button
						upgradeCostTextFishermen.setText('Cost: ' + (storage.fishermenCost || 1000) / 1000 + 'k'); // Load and display the fishermen cost
						currentMultiplierTextFishermen.setText('Current: ' + (storage.fishermenCount || 0)); // Load and display the current fishermen count
						upgradeCostTextFishermen.visible = true; // Show the upgrade cost text for fishermen
						currentMultiplierTextFishermen.visible = true; // Show the current multiplier text for fishermen
					} else {
						upgradeFishermen.visible = false; // Hide upgradeFishermen button
					}
				}
			};
			// Create a ShopGUI1 asset and make it visible when the shop button is clicked
			var shopGUI = game.addChild(LK.getAsset('ShopGUI1', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 1024,
				y: 1366
			}));
			shopGUI.visible = false;
			// Create a ShopGuiClose asset and make it visible when the shop button is clicked
			var shopGuiClose = game.addChild(LK.getAsset('ShopGuiClose', {
				anchorX: 1.0,
				// Anchor to the top right
				anchorY: 0.0,
				// Anchor to the top right
				x: 1024 + 825 - 25,
				// Position it 25 pixels from the right within the shopgui
				y: 50 // Position it 50 pixels below the top of the ShopGUI1
			}));
			shopGuiClose.visible = false;
			shopGuiClose.down = function (x, y, obj) {
				shopGUI.visible = false;
				shopGuiClose.visible = false;
				moneyMultiplierText.visible = false; // Hide the Money Multiplier text
				moneyUpgrade.visible = false; // Hide the moneyUpgrade asset 
				upgradeFishermen.visible = false; // Hide the upgradeFishermen button
				upgradeCostText.visible = false; // Hide the upgrade cost text
				currentMultiplierText.visible = false; // Hide the current multiplier text
				comingSoonText.visible = false; // Hide the 'Coming Soon!' text
				upgradeCostTextFishermen.visible = false; // Hide the upgrade cost text for fishermen
				currentMultiplierTextFishermen.visible = false; // Hide the current multiplier text for fishermen
				scoreTxt.setStyle({
					stroke: 0xFFFFFF,
					strokeThickness: 5 // Restore white stroke when shopgui is closed
				});
				self.visible = true; // Make the fishingnet visible again when the shopgui is closed
			};
			shopGUI.visible = true;
			// Add "Money Multiplier" text to the shopgui
			var moneyMultiplierText = new Text2('Money Multiplier', {
				size: 100,
				fill: 0x000000
			});
			moneyMultiplierText.anchor.set(0.5, 0);
			moneyMultiplierText.x = 1024; // Centered horizontally within the shopgui
			moneyMultiplierText.y = 1366 - 1250 + 100; // Offset by 100 pixels from the Y position of the shopgui
			game.addChild(moneyMultiplierText);
			scoreTxt.setStyle({
				stroke: 0x000000,
				// Add black stroke
				strokeThickness: 10 // Set stroke thickness to 10
			});
			shopGuiClose.visible = true;
			// Add a new asset 'moneyUpgrade' 25 pixels below the Money Multiplier text
			var moneyUpgrade = LK.getAsset('fishingRod', {
				anchorX: 0.5,
				anchorY: 0.0,
				x: 1024,
				// Centered horizontally within the shopgui
				y: moneyMultiplierText.y + 150 // 150 pixels below the Money Multiplier text
			});
			game.addChild(moneyUpgrade);
			// Add text to display current money multiplier
			var currentMultiplierText = new Text2('Current: ' + moneyMultiplier.toFixed(1) + 'x', {
				size: 80,
				fill: 0x000000
			});
			currentMultiplierText.anchor.set(0.5, 0);
			currentMultiplierText.x = moneyUpgrade.x - 550; // 550 pixels to the left of moneyUpgrade
			currentMultiplierText.y = moneyUpgrade.y;
			game.addChild(currentMultiplierText);
			currentMultiplierText.visible = true; // Show the current multiplier text
			var upgradeCost = storage.upgradeCost || 250; // Initialize upgrade cost from storage or set to starting value
			// Add text to display the cost of the money multiplier upgrade
			var upgradeCostText = new Text2('Cost: $' + upgradeCost.toFixed(2), {
				size: 80,
				fill: 0x000000
			});
			if (upgradeCost >= 1000000) {
				var abbreviatedCost = (upgradeCost / 1000000).toFixed(2) + 'm';
				upgradeCostText.setText('Cost: $' + abbreviatedCost);
			} else if (upgradeCost >= 1000) {
				var abbreviatedCost = (upgradeCost / 1000).toFixed(2) + 'k';
				upgradeCostText.setText('Cost: $' + abbreviatedCost);
			} else {
				upgradeCostText.setText('Cost: $' + upgradeCost.toFixed(2));
			}
			upgradeCostText.anchor.set(0.5, 0);
			upgradeCostText.x = moneyUpgrade.x + 500; // 500 pixels to the right of moneyUpgrade
			upgradeCostText.y = moneyUpgrade.y;
			game.addChild(upgradeCostText);
			// Add "Unlock More With 5 More Upgrades!" text 150 pixels below the money multiplier button 
			var unlockMoreText = new Text2('', {
				size: 100,
				// Same size as "Money Multiplier" text 
				fill: 0x000000
			});
			unlockMoreText.anchor.set(0.5, 0);
			unlockMoreText.x = 1024; // Centered horizontally within the shopgui 
			unlockMoreText.y = moneyUpgrade.y + 150; // 150 pixels below the moneyUpgrade button 
			game.addChild(unlockMoreText);
			unlockMoreText.visible = true; // Show the text 
			// Define comingSoonText to avoid ReferenceError 
			var comingSoonText = unlockMoreText;
			// Add a new asset 'upgradeFishermen' 50 pixels below the Fishermen text
			var upgradeFishermen = LK.getAsset('fishingRod', {
				anchorX: 0.5,
				anchorY: 0.0,
				x: 1024,
				// Centered horizontally within the shopgui
				y: unlockMoreText.y + 150 // 150 pixels below the unlockMoreText
			});
			game.addChild(upgradeFishermen);
			// Add text 'Cost: 1k' 550 pixels to the right of the middle of the upgradeFishermen
			var upgradeCostTextFishermen = new Text2('Cost: 1k', {
				size: 80,
				fill: 0x000000
			});
			upgradeCostTextFishermen.anchor.set(0.5, 0);
			upgradeCostTextFishermen.x = upgradeFishermen.x + 550;
			upgradeCostTextFishermen.y = upgradeFishermen.y;
			game.addChild(upgradeCostTextFishermen);
			upgradeCostTextFishermen.visible = false; // Initially hidden
			// Add text 'Current: 0' 550 pixels to the left of the middle of the upgradeFishermen
			var currentMultiplierTextFishermen = new Text2('Current: 0', {
				size: 80,
				fill: 0x000000
			});
			currentMultiplierTextFishermen.anchor.set(0.5, 0);
			currentMultiplierTextFishermen.x = upgradeFishermen.x - 550;
			currentMultiplierTextFishermen.y = upgradeFishermen.y;
			game.addChild(currentMultiplierTextFishermen);
			currentMultiplierTextFishermen.visible = false; // Initially hidden
			// Update the unlockMoreText based on the current money multiplier 
			updateUnlockMoreText();
			moneyUpgrade.down = function (x, y, obj) {
				if (score >= upgradeCost) {
					// Check if the player has enough money
					score -= upgradeCost; // Deduct the cost from the player's score
					moneyMultiplier += 0.1; // Increase multiplier by 0.1x
					currentMultiplierText.setText('Current: ' + moneyMultiplier.toFixed(1) + 'x'); // Update text
					storage.moneyMultiplier = moneyMultiplier; // Persist updated multiplier
					updateUnlockMoreText(); // Update unlockMoreText instantly
					if (moneyMultiplier >= 1.7) {
						upgradeCost += 2500 + 1000 * (moneyMultiplier - 1.7) / 0.1; // Increase by 2500 plus 1k for each 0.1x above 1.7x
					} else {
						upgradeCost *= 1.5; // Original cost increase logic
					}
					storage.upgradeCost = upgradeCost; // Persist updated upgrade cost
					if (upgradeCost >= 1000000) {
						var abbreviatedCost = (upgradeCost / 1000000).toFixed(2) + 'm';
						upgradeCostText.setText('Cost: $' + abbreviatedCost);
					} else if (upgradeCost >= 1000) {
						var abbreviatedCost = (upgradeCost / 1000).toFixed(2) + 'k';
						upgradeCostText.setText('Cost: $' + abbreviatedCost);
					} else {
						upgradeCostText.setText('Cost: $' + upgradeCost.toFixed(2));
					}
					// Update the score text immediately
					if (score >= 1000000) {
						// Abbreviate to 'm' if score is 1,000,000 or more
						var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
						scoreTxt.setText('$' + abbreviatedScore);
					} else if (score >= 1000) {
						// Abbreviate to 'k' if score is 1,000 or more
						var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
						scoreTxt.setText('$' + abbreviatedScore);
					} else {
						scoreTxt.setText('$' + score.toFixed(2));
					}
				}
			};
			self.visible = false; // Make the fishingnet invisible when the shopgui is open
		}
	};
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Init game with sky blue background
});
/**** 
* Game Code
****/ 
// Generate money from fishermen every 5 seconds
LK.setInterval(function () {
	score += fishermenCount * 10;
	storage.moneyTotal = score;
	if (score >= 1000000) {
		var abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
		scoreTxt.setText('$' + abbreviatedScore);
	} else if (score >= 1000) {
		var abbreviatedScore = (score / 1000).toFixed(2) + 'k';
		scoreTxt.setText('$' + abbreviatedScore);
	} else {
		scoreTxt.setText('$' + score.toFixed(2));
	}
}, 5000);
var bottomGUI = LK.getAsset('bottomGUI', {
	anchorX: 0.5,
	anchorY: 1.0,
	x: 1024,
	y: 2732
});
game.addChild(bottomGUI);
//<Assets used in the game will automatically appear here>
// Initialize arrays and variables
function generateFishType() {
	var rand = Math.random() * 100;
	if (rand < 30) {
		return 1;
	} else if (rand < 32) {
		return 2;
	} else if (rand < 47) {
		return 3;
	} else if (rand < 57) {
		return 4;
	} else if (rand < 67) {
		return 5;
	} else if (rand < 72) {
		return 6;
	} else if (rand < 87) {
		return 7;
	} else if (rand < 89.95) {
		return 8;
	} else if (rand < 99.95) {
		return 9;
	} else {
		return 10;
	}
}
var fishes = [];
var score = storage.moneyTotal || 0;
var fishermenCount = storage.fishermenCount || 0;
var fishermenCost = storage.fishermenCost || 1000;
var moneyMultiplier = storage.moneyMultiplier || 1.0; // Initialize money multiplier from storage
var scoreTxt = new Text2('$0', {
	size: 100,
	fill: 0x00FF00,
	// Green fill
	stroke: 0xFFFFFF,
	// White outline
	strokeThickness: 5 // Thickness of the outline
});
var shop = LK.getAsset('shop', {
	anchorX: 0.5,
	anchorY: 0.0,
	x: 1024,
	y: 200
});
game.addChild(shop);
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create and add fishing rod to the game
var fishingRod = game.addChild(new FishingRod());
// Function to spawn fish
function spawnFish(type) {
	var fish = new Fish(type);
	fish.x = 0; // Spawn fish only at the left side of the screen
	fish.y = Math.random() * 1500 + 500;
	fishes.push(fish);
	game.addChild(fish);
}
// Spawn initial fish
for (var i = 0; i < 10; i++) {
	spawnFish(generateFishType());
}
// Update function for the game
game.update = function () {
	// Update all fish
	var _loop = function _loop() {
			fishes[i].update();
			// Check for collision with fishing rod
			if (fishingRod.intersects(fishes[i])) {
				var _animateMessage = function animateMessage() {
					var elapsedTime = Date.now() - startTime;
					if (elapsedTime < slideUpDuration) {
						var progress = elapsedTime / slideUpDuration;
						caughtFishMessage.y = 2732 - progress * 100; // Slide up 100 pixels
						LK.setTimeout(_animateMessage, 16);
					} else {
						// Keep the message in place for the remaining duration
						LK.setTimeout(function () {
							caughtFishMessage.destroy();
						}, stayDuration);
					}
				};
				score += fishes[i].moneyValue * moneyMultiplier; // Multiply fish value by money multiplier
				storage.moneyTotal = score;
				if (score >= 1000000) {
					// Abbreviate to 'm' if score is 1,000,000 or more
					abbreviatedScore = (score / 1000000).toFixed(2) + 'm';
					scoreTxt.setText('$' + abbreviatedScore);
				} else if (score >= 1000) {
					// Abbreviate to 'k' if score is 1,000 or more
					abbreviatedScore = (score / 1000).toFixed(2) + 'k';
					scoreTxt.setText('$' + abbreviatedScore);
				} else {
					scoreTxt.setText('$' + score.toFixed(2));
				}
				fishes[i].destroy();
				fishes.splice(i, 1);
				spawnFish(generateFishType());
			}
		},
		abbreviatedScore,
		abbreviatedScore,
		caughtFishMessage,
		slideUpDuration,
		stayDuration,
		startTime;
	for (var i = 0; i < fishes.length; i++) {
		_loop();
	}
};
// Event handler for dragging the fishing rod
game.move = function (x, y, obj) {
	fishingRod.x = x;
	fishingRod.y = y;
	if (fishingRod.y <= shop.y + 270) {
		fishingRod.alpha = 0;
	} else {
		fishingRod.alpha = 1;
	}
};
 
 
 
 
 
 
 Water themed gui icon that has the text "Shop" on it. 8-bit art style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 
 
 
 
 Big red X button for a game gui. 8-bit art style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
 8-bit art style circular fishing net without a handle.. 8-bit art style
 A bright green + symbol for a game GUI element. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. 8-bit art style