diff --git a/css/main.css b/css/main.css index 71297e2..08a5878 100644 --- a/css/main.css +++ b/css/main.css @@ -100,7 +100,7 @@ body { text-align: center; color: black; float: left; - font-size: 20px; + font-size: 18px; line-height: 43px; width: 100%; } diff --git a/images/items/pickaxe.png b/images/items/pickaxe.png new file mode 100644 index 0000000..f39cb48 Binary files /dev/null and b/images/items/pickaxe.png differ diff --git a/images/tiles/smith10.png b/images/tiles/smith10.png new file mode 100644 index 0000000..d7f91c0 Binary files /dev/null and b/images/tiles/smith10.png differ diff --git a/images/tiles/smith11.png b/images/tiles/smith11.png new file mode 100644 index 0000000..146784c Binary files /dev/null and b/images/tiles/smith11.png differ diff --git a/images/tiles/smith12.png b/images/tiles/smith12.png new file mode 100644 index 0000000..ee1fe4a Binary files /dev/null and b/images/tiles/smith12.png differ diff --git a/js/game.js b/js/game.js index 325ad73..5ed9a6e 100644 --- a/js/game.js +++ b/js/game.js @@ -6,6 +6,7 @@ var factoryRerollPrice = 2 var factorys = [] var inventory = {} +var teleporter = {} var money = 100 var items = [] @@ -261,7 +262,11 @@ function render() { var item = factorys[currentFactory].items[i] // var img = new Image // img.src = "images/items/" + getItemFormId(item.id).name + ".png" - ctx.drawImage(items[item.id].img, item.x, item.y, 48, 48) + if (item.dx != 0 || item.dy != 0) + ctx.drawImage(items[item.id].img, item.x, item.y, 48, 48) + else if (factorys[currentFactory].tiles[item.x / 48][item.y / 48] == 0) + ctx.drawImage(items[item.id].img, item.x, item.y, 48, 48) + } //RENDER TILE-LAYER1 for (var i = 0; i < tilesToRender.length; i++) { diff --git a/js/items.json b/js/items.json index fb775f3..3b8fcb5 100644 --- a/js/items.json +++ b/js/items.json @@ -139,6 +139,10 @@ "id": 34, "name": "slag", "value": 5 + }, { + "id": 35, + "name": "pickaxe", + "value": 5 }], "minerals": { "nameFromId": ["bauxite", diff --git a/js/tiles.js b/js/tiles.js index 68f1b58..6095c86 100644 --- a/js/tiles.js +++ b/js/tiles.js @@ -257,6 +257,105 @@ class Charcoalmeiler extends Tile { } } +class Smith extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.maxwork = 96 * 10 + this.currentwork = 0 + this.name = "smith" + this.i = 19 + this.cost = [{ + "id": 0, + "count": 1000 + }, + { + "id": 3, + "count": 30 + } + ] + this.texture = { + "0": [], + "1": ["smith10", "smith11", "smith12", "smith11"] + } + this.loadImages() + } + + getImage(fulltime, layer) { + fulltime = Math.round(fulltime / 7) + if (this.images[layer].length == 0) + return "0" + return this.images[layer][(fulltime % this.images[layer].length)] + } + + work() { + if (this.input.countOf(2) >= 1 && this.input.countOf(33) >= 1) { + if (this.currentwork == this.maxwork) { + this.input.take(2, 1, this.factory) + this.input.take(33, 1, this.factory) + var item = new Item(35, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + this.currentwork = 0 + } else { + this.currentwork++ + } + } else { + this.currentwork = 0 + } + } +} + +class CrucibleFurnace extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.maxwork = 96 * 10 + this.currentwork = 0 + this.name = "cruciblefurnace" + this.i = 18 + this.cost = [{ + "id": 0, + "count": 1000 + }, + { + "id": 3, + "count": 30 + } + ] + this.texture = { + "0": [], + "1": ["cruciblefurnace10", "cruciblefurnace11", "cruciblefurnace12", "cruciblefurnace11"] + } + this.loadImages() + } + + getImage(fulltime, layer) { + fulltime = Math.round(fulltime / 4) + if (this.images[layer].length == 0) + return "0" + return this.images[layer][(fulltime % this.images[layer].length)] + } + + work() { + //Items für ein Pank + var requieredCount = 10 + if (this.input.countOf(33) >= 35 && this.input.countOf(16) >= 5) { + if (this.currentwork == this.maxwork) { + this.input.take(2, requieredCount, this.factory) + for (var i = 0; i < 40; i++) { + var item = new Item(32, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + } + this.currentwork = 0 + } else { + this.currentwork++ + } + } else { + this.currentwork = 0 + } + } +} + class AdvancedCharcoalmeiler extends Tile { constructor(x, y, factory) { super(x, y, factory) @@ -505,8 +604,8 @@ class BlastfurnaceLower extends Tile { this.currentwork = 0 this.input.take(16, 40, this.factory) this.input.take(11, 10, this.factory) - for (var i = 0; i < 15; i++) { - var item = new Item(11, this.x * 48, this.y * 48) + for (var i = 0; i < 35; i++) { + var item = new Item(33, this.x * 48, this.y * 48) this.factory.items.push(item) item.setDFromDirection(this.direction) } @@ -525,6 +624,7 @@ class BlastfurnaceUpper extends Tile { this.name = "blastfurnaceupper" this.i = 17 this.dust = 0 + this.hasNoInventory = true this.cost = [{ "id": 0, "count": 60000 @@ -870,6 +970,94 @@ class Warehouse extends Tile { } } } + +class TeleporterInput extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.name = "teleporterinput" + this.hasNoInventory = true + this.i = 20 + this.frequency = 0 + this.cost = [{ + "id": 0, + "count": 50 + }] + this.texture = { + "0": [], + "1": ["collector13"] + } + this.options = [{ + "type": "amount", + "var": "frequency" + }] + this.loadImages() + } + + work() { + if (teleporter[this.frequency] == undefined) { + teleporter[this.frequency] = new FactoryInventory + } + while (this.input.items.length > 0) { + var item = this.input.items.pop() + teleporter[this.frequency].addItem(item) + this.factory.deleteItem(item) + } + } + + getImage(fulltime, layer) { + fulltime = Math.round(fulltime / 6) + if (this.images[layer].length == 0) + return "0" + return this.images[layer][(fulltime % this.images[layer].length)] + } +} + +class TeleporterOutput extends Tile { + constructor(x, y, factory) { + super(x, y, factory) + this.name = "teleporteroutput" + this.hasNoInventory = true + this.i = 21 + this.frequency = 0 + this.cost = [{ + "id": 0, + "count": 50 + }] + this.texture = { + "0": [], + "1": ["collector13"] + } + this.options = [{ + "type": "amount", + "var": "frequency" + }] + this.loadImages() + } + + work() { + if (teleporter[this.frequency] == undefined) { + teleporter[this.frequency] = new FactoryInventory + } + while (teleporter[this.frequency].items.length > 0) { + var c = teleporter[this.frequency].itemcount[0] + var id = teleporter[this.frequency].items[0] + teleporter[this.frequency].take(id, c) + for (var i = 0; i < c; i++) { + var item = new Item(id, this.x * 48, this.y * 48) + this.factory.items.push(item) + item.setDFromDirection(this.direction) + } + } + } + + getImage(fulltime, layer) { + fulltime = Math.round(fulltime / 6) + if (this.images[layer].length == 0) + return "0" + return this.images[layer][(fulltime % this.images[layer].length)] + } +} + tileClasses.push(Conveyorbelt) //0 tileClasses.push(Treefarm) //1 tileClasses.push(Saw) //2 @@ -888,3 +1076,7 @@ tileClasses.push(Cokery) //14 tileClasses.push(MineralWasher) //15 tileClasses.push(BlastfurnaceLower) //16 tileClasses.push(BlastfurnaceUpper) //17 +tileClasses.push(CrucibleFurnace) //18 +tileClasses.push(Smith) //19 +tileClasses.push(TeleporterInput) //20 +tileClasses.push(TeleporterOutput) //21 diff --git a/js/userinterface.js b/js/userinterface.js index d6709d2..3391c6e 100644 --- a/js/userinterface.js +++ b/js/userinterface.js @@ -573,9 +573,7 @@ function drawInventory(inventory, title) { return true for (var y = 0; y < 3; y++) { for (var x = 0; x < 10; x++) { - var img = new Image - img.src = "images/items/" + items[itemId[currentIndex]].name + ".png" - inventoryCtx.drawImage(img, 12 + x * 72, 36 + y * 72, 48, 48) + inventoryCtx.drawImage(items[itemId[currentIndex]].img, 12 + x * 72, 36 + y * 72, 48, 48) var formattedCount = formatItemCount(itemCount[currentIndex]) inventoryCtx.strokeStyle = "black" @@ -611,12 +609,10 @@ function drawBigInventory(inventory) { var currentIndex = 0 while (currentIndex != itemId.length) { var itemCtx = $('#itemBig_' + currentIndex)[0].getContext("2d") - var img = new Image - img.src = "images/items/" + items[itemId[currentIndex]].name + ".png" itemCtx.clearRect(0, 0, innerWidth, innerHeight) itemCtx.font = "16px Electrolize" itemCtx.drawImage(itembg, 0, 0, 72, 72) - itemCtx.drawImage(img, 12, 12, 48, 48) + itemCtx.drawImage(items[itemId[currentIndex]].img, 12, 12, 48, 48) var formattedCount = formatItemCount(itemCount[currentIndex]) itemCtx.strokeStyle = "black" diff --git a/lang/en.json b/lang/en.json index 7631997..b4ab241 100644 --- a/lang/en.json +++ b/lang/en.json @@ -65,12 +65,20 @@ "description": "Gets some Minerals" }, "blastfurnacelower": { - "name": "Mineral Washer", - "description": "Gets some Minerals" + "name": "Blast Furnace (Lower Part)", + "description": "Melts 40 Iron Ore with 10 Coke to create 35 Raw Iron. Requieres a upper part to work." + }, + "smith": { + "name": "Smith", + "description": "Build a Pickaxe out of 1 Steel and 1 Plank" }, "blastfurnaceupper": { - "name": "Mineral Washer", - "description": "Gets some Minerals" + "name": "Blast Furnace (Upper Part)", + "description": "Is requiered to put on the lower Blast Furnace Part" + }, + "cruciblefurnace": { + "name": "Crucible Furnace", + "description": "Enriches 35 Rawiron with 5 Iron Ore into 40 Steel" }, "filterleft": { "name": "Item Filter (left)", @@ -79,6 +87,20 @@ "filter": "Filtered Item" } }, + "teleporterinput": { + "name": "teleporterinput", + "description": "Puts a selected Item to the left and all other straight.", + "options": { + "frequency": "Frequency" + } + }, + "teleporteroutput": { + "name": "teleporteroutput", + "description": "Puts a selected Item to the left and all other straight.", + "options": { + "frequency": "Frequency" + } + }, "filterright": { "name": "Item Filter (right)", "description": "Puts a selected Item to the right and all other straight.", @@ -120,7 +142,7 @@ "tin", "salt" ], - "items": ["None", "Log", "Planks", "Stone", "Charcoal", "Sawdust", "Charcoal Dust", "Raw Paper", "Paper", "Siev", "Filter", "Coke", "Briquettes","Bauxite","Lead Ore","Chrome Ore","Iron Ore","Cobalt Ore","Copper Ore","Lithium Ore","Magnesium Ore","Manganese Ore","Molybdenum Ore","Nickel Ore","Silver Ore","Tantalum Ore","Titanium Ore","Uranium Ore","Vanadium Ore","Tungesten Ore","Zinc Ore","Tin Ore","Steel","Raw Iron","Slag"], + "items": ["None", "Log", "Planks", "Stone", "Charcoal", "Sawdust", "Charcoal Dust", "Raw Paper", "Paper", "Siev", "Filter", "Coke", "Briquettes","Bauxite","Lead Ore","Chrome Ore","Iron Ore","Cobalt Ore","Copper Ore","Lithium Ore","Magnesium Ore","Manganese Ore","Molybdenum Ore","Nickel Ore","Silver Ore","Tantalum Ore","Titanium Ore","Uranium Ore","Vanadium Ore","Tungesten Ore","Zinc Ore","Tin Ore","Steel","Raw Iron","Slag","Pickaxe"], "more": "Show Inventory / Sell Items", "inventory": "Inventory", "player": "Player",