private void ConnectXML() { string resourcePath = fileRoot + xmlFile; XMLNode xml = XMLParser.Parse((Resources.Load(resourcePath, typeof(TextAsset)) as TextAsset).text); XMLNodeList xmlList = xml.GetNodeList(xmlRoot); XMLNode xmlSubNode = xmlList[PRODUCTS] as XMLNode; XMLNodeList productsXML = xmlSubNode.GetNodeList("products>0>product"); for (int j = 0; j < productsXML.Count; j++) { XMLNode productXML = productsXML[j] as XMLNode; Product product = new Product(); product.name = productXML.GetValue("@name"); product.tag = productXML.GetValue("@tag"); product.cost = float.Parse(productXML.GetValue("@cost")); product.price = float.Parse(productXML.GetValue("@retail")); product.upgradeCost = float.Parse(productXML.GetValue("@upgrade")); product.time = float.Parse(productXML.GetValue("@time")); product.viability = int.Parse(productXML.GetValue("@viability")); product.customers = int.Parse(productXML.GetValue("@customers")); products.Add(product); } // Debug.Log(products); xmlSubNode = xmlList[ENTERTAINMENTS] as XMLNode; XMLNodeList entertainmentXML = xmlSubNode.GetNodeList("entertainments>0>entertainment"); for (int j = 0; j < entertainmentXML.Count; j++) { XMLNode entertainmentsXML = entertainmentXML[j] as XMLNode; Entertainment entertainment = new Entertainment(); entertainment.name = entertainmentsXML.GetValue("@name"); entertainment.tag = entertainmentsXML.GetValue("@tag"); entertainment.cost = float.Parse(entertainmentsXML.GetValue("@cost")); entertainment.price = float.Parse(entertainmentsXML.GetValue("@retail")); entertainment.upgradeCost = float.Parse(entertainmentsXML.GetValue("@upgrade")); entertainment.time = float.Parse(entertainmentsXML.GetValue("@time")); entertainment.viability = int.Parse(entertainmentsXML.GetValue("@viability")); entertainment.buyers = int.Parse(entertainmentsXML.GetValue("@buyers")); entertainment.advertisers = int.Parse(entertainmentsXML.GetValue("@advertisers")); // entertainment.priceable = entertainmentsXML.GetValue("@priceable"); entertainments.Add(entertainment); } xmlSubNode = xmlList[SOFTWARES] as XMLNode; XMLNodeList softwareXML = xmlSubNode.GetNodeList("softwares>0>software"); for (int j = 0; j < softwareXML.Count; j++) { XMLNode softwaresXML = softwareXML[j] as XMLNode; Software software = new Software(); software.name = softwaresXML.GetValue("@name"); software.tag = softwaresXML.GetValue("@tag"); software.cost = float.Parse(softwaresXML.GetValue("@cost")); software.price = float.Parse(softwaresXML.GetValue("@retail")); software.upgradeCost = float.Parse(softwaresXML.GetValue("@upgrade")); software.time = float.Parse(softwaresXML.GetValue("@time")); software.viability = int.Parse(softwaresXML.GetValue("@viability")); software.buyers = int.Parse(softwaresXML.GetValue("@buyers")); // software.priceable = softwaresXML.GetValue("@priceable"); softwares.Add(software); } xmlSubNode = xmlList[SERVICES] as XMLNode; XMLNodeList servicesXML = xmlSubNode.GetNodeList("services>0>service"); for (int j = 0; j < servicesXML.Count; j++) { XMLNode serviceXML = servicesXML[j] as XMLNode; Service service = new Service(); service.name = serviceXML.GetValue("@name"); service.tag = serviceXML.GetValue("@tag"); service.cost = float.Parse(serviceXML.GetValue("@cost")); service.price = float.Parse(serviceXML.GetValue("@retail")); service.upgradeCost = float.Parse(serviceXML.GetValue("@upgrade")); service.time = float.Parse(serviceXML.GetValue("@time")); service.viability = int.Parse(serviceXML.GetValue("@viability")); service.buyers = int.Parse(serviceXML.GetValue("@customers")); // service.priceable = serviceXML.GetValue("@priceable"); service.profitMethod = serviceXML.GetValue("@profitMethod"); services.Add(service); } xmlSubNode = xmlList[WORKERS] as XMLNode; XMLNodeList workersXML = xmlSubNode.GetNodeList("workers>0>worker"); for (int j = 0; j < workersXML.Count; j++) { XMLNode workerXML = workersXML[j] as XMLNode; Worker worker = new Worker(); worker.name = workerXML.GetValue("@name"); worker.tag = workerXML.GetValue("@tag"); worker.cost = float.Parse(workerXML.GetValue("@cost")); worker.discipline = workerXML.GetValue("@discipline"); // worker.price = float.Parse(workerXMl.GetValue("@price")); // worker.upgradeCost = float.Parse(workerXMl.GetValue("@cost")); // worker.time = float.Parse(workerXMl.GetValue("@time")); // worker.viability = int.Parse(workerXMl.GetValue("@viability")); // worker.customers = int.Parse(workerXMl.GetValue("@customers")); workers.Add(worker); } xmlSubNode = xmlList[MARKETING] as XMLNode; XMLNodeList marketingXML = xmlSubNode.GetNodeList("marketing>0>tool"); for (int j = 0; j < marketingXML.Count; j++) { XMLNode toolXML = marketingXML[j] as XMLNode; MarketingTool tool = new MarketingTool(); tool.name = toolXML.GetValue("@name"); tool.tag = toolXML.GetValue("@tag"); tool.cost = float.Parse(toolXML.GetValue("@cost")); // tool.price = float.Parse(toolXML.GetValue("@price")); // tool.upgradeCost = float.Parse(toolXML.GetValue("@cost")); // tool.time = float.Parse(toolXML.GetValue("@time")); // tool.viability = int.Parse(toolXML.GetValue("@viability")); // tool.customers = int.Parse(toolXML.GetValue("@customers")); marketingTools.Add(tool); } }
private void CreateButtons() { GameObject g = null; float offsety = -2.4f; float offsetx = 3.81f; productPane = transform.Find("Products/ProductsPane"); entertainmentPane = transform.Find("Entertainment/EntertainmentPane"); servicePane = transform.Find("Services/ServicesPane"); softwarePane = transform.Find("Software/SoftwarePane"); marketingPane = transform.Find("Marketing/MarketingPane"); workersPane = transform.Find("Workers/WorkersPane"); Vector3 topLeft = new Vector3(-8f, 1.3f, 0f); Vector3 piScale = new Vector3(.62f, .62f, 1f); int size = 5; int numberPerColumn = size; for (int i = 0; i < xml.products.Count; i++) { Product item = xml.products[i]; g = Instantiate(Resources.Load("ProductionInterface", typeof(GameObject))) as GameObject; g.transform.parent = productPane; ProductionInterface pi = g.GetComponent <ProductionInterface>(); pi.item = item; pi.product = item; pi.border.GetComponent <MeshRenderer>().material.color = GenerateIncrementedColor(productColor, i, xml.products.Count); pi.border.transform.Find("Edge").gameObject.GetComponent <MeshRenderer>().material.color = new Color(productColor.r * colorEdgeAdjustment, productColor.g * colorEdgeAdjustment, productColor.b * colorEdgeAdjustment, 1f); productsList.Add(pi); float marketingOffsetY = -1.8f; float marketingOffsetx = 3.5f; int col = i % 5; int row = i / 5; g.transform.localPosition = topLeft + new Vector3(col * offsetx, row * offsety, 0f); g.transform.localScale = piScale; } for (int i = 0; i < xml.entertainments.Count; i++) { Entertainment item = xml.entertainments[i]; g = Instantiate(Resources.Load("ProductionInterface", typeof(GameObject))) as GameObject; g.transform.parent = entertainmentPane; ProductionInterface pi = g.GetComponent <ProductionInterface>(); pi.item = item; pi.entertainment = item; pi.border.GetComponent <MeshRenderer>().material.color = GenerateIncrementedColor(entertainmentColor, i, xml.products.Count); pi.border.transform.Find("Edge").gameObject.GetComponent <MeshRenderer>().material.color = new Color(entertainmentColor.r * colorEdgeAdjustment, entertainmentColor.g * colorEdgeAdjustment, entertainmentColor.b * colorEdgeAdjustment, 1f); entertainmentList.Add(pi); float entertainmentOffsetY = -3.3f; float entertainmentOffsetX = 4.7f; int col = i % 4; int row = i / 4; // topLeft = new Vector3(-7f, 1.3f, 0f); // piScale = new Vector3(.8f, .8f, 1f); g.transform.localPosition = new Vector3(-7.7f, 1f, 0f) + new Vector3(col * entertainmentOffsetX, row * entertainmentOffsetY, 0f); g.transform.localScale = new Vector3(.75f, .75f, 1f); } for (int i = 0; i < xml.softwares.Count; i++) { Software item = xml.softwares[i]; g = Instantiate(Resources.Load("ProductionInterface", typeof(GameObject))) as GameObject; g.transform.parent = softwarePane; ProductionInterface pi = g.GetComponent <ProductionInterface>(); pi.border.GetComponent <MeshRenderer>().material.color = GenerateIncrementedColor(softwareColor, i, xml.products.Count);; pi.border.transform.Find("Edge").gameObject.GetComponent <MeshRenderer>().material.color = new Color(softwareColor.r * colorEdgeAdjustment, softwareColor.g * colorEdgeAdjustment, softwareColor.b * colorEdgeAdjustment, 1f); pi.item = item; pi.software = item; softwareList.Add(pi); float softwareOffsetY = -3.3f; float softwareOffsetX = 4.7f; int col = i % 4; int row = i / 4; // piScale = new Vector3(.8f, .8f, 1f); g.transform.localPosition = new Vector3(-7.7f, 1f, 0f) + new Vector3(col * softwareOffsetX, row * softwareOffsetY, 0f); g.transform.localScale = new Vector3(.75f, .75f, 1f); } for (int i = 0; i < xml.services.Count; i++) { Service item = xml.services[i]; g = Instantiate(Resources.Load("ProductionInterface", typeof(GameObject))) as GameObject; g.transform.parent = servicePane; ProductionInterface pi = g.GetComponent <ProductionInterface>(); pi.item = item; pi.service = item; pi.border.GetComponent <MeshRenderer>().material.color = GenerateIncrementedColor(serviceColor, i, xml.products.Count);; pi.border.transform.Find("Edge").gameObject.GetComponent <MeshRenderer>().material.color = new Color(serviceColor.r * colorEdgeAdjustment, serviceColor.g * colorEdgeAdjustment, serviceColor.b * colorEdgeAdjustment, 1f); servicesList.Add(pi); // float marketingOffsetY = -1.8f; // float marketingOffsetx = 3.5f; int col = i % 5; int row = i / 5; int imod = i % size; g.transform.localPosition = topLeft + new Vector3(col * offsetx, row * offsety, 0f); g.transform.localScale = piScale; } for (int i = 0; i < xml.workers.Count; i++) { Worker xmlWorker = xml.workers[i]; g = Instantiate(Resources.Load("WorkerInterface", typeof(GameObject))) as GameObject; switch (xmlWorker.discipline) { case "products": g.transform.parent = workersPane.Find("ProductWorkers"); break; case "marketing": g.transform.parent = workersPane.Find("MarketingWorkers"); break; case "entertainment": g.transform.parent = workersPane.Find("EntertainmentWorkers"); break; case "software": g.transform.parent = workersPane.Find("SoftwareWorkers"); break; case "services": g.transform.parent = workersPane.Find("ServicesWorkers"); break; default: break; } WorkerInterface wi = g.GetComponent <WorkerInterface>(); wi.worker = xmlWorker; workersList.Add(wi); float workerOffset = -1.15f; g.transform.localPosition = new Vector3(0f, (g.transform.parent.childCount - 1) * workerOffset, 0f); g.transform.localScale = new Vector3(1.05f, 1.05f, 1f); } for (int i = 0; i < xml.marketingTools.Count; i++) { MarketingTool item = xml.marketingTools[i]; g = Instantiate(Resources.Load("MarketingInterface", typeof(GameObject))) as GameObject; g.transform.parent = marketingPane; MarketingInterface mi = g.GetComponent <MarketingInterface>(); mi.marketing = item; // mi.border.GetComponent<MeshRenderer>().material.color = GenerateIncrementedColor(marketingColor, i, xml.products.Count);; // mi.border.transform.Find("Edge").gameObject.GetComponent<MeshRenderer>().material.color = new Color(marketingColor.r * colorEdgeAdjustment, marketingColor.g * colorEdgeAdjustment, marketingColor.b * colorEdgeAdjustment, 1f); marketingList.Add(mi); float marketingOffsetY = -1.8f; float marketingOffsetx = 3.8f; int col = i % 5; int row = i / 5; // int imod = i % size; // topLeft = new Vector3(-7.2f, 1.5f, -2f); g.transform.localPosition = new Vector3(-7.7f, 1.5f, 0f) + new Vector3(col * marketingOffsetx, row * marketingOffsetY, 0f); g.transform.localScale = new Vector3(1.3f, 1.3f, 1f); } }