{"_id":"59a9f7b428ab5f000f239566","category":{"_id":"59a9f7b328ab5f000f23954d","version":"59a9f7b328ab5f000f23954a","project":"543b9b0065bf840e00b473d5","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-11-10T14:32:08.590Z","from_sync":false,"order":2,"slug":"store","title":"Shop Menu"},"user":"543b9aa865bf840e00b473d1","parentDoc":null,"project":"543b9b0065bf840e00b473d5","version":{"_id":"59a9f7b328ab5f000f23954a","project":"543b9b0065bf840e00b473d5","__v":1,"createdAt":"2017-09-02T00:13:39.834Z","releaseDate":"2017-09-02T00:13:39.834Z","categories":["59a9f7b328ab5f000f23954b","59a9f7b328ab5f000f23954c","59a9f7b328ab5f000f23954d","59a9f7b328ab5f000f23954e","59a9f7b328ab5f000f23954f","59a9f7b328ab5f000f239550","59a9f7b328ab5f000f239551","59a9f7b328ab5f000f239552","59a9f7b328ab5f000f239553","59a9f7b328ab5f000f239554","59a9f7b328ab5f000f239555","59a9f7b328ab5f000f239556","59a9f7b328ab5f000f239557"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"7.2.0","version":"7.2"},"githubsync":"","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-11-19T14:52:12.234Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.\",\n  \"title\": \"Reminder - Keep Daily Backups\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What is the shop menu?\"\n}\n[/block]\nIn the new kit we've updated the entire shopping experience to a centralized menu and common scripting experience. This makes developing your game prototype even easier than ever. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/494d080-Screen_Shot_2016-11-19_at_7.44.40_PM.png\",\n        \"Screen Shot 2016-11-19 at 7.44.40 PM.png\",\n        636,\n        401,\n        \"#6aaabb\"\n      ],\n      \"caption\": \"Shop menu home. Click to view larger.\"\n    }\n  ]\n}\n[/block]\nAll of the script files are located in the Menus folder. And in the UI - you'll find the shop under UIAnchor - Center.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7692da7-Screen_Shot_2016-11-20_at_12.12.46_AM.png\",\n        \"Screen Shot 2016-11-20 at 12.12.46 AM.png\",\n        272,\n        506,\n        \"#c3c3c3\"\n      ],\n      \"caption\": \"Click to view larger.\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/26e833f-Screen_Shot_2016-11-20_at_12.12.52_AM.png\",\n        \"Screen Shot 2016-11-20 at 12.12.52 AM.png\",\n        308,\n        718,\n        \"#c6c6c6\"\n      ],\n      \"caption\": \"Shop Inspector. Click to view larger.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Where is the shop in-game?\"\n}\n[/block]\nClick the shopping cart button on the right side to open the shop menu. See the screenshot below for where to locate the shop button in the game.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/99a71e3-shop-menu.png\",\n        \"shop-menu.png\",\n        900,\n        502,\n        \"#32461c\"\n      ],\n      \"caption\": \"Shop menu button. Click to view larger.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What does a normal building button look like in the store?\"\n}\n[/block]\nThe UpdateLabelStats() function in Scripts/Creators/BaseCreator.cs sets the default button color to brown for buildings the player is allowed to build. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a6f6983-can_purchase.png\",\n        \"can purchase.png\",\n        149,\n        154,\n        \"#34606a\"\n      ],\n      \"caption\": \"Normal price button. Click to view larger.\"\n    }\n  ]\n}\n[/block]\nThere are two cases in which the player is not allowed to build - either they don't have enough money or they have exceeded the number of structures they can build based on their XP level. These two alternative cases are described below.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What happens if I don't have enough resources to purchase an item?\"\n}\n[/block]\nIf you don't have enough resources, the UpdateLabelStats() function in Scripts/Creators/BaseCreator.cs changes the text red. Clicking the button shows an error message that you don't have enough of the currency.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e4df45e-not_enough_resources.png\",\n        \"not enough resources.png\",\n        151,\n        156,\n        \"#334d4f\"\n      ],\n      \"caption\": \"Not enough resources, button text turns red. Click to view larger.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What happens if my Level XP prevents additional purchases?\"\n}\n[/block]\nYou want to look at the Level XP documentation. In this example image below, the text in the store item shows 2/2 in the corner, which means for our current level we can only have a maximum of 2 gold forges and we've already created these. The store item turns grey and the button text black. \n\nClicking the button returns an error that your XP level needs to be higher (read the next section below for how to award XP points to your player - we already have setup a few examples like training units, building other structures, or removing trees and objects on the map)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a7d409c-grey.png\",\n        \"grey.png\",\n        161,\n        171,\n        \"#414e53\"\n      ],\n      \"caption\": \"XP Level restrictions prevent additional structures. Object turns grey. Click to view larger.\"\n    }\n  ]\n}\n[/block]\nThe following code reference is an excerpt from Scripts/Creators/BaseCreator.cs showing the function that updates the label stats with the changes we saw in the above images.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Scripts/Creators/BaseCreator.cs\\n// UpdateLabelStats() changes the store label pricing from the XML values\\n// in addition to changing the button functions depending if the player\\n// has the money to buy or their XP level restricts the number of buildings\\n\\n\\tprotected IEnumerator UpdateLabelStats()\\n\\t{\\n    // Wait for a small period to let the XML load\\n\\t\\tyield return new WaitForSeconds (xmlLoadDelay);\\n\\n    // Get an update to the structures allowed \\n\\t\\tUpdateStructuresAllowed ();\\n    \\n    // Colors for different issues\\n    // Black = XP level limit exceeded, can't build this structure\\n    // Brown = Normal, all is fine.\\n    // Red = Not enough of the currency to purchase\\n    \\n\\t\\tColor \\n\\t\\tblack = new Color (0, 0, 0),\\n\\t\\tbrown = new Color (0.45f, 0.09f, 0),\\n\\t\\tred = new Color (1, 0, 0);\\n\\n\\t\\tbool buildingAllowed;\\t\\n\\n    // Loop through all of the structures in the game\\n\\t\\tfor (int i = 0; i < totalStructures; i++) \\n\\t\\t{\\n      // Check if the building can still be created\\n\\t\\t\\tbuildingAllowed =(allowedStructures[i]-existingStructures[i]>0);\\n\\n      // Get label details\\n\\t\\t\\tNameLbs[i].text = structures [i] [\\\"Name\\\"];\\n\\t\\t\\tTimeLbs[i].text = structures [i] [\\\"TimeToBuild\\\"];\\n\\n\\t\\t\\tQuantityLbs[i].text =  existingStructures[i].ToString()+\\\"/\\\"+allowedStructures[i].ToString();\\n\\t\\t\\tPriceLbs[i].text = structures [i] [\\\"Price\\\"];\\n\\n      // If the building is allowed \\n      // (haven't exceeded XP level limits for this structure)\\n\\t\\t\\tif(buildingAllowed)\\n\\t\\t\\t{\\n        // Normal background blue graphic\\n        // And text colors\\n\\t\\t\\t\\tNicheSprites[i].spriteName = \\\"stone_niche\\\";\\n\\t\\t\\t\\tPortraitSprites[i].atlas = Portraits;\\n\\n\\t\\t\\t\\tNameLbs[i].color = brown;\\n\\t\\t\\t\\tTimeLbs[i].color = brown;\\n\\t\\t\\t\\tQuantityLbs[i].color = brown;\\n\\t\\t\\t\\tPriceLbs[i].color = brown;\\n\\t\\t\\t}\\n\\t\\t\\telse\\n\\t\\t\\t{\\n        // Exceeded level limits, so turn the background grey\\n        // and the text black\\n\\t\\t\\t\\tNicheSprites[i].spriteName = \\\"stone_niche_bw\\\";\\n\\t\\t\\t\\tPortraitSprites[i].atlas = PortraitsBW;\\n\\n\\t\\t\\t\\tNameLbs[i].color = black;\\n\\t\\t\\t\\tTimeLbs[i].color = black;\\n\\t\\t\\t\\tQuantityLbs[i].color = black;\\n\\t\\t\\t\\tPriceLbs[i].color = black;\\n\\t\\t\\t}\\t\\n\\n\\t\\t\\tbool hasMoney = false;\\n\\n      // Checks if they have enough of the currency the sturcture costs\\n\\t\\t\\tif (structures [i] [\\\"Currency\\\"] == \\\"Gold\\\")\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(((Stats)stats).gold + ((Stats)stats).deltaGoldPlus - ((Stats)stats).deltaGoldMinus >= int.Parse(structures [i] [\\\"Price\\\"]))\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\thasMoney = true;\\n\\t\\t\\t\\t}\\n\\t\\t\\t} \\n\\t\\t\\telse if (structures [i] [\\\"Currency\\\"] == \\\"Mana\\\")\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(((Stats)stats).mana + ((Stats)stats).deltaManaPlus - ((Stats)stats).deltaManaMinus>=int.Parse(structures [i] [\\\"Price\\\"]))\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\thasMoney = true;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\telse //if (structures [currentSelection] [\\\"Currency\\\"] == \\\"Crystals\\\")\\n\\t\\t\\t{\\n\\t\\t\\t\\tif(((Stats)stats).crystals +((Stats)stats).deltaCrystalsPlus-((Stats)stats).deltaCrystalsMinus>=int.Parse(structures [i] [\\\"Price\\\"]))\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\thasMoney = true;\\n\\t\\t\\t\\t}\\t\\n\\t\\t\\t}\\n\\n      // If they don't have the money, but the building is\\n      // allowed (not limited by XP) then change the text color\\n      // to red. Clicking the button will show a text error\\n      // (Another function handles this in the BaseCreator.cs script)\\n\\t\\t\\tif(!hasMoney && buildingAllowed)\\n\\t\\t\\t{\\n\\t\\t\\t\\t((UILabel)PriceLbs[i]).color = red;\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\",\n      \"language\": \"csharp\",\n      \"name\": \"UpdateLabelStats() excerpt from Scripts/Creators/BaseCreator.cs\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"What scripts are used in the shop menu?\"\n}\n[/block]\nFor units -- you'll want to open Scripts/Menus/Units/MenuUnits.cs\n\nFor in-app purchases - you'll want to open Scripts/Menus/Shop/Store.cs\n\nFor shield - this menu is just cosmetic, click Shop Menu > Shield on the left for details.\n\nFor all other menus (walls, buildings, resource buildings, decorations) open Scripts/Creators/BaseCreator.cs\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"More details...\"\n}\n[/block]\nFor more details about shop sections like buildings or walls, please click the specific section of the shop you would like to learn about from the left side Documentation menu.","excerpt":"","slug":"shop-overview-1","type":"basic","title":"Shop Overview"}
[block:callout] { "type": "success", "body": "When working on a strategy game with a kit as big as the Complete Kit - always keep a working daily backup! Save yourself the trouble of rolling-back changes and losing work.", "title": "Reminder - Keep Daily Backups" } [/block] [block:api-header] { "type": "basic", "title": "What is the shop menu?" } [/block] In the new kit we've updated the entire shopping experience to a centralized menu and common scripting experience. This makes developing your game prototype even easier than ever. [block:image] { "images": [ { "image": [ "https://files.readme.io/494d080-Screen_Shot_2016-11-19_at_7.44.40_PM.png", "Screen Shot 2016-11-19 at 7.44.40 PM.png", 636, 401, "#6aaabb" ], "caption": "Shop menu home. Click to view larger." } ] } [/block] All of the script files are located in the Menus folder. And in the UI - you'll find the shop under UIAnchor - Center. [block:image] { "images": [ { "image": [ "https://files.readme.io/7692da7-Screen_Shot_2016-11-20_at_12.12.46_AM.png", "Screen Shot 2016-11-20 at 12.12.46 AM.png", 272, 506, "#c3c3c3" ], "caption": "Click to view larger." } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/26e833f-Screen_Shot_2016-11-20_at_12.12.52_AM.png", "Screen Shot 2016-11-20 at 12.12.52 AM.png", 308, 718, "#c6c6c6" ], "caption": "Shop Inspector. Click to view larger." } ] } [/block] [block:api-header] { "type": "basic", "title": "Where is the shop in-game?" } [/block] Click the shopping cart button on the right side to open the shop menu. See the screenshot below for where to locate the shop button in the game. [block:image] { "images": [ { "image": [ "https://files.readme.io/99a71e3-shop-menu.png", "shop-menu.png", 900, 502, "#32461c" ], "caption": "Shop menu button. Click to view larger." } ] } [/block] [block:api-header] { "type": "basic", "title": "What does a normal building button look like in the store?" } [/block] The UpdateLabelStats() function in Scripts/Creators/BaseCreator.cs sets the default button color to brown for buildings the player is allowed to build. [block:image] { "images": [ { "image": [ "https://files.readme.io/a6f6983-can_purchase.png", "can purchase.png", 149, 154, "#34606a" ], "caption": "Normal price button. Click to view larger." } ] } [/block] There are two cases in which the player is not allowed to build - either they don't have enough money or they have exceeded the number of structures they can build based on their XP level. These two alternative cases are described below. [block:api-header] { "type": "basic", "title": "What happens if I don't have enough resources to purchase an item?" } [/block] If you don't have enough resources, the UpdateLabelStats() function in Scripts/Creators/BaseCreator.cs changes the text red. Clicking the button shows an error message that you don't have enough of the currency. [block:image] { "images": [ { "image": [ "https://files.readme.io/e4df45e-not_enough_resources.png", "not enough resources.png", 151, 156, "#334d4f" ], "caption": "Not enough resources, button text turns red. Click to view larger." } ] } [/block] [block:api-header] { "type": "basic", "title": "What happens if my Level XP prevents additional purchases?" } [/block] You want to look at the Level XP documentation. In this example image below, the text in the store item shows 2/2 in the corner, which means for our current level we can only have a maximum of 2 gold forges and we've already created these. The store item turns grey and the button text black. Clicking the button returns an error that your XP level needs to be higher (read the next section below for how to award XP points to your player - we already have setup a few examples like training units, building other structures, or removing trees and objects on the map) [block:image] { "images": [ { "image": [ "https://files.readme.io/a7d409c-grey.png", "grey.png", 161, 171, "#414e53" ], "caption": "XP Level restrictions prevent additional structures. Object turns grey. Click to view larger." } ] } [/block] The following code reference is an excerpt from Scripts/Creators/BaseCreator.cs showing the function that updates the label stats with the changes we saw in the above images. [block:code] { "codes": [ { "code": "// Scripts/Creators/BaseCreator.cs\n// UpdateLabelStats() changes the store label pricing from the XML values\n// in addition to changing the button functions depending if the player\n// has the money to buy or their XP level restricts the number of buildings\n\n\tprotected IEnumerator UpdateLabelStats()\n\t{\n // Wait for a small period to let the XML load\n\t\tyield return new WaitForSeconds (xmlLoadDelay);\n\n // Get an update to the structures allowed \n\t\tUpdateStructuresAllowed ();\n \n // Colors for different issues\n // Black = XP level limit exceeded, can't build this structure\n // Brown = Normal, all is fine.\n // Red = Not enough of the currency to purchase\n \n\t\tColor \n\t\tblack = new Color (0, 0, 0),\n\t\tbrown = new Color (0.45f, 0.09f, 0),\n\t\tred = new Color (1, 0, 0);\n\n\t\tbool buildingAllowed;\t\n\n // Loop through all of the structures in the game\n\t\tfor (int i = 0; i < totalStructures; i++) \n\t\t{\n // Check if the building can still be created\n\t\t\tbuildingAllowed =(allowedStructures[i]-existingStructures[i]>0);\n\n // Get label details\n\t\t\tNameLbs[i].text = structures [i] [\"Name\"];\n\t\t\tTimeLbs[i].text = structures [i] [\"TimeToBuild\"];\n\n\t\t\tQuantityLbs[i].text = existingStructures[i].ToString()+\"/\"+allowedStructures[i].ToString();\n\t\t\tPriceLbs[i].text = structures [i] [\"Price\"];\n\n // If the building is allowed \n // (haven't exceeded XP level limits for this structure)\n\t\t\tif(buildingAllowed)\n\t\t\t{\n // Normal background blue graphic\n // And text colors\n\t\t\t\tNicheSprites[i].spriteName = \"stone_niche\";\n\t\t\t\tPortraitSprites[i].atlas = Portraits;\n\n\t\t\t\tNameLbs[i].color = brown;\n\t\t\t\tTimeLbs[i].color = brown;\n\t\t\t\tQuantityLbs[i].color = brown;\n\t\t\t\tPriceLbs[i].color = brown;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n // Exceeded level limits, so turn the background grey\n // and the text black\n\t\t\t\tNicheSprites[i].spriteName = \"stone_niche_bw\";\n\t\t\t\tPortraitSprites[i].atlas = PortraitsBW;\n\n\t\t\t\tNameLbs[i].color = black;\n\t\t\t\tTimeLbs[i].color = black;\n\t\t\t\tQuantityLbs[i].color = black;\n\t\t\t\tPriceLbs[i].color = black;\n\t\t\t}\t\n\n\t\t\tbool hasMoney = false;\n\n // Checks if they have enough of the currency the sturcture costs\n\t\t\tif (structures [i] [\"Currency\"] == \"Gold\")\n\t\t\t{\n\t\t\t\tif(((Stats)stats).gold + ((Stats)stats).deltaGoldPlus - ((Stats)stats).deltaGoldMinus >= int.Parse(structures [i] [\"Price\"]))\n\t\t\t\t{\n\t\t\t\t\thasMoney = true;\n\t\t\t\t}\n\t\t\t} \n\t\t\telse if (structures [i] [\"Currency\"] == \"Mana\")\n\t\t\t{\n\t\t\t\tif(((Stats)stats).mana + ((Stats)stats).deltaManaPlus - ((Stats)stats).deltaManaMinus>=int.Parse(structures [i] [\"Price\"]))\n\t\t\t\t{\n\t\t\t\t\thasMoney = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse //if (structures [currentSelection] [\"Currency\"] == \"Crystals\")\n\t\t\t{\n\t\t\t\tif(((Stats)stats).crystals +((Stats)stats).deltaCrystalsPlus-((Stats)stats).deltaCrystalsMinus>=int.Parse(structures [i] [\"Price\"]))\n\t\t\t\t{\n\t\t\t\t\thasMoney = true;\n\t\t\t\t}\t\n\t\t\t}\n\n // If they don't have the money, but the building is\n // allowed (not limited by XP) then change the text color\n // to red. Clicking the button will show a text error\n // (Another function handles this in the BaseCreator.cs script)\n\t\t\tif(!hasMoney && buildingAllowed)\n\t\t\t{\n\t\t\t\t((UILabel)PriceLbs[i]).color = red;\n\t\t\t}\n\t\t}\n\t}", "language": "csharp", "name": "UpdateLabelStats() excerpt from Scripts/Creators/BaseCreator.cs" } ] } [/block] [block:api-header] { "type": "basic", "title": "What scripts are used in the shop menu?" } [/block] For units -- you'll want to open Scripts/Menus/Units/MenuUnits.cs For in-app purchases - you'll want to open Scripts/Menus/Shop/Store.cs For shield - this menu is just cosmetic, click Shop Menu > Shield on the left for details. For all other menus (walls, buildings, resource buildings, decorations) open Scripts/Creators/BaseCreator.cs [block:api-header] { "type": "basic", "title": "More details..." } [/block] For more details about shop sections like buildings or walls, please click the specific section of the shop you would like to learn about from the left side Documentation menu.