public override void Open() { base.Open(); StorageBuilding sb = (StorageBuilding)obj; for (int a = 0; a < sb.NumOfTotalTypes; a++) { uiObjectDatabase = obj.UIObjects; //for simple grid if (sb.Inventory[a] > 0 && simpleInventoryGrid != null) { GameObject g1 = Instantiate(uiObjectDatabase.storageItem_smpl); g1.transform.SetParent(simpleInventoryGrid.transform); StorageItem_smpl s = g1.GetComponent <StorageItem_smpl>(); s.sb = sb; s.index = a; noItems.SetActive(false); } //entry in advanced grid GameObject g2 = Instantiate(uiObjectDatabase.storageItem_adv); g2.transform.SetParent(advancedInventoryGrid.transform); StorageItem_adv si = g2.GetComponent <StorageItem_adv>(); si.index = a; si.sb = sb; } }
public void ShowActions(string bt) { foreach (Transform child in actionsGrid.transform) { Destroy(child.gameObject); } int index = (int)Enums.categoryDict[bt]; Dictionary <Action, bool> dict = actionList[index]; //for each action in dictionary foreach (Action a in dict.Keys) { //if action is enabled, create the button if (!dict[a]) { continue; } //instantiate object and set parent to category menu GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ActionButton")); go.transform.SetParent(actionsGrid.transform); go.transform.localScale = new Vector3(1, 1, 1); //set action and actioncontroller for button ActionButton ab = go.GetComponent <ActionButton>(); ab.act = a; ab.actionController = actionController; } actionsMenu.OpenMenu(); //((RectTransform)(actionsGrid.transform)).offsetMin = new Vector2(0, 0); }
public override void UpdateOverviewPage() { base.UpdateOverviewPage(); Jobcentre jc = (Jobcentre)obj; //update prospect list ONLY if there's different # of prospects than before if (prospectGrid.childCount == jc.Prospects.Count) { return; } foreach (Transform child in prospectGrid) { Destroy(child.gameObject); } //instantiate worker list foreach (Prole p in jc.Prospects) { if (p == null) { continue; } GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ProspectInfo")); go.transform.SetParent(prospectGrid); ProspectInfo pi = go.GetComponent <ProspectInfo>(); pi.prospect = p; pi.jobcentre = jc; } }
public void LoadScenarioButtons() { Campaign cmpgn = CampaignManager.campaigns[campaignName]; //generate buttons for individual saves for (int x = 0; x < cmpgn.levels.Count; x++) { GameFile gf = cmpgn.levels[x]; gf.loadFromResources = true; GameObject b = Instantiate(UIObjectDatabase.GetUIElement("Scenario")); b.transform.parent = grid.transform; b.transform.localScale = new Vector3(1, 1, 1); b.name = "Button_" + gf.filename; LoadScenarioButton sc = b.GetComponent <LoadScenarioButton>(); sc.Datapath = gf; sc.CampaignName = campaignName; sc.Level = x; Button bttn = b.GetComponent <Button>(); bttn.interactable = x <= cmpgn.spot; } label.text = campaignName; saveListGenerator.fileLocation = campaignName; saveListGenerator.LoadSaves(); //reset scrollbar to top sb.value = 1; }
public void LoadSaves() { //generate buttons for individual saves string datapath = Application.persistentDataPath + "/"; if (!Directory.Exists(datapath + fileLocation)) { Directory.CreateDirectory(datapath + fileLocation); } foreach (string f in Directory.GetFiles(datapath + fileLocation)) { string fileName = Path.GetFileNameWithoutExtension(f); GameObject go = Instantiate(UIObjectDatabase.GetUIElement("SavedGame")); go.transform.parent = grid.transform; go.transform.localScale = new Vector3(1, 1, 1); go.name = "Button_" + f; LoadGameFileButton b = go.GetComponent <LoadGameFileButton>(); b.Datapath = new GameFile(mode, fileLocation, fileName, false); b.Deletable = canDeleteFiles; } //reset scrollbar to top sb.value = 1; }
void CreateGoalList() { //add housing goal to level info if (scenario.HasHouseGoal) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ScenarioGoal")); ScenarioGoal sg = go.GetComponent <ScenarioGoal>(); sg.goalDesc.text = scenario.HousingGoalToString(); sg.toggle.isOn = scenario.HousingComplete; sg.transform.SetParent(gridThing.transform); sg.transform.localScale = new Vector3(1, 1, 1); } //add pop goal if (scenario.HasPopGoal) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ScenarioGoal")); ScenarioGoal sg = go.GetComponent <ScenarioGoal>(); sg.goalDesc.text = scenario.PopulationToString(); sg.toggle.isOn = scenario.PopulationComplete; sg.transform.SetParent(gridThing.transform); sg.transform.localScale = new Vector3(1, 1, 1); } //add prosperity goal if (scenario.HasProspGoal) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ScenarioGoal")); ScenarioGoal sg = go.GetComponent <ScenarioGoal>(); sg.goalDesc.text = scenario.ProsperityToString(); sg.toggle.isOn = scenario.ProsperityComplete; sg.transform.SetParent(gridThing.transform); sg.transform.localScale = new Vector3(1, 1, 1); } if (scenario.HasStorageGoals) { List <string> storageGoals = scenario.goals.storageGoals; for (int i = 0; i < storageGoals.Count; i++) { ItemOrder io = new ItemOrder(storageGoals[i]); GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ScenarioGoal")); ScenarioGoal sg = go.GetComponent <ScenarioGoal>(); sg.goalDesc.text = scenario.StorageGoalToString(i); sg.toggle.isOn = scenario.worldController.HasGood(io); sg.transform.SetParent(gridThing.transform); sg.transform.localScale = new Vector3(1, 1, 1); } } }
public void CreateWorkplaceElement(Workplace w) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("WorkplaceListItem")); go.transform.SetParent(grid.transform); WorkplaceListItem element = go.GetComponent <WorkplaceListItem>(); element.Building = w; }
public void OpenCity(City c) { CloseCity(); CurrentCity = c; if (c == null) { Debug.LogError("Tried to open null city"); } cityName.text = CurrentCity.name; cityMenu.OpenMenu(cityPage); diploMenu.OpenMenu(); exports = c.GetPossibleExports(); foreach (ItemOrder export in exports) { //don't allow trade if item is not whitelisted if (!ResourcesDatabase.ItemAllowed(export.GetItemName())) { continue; } GameObject deal = Instantiate(UIObjectDatabase.GetUIElement("TradeDeal")); deal.transform.SetParent(exportsGrid.transform); TradeDeal td = deal.GetComponent <TradeDeal>(); td.order = export; td.trade = tradeController; td.diplo = this; } imports = c.GetPossibleImports(); foreach (ItemOrder import in imports) { //don't allow trade if item is not whitelisted if (!ResourcesDatabase.ItemAllowed(import.GetItemName())) { continue; } GameObject deal = Instantiate(UIObjectDatabase.GetUIElement("TradeDeal")); deal.transform.SetParent(importsGrid.transform); TradeDeal td = deal.GetComponent <TradeDeal>(); td.order = import; td.trade = tradeController; td.diplo = this; } }
public void CreateWorkerListElement(Prole p, Workplace wp) { if (p == null) { return; } GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ProleInfo")); go.transform.SetParent(proleGrid); ProleInfo pi = go.GetComponent <ProleInfo>(); pi.Employee = p; pi.WP = wp; }
private void Start() { if (noCities != null) { noCities.SetActive(cities.Count == 0); } foreach (City c in cities) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("CityButton")); go.transform.SetParent(cityGrid.transform); go.transform.localScale = new Vector3(1, 1, 1); CityButton cb = go.GetComponent <CityButton>(); cb.city = c; cb.diplomacy = this; cb.diploScreen = diploScreen; } }
// Use this for initialization void Start() { List <string> items = Enums.GetAllItems(); foreach (string item in items) { if (!ResourcesDatabase.ItemAllowed(item)) { continue; } GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ItemValueUI")); go.transform.SetParent(grid.transform); ItemValueUI iv = go.GetComponent <ItemValueUI>(); iv.ItemName = item; iv.Tooltip = tooltip; } }
public void LoadActionEnablers() { for (int x = 0; x < actionList.Count; x++) { Dictionary <Action, bool> dict = actionList[x]; //for each action in dictionary foreach (Action a in dict.Keys) { GameObject go = Instantiate(UIObjectDatabase.GetUIElement("ActionEnabler")); go.transform.SetParent(enableMenuGrid.transform); go.transform.localScale = new Vector3(1, 1, 1); ActionEnabler ae = go.GetComponent <ActionEnabler>(); ae.Action = a; ae.Category = x; ae.ActionSelecter = this; ae.ListIndex = x; } } }
public void LoadFinancialReports() { DeleteFinancialReports(); GameObject g = Instantiate(UIObjectDatabase.GetUIElement("QuarterlyReport")); QuarterlyReport currentReport = g.GetComponent <QuarterlyReport>(); currentReport.PrintReport(moneyController.CurrentQuarter); g.transform.SetParent(grid.transform); CurrentQuarter = currentReport; Quarter[] prev = moneyController.pastQuarters.quarters; for (int i = moneyController.pastQuarters.currentIndex - 1; i > -1; i--) { Quarter q = prev[i]; GameObject go = Instantiate(UIObjectDatabase.GetUIElement("QuarterlyReport")); QuarterlyReport qr = go.GetComponent <QuarterlyReport>(); qr.PrintReport(q); go.transform.SetParent(grid.transform); } }
public void NewNotification(Notification n) { if (eventListGrid == null) { return; } Events.Add(n); GameObject go = Instantiate(UIObjectDatabase.GetUIElement("NotificationListItem")); go.transform.SetParent(eventListGrid.transform); go.transform.SetAsFirstSibling(); go.transform.localScale = new Vector3(1, 1, 1); NotificationUI listitem = go.GetComponent <NotificationUI>(); listitem.gameObject.SetActive(true); listitem.Controller = this; listitem.Event = n; listitem.Index = Events.Count - 1; listitem.PrintEvent(true); listitem.Camera = cameraController; listitem.CityMenu = cityMenu; listitem.NotificationMenu = notificationMenu; NotificationUI banner = buttons[(int)n.type]; notificationMenu.OpenMenu(banner.gameObject); banner.NotificationMenu = notificationMenu; banner.CityMenu = cityMenu; banner.Event = n; banner.Camera = cameraController; banner.PrintEvent(false); bannerDisplayTime = 24; UpdateBanner(); }
public override void OpenWindow() { OpenWindow(UIObjectDatabase.GetUIElement("WorkplaceWindow")); }
public override void Open() { base.Open(); StorageBuilding sb = (StorageBuilding)obj; ItemType type = sb.typeStored; string[] items = new string[0]; int length = 0; switch (type) { case ItemType.Food: length = (int)FoodType.END; items = new string[length]; Enums.foodDict.Keys.CopyTo(items, 0); break; case ItemType.Good: length = (int)GoodType.END; items = new string[length]; Enums.goodDict.Keys.CopyTo(items, 0); break; case ItemType.Resource: length = (int)ResourceType.END; items = new string[length]; Enums.resourceDict.Keys.CopyTo(items, 0); break; } List <string> sorted = new List <string>(items); sorted.Sort(); foreach (string item in sorted) { if (!ResourcesDatabase.ItemAllowed(item)) { continue; } Node n = Enums.GetItemData(item); int index = n.x; ////for simple grid //if (sb.Inventory[index] > 0) { // GameObject g1 = Instantiate(storageitem_smpl); // g1.transform.SetParent(simpleInventoryGrid.transform); // StorageItem_smpl s = g1.GetComponent<StorageItem_smpl>(); // s.sb = sb; // s.index = index; // noItems.SetActive(false); //} //entry in advanced grid GameObject g2 = Instantiate(UIObjectDatabase.GetUIElement("StorageItem_adv")); g2.transform.SetParent(advancedInventoryGrid); StorageItem_adv si = g2.GetComponent <StorageItem_adv>(); si.index = index; si.sb = sb; } }
public override void OpenWindow() { OpenWindow(UIObjectDatabase.GetUIElement("GeneratorWindow")); }
public override void OpenWindow() { OpenWindow(UIObjectDatabase.GetUIElement("StorageWindow")); }
public virtual void OpenWindow() { OpenWindow(UIObjectDatabase.GetUIElement("ObjWindow")); }