{"__v":3,"_id":"554f0dfacbb3510d00a5738a","category":{"__v":5,"_id":"55094050961f17170070abbd","project":"543b9b0065bf840e00b473d5","version":"543b9b0065bf840e00b473d8","pages":["550942e2368a5617004146d8","550a3bca42fff40d00ae600c","550a42a342fff40d00ae6022","550a854f635c660d005280b8","554f0dfacbb3510d00a5738a"],"reference":false,"createdAt":"2015-03-18T09:07:28.587Z","from_sync":false,"order":2,"slug":"player-village","title":"Player Village"},"project":"543b9b0065bf840e00b473d5","user":"543b9aa865bf840e00b473d1","version":{"__v":11,"_id":"543b9b0065bf840e00b473d8","project":"543b9b0065bf840e00b473d5","createdAt":"2014-10-13T09:27:28.467Z","releaseDate":"2014-10-13T09:27:28.467Z","categories":["543b9b0065bf840e00b473d9","543b9ef065bf840e00b473e0","54890012f291f61400c02d36","54890902f291f61400c02d3e","54890c43f291f61400c02d44","54890d71c178b40b00aa3086","5508125c0c4d8c19008a5f83","55094050961f17170070abbd","550945111c38c50d006118ad","550a4c2e42fff40d00ae6049","55221c074801a40d00a77610"],"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"createdAt":"2015-05-10T07:51:22.263Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"order":5,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Purchasing Buildings\"\n}\n[/block]\nObjects can be purchased with one of the two currencies. So there are two sections in the XML file: **gold_based** and **resource_cost**\n\nThis is important because the name is not friendly. But it's a very easy concept.\nEvery object can be bought spending Gold **OR EITHER** Mana Juice.\nThere's no object that needs both of them.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"If the gold_based cell is \\\"True\\\" it means that the object may be bought spending Gold.\\n\\nIf the gold_based cell is \\\"False\\\" it means that the object may be bought spending Mana Juice.\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/cfIrkNaR3y0KE6U8C49d\",\n        \"goldresource.jpg\",\n        \"800\",\n        \"600\",\n        \"#8493b2\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nExample: Creation of a research building included in the kit\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Research Globe -> gold_based == True && resource_cost == 10000\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nThis means that the player have to spend 10000 Gold to build a Research Globe.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What about more than two in-game currencies?\"\n}\n[/block]\nIn order to have buildings based on more than 2 currencies, just replace the GoldBased boolean with an integer and then modify the xml \"reader\" - the sequences that process the xml, as well as some verifications in BuildingCreator, here and there. The modifications are not very extensive for this issue.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Upgrading Buildings\"\n}\n[/block]\nThe same is for the upgrade. You specify the currency type (gold or liquid mana) and cost:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/1gnWnuHnROmqRRbpcnJo\",\n        \"upgradecost.jpg\",\n        \"800\",\n        \"600\",\n        \"#3a3a3b\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nExample: \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Summoning Circle -> gold_based == False && 2_upgrade_cost == 12500\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nThis means that the player have to spend 12500 Mana Juice to upgrade the Summoning Circle to lev 2\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Selling a Building\"\n}\n[/block]\nThis is important because there's no column on the XML file talking about this.\nSell rate always equal 60% building value and this value has to be added to the object.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"object.sell_rate = object.Calculate_Value() * .6\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Production Buildings\"\n}\n[/block]\nYou can see that one the production building are created using the opposite resource. This is intended, but it may create confusion.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Gold Forge \\t-> gold_based == False\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nThe Gold Forge is built using Mana Juice, but produces Gold\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Mana Generator\\t-> gold_based == True\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nThe Mana Generator is built using Gold, but produces Mana Juice\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Production Rate\"\n}\n[/block]\nThe resource generator buildings generates an amount of resources every second. To calculate the entire generation of a player we have to sum every production.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"player.goldGenerationPerSec = CalculateTotalGoldGeneration (building_on_gameboard, building_level)\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nSame for the Mana Juice\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Production Storage\"\n}\n[/block]\nEach player has a maximum amount of resources depending on the building settings. This is calculated as follows for Gold.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"player.maxGold = CalculateGoldStorage (buildings_on_gameboard, building_level)\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nSame for the Mana Juice (liquid currency).\n\nIf the total exceed the max, the resources won't generate more income.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if player.currentGold >= player.maxGold\\n\\t\\tplayer.goldGenerationPerSec = 0\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nResource Generation is processed by Stats.cs, at 1 second interval.\n\nStats.cs contains two variables:\n[block:parameters]\n{\n  \"data\": {\n    \"0-1\": \"production per second\",\n    \"1-1\": \"number of buildings who produce different resources\",\n    \"1-0\": \"public int[] productionBuildings\",\n    \"0-0\": \"public float[] productionRates\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\nBuildingCreator.cs reads the numeric data in Buildings.xml, and among other things, records production rates and storage increase in two of the methods:\n\nThe rates can be updated before the building is finished:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"LoadBuilding()\\n((Stats)stats).productionRates[0] = float.Parse(buildings [currentSelection] [\\\"ProdPerSec\\\"]);\\n//if the building produces resources, the productionRates is passed to Stats\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nThis one passes the storage increase to the ConstructionSelector.cs (storage will increase when the building will be finished)\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PlaceObject()\\n((ConstructionSelector)selectedConstruction.GetComponent(\\\"ConstructionSelector\\\")).storageIncrease = int.Parse (buildings [currentSelection] [\\\"StoreCap\\\"]);\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nWhen the building is finished, ConstructionSelector.cs passes the info to Stats.cs regarding both storage increase and a new production building ready\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"if(buildingType==\\\"Barrel\\\")\\n//increases total storage in Stats\\n{\\n        ((Stats)stats).maxStorageMana += storageIncrease;\\n}\\nelse if(buildingType==\\\"Forge\\\")\\n{\\n        ((Stats)stats).productionBuildings[0]++;\\n        ((Stats)stats).maxStorageGold += storageIncrease;\\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nExtend these, to reflect the new production buildings, and carefully modify these 4 files – Buildings.xml, BuildingCreator.cs, ConstructionSelector.cs and Stats.cs.\n\nThere is also a cancel method in BuildingCreator.cs that decreases both production and storage when a building is selected and destroyed:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"CancelObject()\\nelse if (currentSelection == 4) //4=Forge (gold)\\n{\\n        ((Stats)stats).productionBuildings[0]--;\\n        DecreaseStorage(1);\\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nAnalyze these files with patience, because this goes pretty deep into the kit. The info is also processed back and forth in the game load scripts - the whole kit is extremely intricate at this point.\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Important Dobbit Toolhouse (object id = 12)\"\n}\n[/block]\nThe Dobbit toolhouse also the only building that may be built independently.\nFor every other building the player could upgrade or create only one building at a time for each builder he has.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://www.filepicker.io/api/file/LFY2ap5SCuK92A7Z9Fvk\",\n        \"dobbit.jpg\",\n        \"800\",\n        \"600\",\n        \"#d4422d\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n(Ex. if the player has 3 dobbit toolhouse he may create one building while upgrading two others.) \n\nIt's the same rule used by clash of clans builder's hut.","excerpt":"","slug":"costs-upgrades-and-settings","type":"basic","title":"Costs, Upgrades, and Settings"}

Costs, Upgrades, and Settings


[block:api-header] { "type": "basic", "title": "Purchasing Buildings" } [/block] Objects can be purchased with one of the two currencies. So there are two sections in the XML file: **gold_based** and **resource_cost** This is important because the name is not friendly. But it's a very easy concept. Every object can be bought spending Gold **OR EITHER** Mana Juice. There's no object that needs both of them. [block:code] { "codes": [ { "code": "If the gold_based cell is \"True\" it means that the object may be bought spending Gold.\n\nIf the gold_based cell is \"False\" it means that the object may be bought spending Mana Juice.", "language": "text" } ] } [/block] [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/cfIrkNaR3y0KE6U8C49d", "goldresource.jpg", "800", "600", "#8493b2", "" ] } ] } [/block] Example: Creation of a research building included in the kit [block:code] { "codes": [ { "code": "Research Globe -> gold_based == True && resource_cost == 10000", "language": "text" } ] } [/block] This means that the player have to spend 10000 Gold to build a Research Globe. [block:api-header] { "type": "basic", "title": "What about more than two in-game currencies?" } [/block] In order to have buildings based on more than 2 currencies, just replace the GoldBased boolean with an integer and then modify the xml "reader" - the sequences that process the xml, as well as some verifications in BuildingCreator, here and there. The modifications are not very extensive for this issue. [block:api-header] { "type": "basic", "title": "Upgrading Buildings" } [/block] The same is for the upgrade. You specify the currency type (gold or liquid mana) and cost: [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/1gnWnuHnROmqRRbpcnJo", "upgradecost.jpg", "800", "600", "#3a3a3b", "" ] } ] } [/block] Example: [block:code] { "codes": [ { "code": "Summoning Circle -> gold_based == False && 2_upgrade_cost == 12500", "language": "text" } ] } [/block] This means that the player have to spend 12500 Mana Juice to upgrade the Summoning Circle to lev 2 [block:api-header] { "type": "basic", "title": "Selling a Building" } [/block] This is important because there's no column on the XML file talking about this. Sell rate always equal 60% building value and this value has to be added to the object. [block:code] { "codes": [ { "code": "object.sell_rate = object.Calculate_Value() * .6", "language": "csharp" } ] } [/block] [block:api-header] { "type": "basic", "title": "Production Buildings" } [/block] You can see that one the production building are created using the opposite resource. This is intended, but it may create confusion. [block:code] { "codes": [ { "code": "Gold Forge \t-> gold_based == False", "language": "text" } ] } [/block] The Gold Forge is built using Mana Juice, but produces Gold [block:code] { "codes": [ { "code": "Mana Generator\t-> gold_based == True", "language": "text" } ] } [/block] The Mana Generator is built using Gold, but produces Mana Juice [block:api-header] { "type": "basic", "title": "Production Rate" } [/block] The resource generator buildings generates an amount of resources every second. To calculate the entire generation of a player we have to sum every production. [block:code] { "codes": [ { "code": "player.goldGenerationPerSec = CalculateTotalGoldGeneration (building_on_gameboard, building_level)", "language": "csharp" } ] } [/block] Same for the Mana Juice [block:api-header] { "type": "basic", "title": "Production Storage" } [/block] Each player has a maximum amount of resources depending on the building settings. This is calculated as follows for Gold. [block:code] { "codes": [ { "code": "player.maxGold = CalculateGoldStorage (buildings_on_gameboard, building_level)", "language": "csharp" } ] } [/block] Same for the Mana Juice (liquid currency). If the total exceed the max, the resources won't generate more income. [block:code] { "codes": [ { "code": "if player.currentGold >= player.maxGold\n\t\tplayer.goldGenerationPerSec = 0", "language": "csharp" } ] } [/block] Resource Generation is processed by Stats.cs, at 1 second interval. Stats.cs contains two variables: [block:parameters] { "data": { "0-1": "production per second", "1-1": "number of buildings who produce different resources", "1-0": "public int[] productionBuildings", "0-0": "public float[] productionRates" }, "cols": 2, "rows": 2 } [/block] BuildingCreator.cs reads the numeric data in Buildings.xml, and among other things, records production rates and storage increase in two of the methods: The rates can be updated before the building is finished: [block:code] { "codes": [ { "code": "LoadBuilding()\n((Stats)stats).productionRates[0] = float.Parse(buildings [currentSelection] [\"ProdPerSec\"]);\n//if the building produces resources, the productionRates is passed to Stats", "language": "csharp" } ] } [/block] This one passes the storage increase to the ConstructionSelector.cs (storage will increase when the building will be finished) [block:code] { "codes": [ { "code": "PlaceObject()\n((ConstructionSelector)selectedConstruction.GetComponent(\"ConstructionSelector\")).storageIncrease = int.Parse (buildings [currentSelection] [\"StoreCap\"]);", "language": "csharp" } ] } [/block] When the building is finished, ConstructionSelector.cs passes the info to Stats.cs regarding both storage increase and a new production building ready [block:code] { "codes": [ { "code": "if(buildingType==\"Barrel\")\n//increases total storage in Stats\n{\n ((Stats)stats).maxStorageMana += storageIncrease;\n}\nelse if(buildingType==\"Forge\")\n{\n ((Stats)stats).productionBuildings[0]++;\n ((Stats)stats).maxStorageGold += storageIncrease;\n}", "language": "csharp" } ] } [/block] Extend these, to reflect the new production buildings, and carefully modify these 4 files – Buildings.xml, BuildingCreator.cs, ConstructionSelector.cs and Stats.cs. There is also a cancel method in BuildingCreator.cs that decreases both production and storage when a building is selected and destroyed: [block:code] { "codes": [ { "code": "CancelObject()\nelse if (currentSelection == 4) //4=Forge (gold)\n{\n ((Stats)stats).productionBuildings[0]--;\n DecreaseStorage(1);\n}", "language": "csharp" } ] } [/block] Analyze these files with patience, because this goes pretty deep into the kit. The info is also processed back and forth in the game load scripts - the whole kit is extremely intricate at this point. [block:api-header] { "type": "basic", "title": "Important Dobbit Toolhouse (object id = 12)" } [/block] The Dobbit toolhouse also the only building that may be built independently. For every other building the player could upgrade or create only one building at a time for each builder he has. [block:image] { "images": [ { "image": [ "https://www.filepicker.io/api/file/LFY2ap5SCuK92A7Z9Fvk", "dobbit.jpg", "800", "600", "#d4422d", "" ] } ] } [/block] (Ex. if the player has 3 dobbit toolhouse he may create one building while upgrading two others.) It's the same rule used by clash of clans builder's hut.