void Start() { try { db = GameObject.Find("Database").GetComponent <Database>(); dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); dm.dispensary.inventory = this; } catch (NullReferenceException) { } }
public List <AvailableComponent> GetAvailableComponents() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); Dispensary dispensary = dm.dispensary; List <AvailableComponent> availableComponents = new List <AvailableComponent>(); int storageCount = dispensary.GetStorageCount(); if ((storageCount + 1) < dispensary.maxStorageCount) { storageCount++; availableComponents.Add(new AvailableComponent("Storage", (storageCount == 0) ? 6500 : (storageCount == 1) ? 14000 : 25000)); // Price for components where the number is limited but greater than 1 will increase with each purchase } int growCount = dispensary.GetGrowroomCount(); if ((growCount + 1) < dispensary.maxGrowroomCount) { growCount++; availableComponents.Add(new AvailableComponent("Growroom", (growCount == 0) ? 25000 : (growCount == 1) ? 60000 : 125000)); // Price for components where the number is limited but greater than 1 will increase with each purchase } int processingCount = dispensary.GetProcessingCount(); if ((processingCount + 1) < dispensary.maxProcessingCount) { processingCount++; availableComponents.Add(new AvailableComponent("Processing", (processingCount == 0) ? 25000 : (processingCount == 1) ? 60000 : 125000)); // Price for components where the number is limited but greater than 1 will increase with each purchase } int hallwayCount = dispensary.GetHallwayCount(); if ((hallwayCount + 1) < dispensary.maxHallwayCount) { hallwayCount++; availableComponents.Add(new AvailableComponent("Hallway", (hallwayCount == 0) ? 5000 : (hallwayCount == 1) ? 6000 : (hallwayCount == 2) ? 7500 : (hallwayCount == 3) ? 10000 : (hallwayCount == 4) ? 15000 : 22500)); // Price for components where the number is limited but greater than 1 will increase with each purchase } foreach (string comp in dispensary.absentComponents) { switch (comp) { case "GlassShop": availableComponents.Add(new AvailableComponent("GlassShop", 30000)); break; case "SmokeLounge": availableComponents.Add(new AvailableComponent("SmokeLounge", 10000)); break; case "Workshop": availableComponents.Add(new AvailableComponent("Workshop", 30000)); break; } } return(availableComponents); }
void Awake() { try { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); StoreObject storeObj = GetComponent <StoreObject>(); objectID = storeObj.objectID; subID = storeObj.subID; } catch (NullReferenceException) { } }
void Start() { try { pathfinding = gameObject.GetComponent <DeliveryDriverPathfinding>(); GameObject managers = GameObject.Find("DispensaryManager"); dm = managers.GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); } catch (NullReferenceException) { } }
void Awake() { try { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); ui = GameObject.Find("MenuManager").GetComponent <UIManager_v2>(); } catch (NullReferenceException) { //do nothing, mm_v2 catches it } }
public void Setup(float nodeRadius_, int[,] tileIDs) { if (dm == null || db == null) { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); } nodeRadius = nodeRadius_; nodeDiameter = nodeRadius_ * 2; gridWorldSize.x = gridSizeX * nodeDiameter; gridWorldSize.y = gridSizeY * nodeDiameter; CreateGrid(tileIDs); }
public void CreateOrderPresetList() { Start(); DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <OrderPreset> orders = dm.currentCompany.GetOrderPresets(vendor.vendorName); if (orders != null) { if (orders.Count == 0) { noPresetsText.gameObject.SetActive(true); } else { noPresetsText.gameObject.SetActive(false); } foreach (OrderPresetDisplayObject disp in displayedPresetObjects) { Destroy(disp.gameObject); } displayedPresetObjects.Clear(); //orders = SortList(panel.sortMode, vendors); RectTransform rectTransform = orderPresetContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = orderPresetPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = orders.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); rectTransform.sizeDelta = new Vector2(orderPresetContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < orders.Count; i++) { Image orderPresetGO = Instantiate(orderPresetPrefab); Button[] buttonComponents = orderPresetGO.GetComponentsInChildren <Button>(); int temp = i; OrderPreset order = orders[temp]; buttonComponents[0].onClick.AddListener(() => LoadOrderFormPreset(order)); Text[] textComponents = orderPresetGO.GetComponentsInChildren <Text>(); textComponents[0].text = orders[i].presetName; orderPresetGO.transform.SetParent(orderPresetContentPanel.transform.parent, false); orderPresetGO.gameObject.SetActive(true); orderPresetGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); OrderPresetDisplayObject orderDisplayObject = orderPresetGO.gameObject.AddComponent <OrderPresetDisplayObject>(); displayedPresetObjects.Add(orderDisplayObject); //newStaffDisplayObject } foreach (OrderPresetDisplayObject obj in displayedPresetObjects) { obj.transform.SetParent(orderPresetContentPanel.transform); } } }
void Start() { try { GameObject manager = GameObject.Find("DispensaryManager"); dm = manager.GetComponent <DispensaryManager>(); uiManager = manager.GetComponent <UIManager_v1>(); uiManager.UpdateMoney(money); noCost = true; } catch (NullReferenceException) { } }
void Awake() { try { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); h = gameObject.AddComponent <Highlighter>(); functionHandler = gameObject.GetComponent <StoreObjectFunction_Handler>(); modifierHandler = gameObject.GetComponent <StoreObjectModifier_Handler>(); //GetOnPlace(); } catch (Exception ex) { //print("Probably in test scene"); } }
void Start() { try { dm = gameObject.GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); uiManager = GameObject.Find("UIManager").GetComponent <UIManager_v5>(); originalPos = cam.transform.position; originalRot = cam.transform.eulerAngles; state = CameraState.Exterior; } catch (NullReferenceException) { } }
public void Setup(Vector2 dimensions, float nodeRadius_, int[,] tileIDs) { if (dm == null || db == null) { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); } nodeRadius = nodeRadius_; nodeDiameter = nodeRadius_ * 2; gridWorldSize.x = dimensions.x * 10; gridWorldSize.y = dimensions.y * 10; gridSizeX = Mathf.RoundToInt(gridWorldSize.x / nodeDiameter); gridSizeY = Mathf.RoundToInt(gridWorldSize.y / nodeDiameter); CreateGrid(tileIDs); }
public void CreateVendorList() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <Vendor_s> vendors_s = dm.currentCompany.hiredVendors; List <Vendor> vendors = new List <Vendor>(); if (vendors_s != null) { foreach (Vendor_s vendor_s in vendors_s) { vendors.Add(database.GetVendor(vendor_s.vendorName)); } vendorScrollbar.value = 1; foreach (VendorDisplayObject disp in vendorDisplayedObjects) { Destroy(disp.gameObject); } vendorDisplayedObjects.Clear(); //vendors = SortList(panel.sortMode, vendors); RectTransform rectTransform = vendorContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = vendorDisplayPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = vendors.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); rectTransform.sizeDelta = new Vector2(vendorContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < vendors.Count; i++) { Image vendorDisplayGO = Instantiate(vendorDisplayPrefab); Button[] buttonComponents = vendorDisplayGO.GetComponentsInChildren <Button>(); Vendor vendor = vendors[i]; buttonComponents[0].onClick.AddListener(() => ViewSelection(vendor)); buttonComponents[1].onClick.AddListener(() => FireVendor(vendor)); Text[] textComponents = vendorDisplayGO.GetComponentsInChildren <Text>(); textComponents[0].text = vendors[i].vendorName; vendorDisplayGO.transform.SetParent(vendorContentPanel.transform.parent, false); vendorDisplayGO.gameObject.SetActive(true); vendorDisplayGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); VendorDisplayObject vendorDisplayObject = vendorDisplayGO.gameObject.AddComponent <VendorDisplayObject>(); vendorDisplayedObjects.Add(vendorDisplayObject); //newStaffDisplayObject } foreach (VendorDisplayObject obj in vendorDisplayedObjects) { obj.transform.SetParent(vendorContentPanel.transform); } } }
public void CreateList_StaffWindow(string search) // list will be List<Staff> when making functional { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <Staff_s> staff = dm.dispensary.allStaff; staffScrollbar.value = 1; foreach (StaffDisplayObject disp in displayedObjects) { Destroy(disp.gameObject); } displayedObjects.Clear(); if (search != string.Empty) { staff = SearchStaffList(staff, search); } if (!window.searchBar.ignoreFilters) { staff = FilterStaffList(staff); } staff = SortStaffList(window.sortMode, staff); RectTransform rectTransform = staffContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = staffDisplayPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = staff.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); rectTransform.sizeDelta = new Vector2(staffContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < staff.Count; i++) { Staff_s staff_s = staff[i]; StaffDisplayObject newStaffDisplay = Instantiate(staffDisplayPrefab); newStaffDisplay.staff = staff_s; newStaffDisplay.staffNameText.text = staff[i].staffName; newStaffDisplay.jobDisplay.SetJobType(staff_s.jobType); newStaffDisplay.jobDisplay.staff = staff_s; Rect newStaffDisplayRect = newStaffDisplay.GetComponent <RectTransform>().rect; newStaffDisplay.gameObject.transform.SetParent(staffContentPanel.transform.parent, false); newStaffDisplay.gameObject.SetActive(true); newStaffDisplay.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * i); displayedObjects.Add(newStaffDisplay); //newStaffDisplayObject } foreach (StaffDisplayObject obj in displayedObjects) { obj.transform.SetParent(staffContentPanel.transform); } }
void Start() { try { h = gameObject.GetComponent <Highlighter>(); GameObject managers = GameObject.Find("DispensaryManager"); db = GameObject.Find("Database").GetComponent <Database>(); dm = managers.GetComponent <DispensaryManager>(); cm = managers.GetComponent <CustomerManager>(); //pathfinding.currentGrid = GameObject.Find ("Dispensary").GetComponentInChildren<ComponentGrid>(); } catch (NullReferenceException) { print("Customer, DB , or Dispensary is Null - Customer.cs"); } }
void Start() { try { h = gameObject.GetComponent <Highlighter>(); pathfinding = gameObject.GetComponent <StaffPathfinding>(); job = null; GameObject managers = GameObject.Find("DispensaryManager"); dm = managers.GetComponent <DispensaryManager>(); sm = managers.GetComponent <StaffManager>(); pathfinding.currentGrid = GameObject.Find("Dispensary").GetComponentInChildren <ComponentGrid>(); } catch (NullReferenceException) { print("Customer, DB , or Dispensary is Null - Customer.cs"); } }
public List <CompatibleObject> GetComponentObjects() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); Dispensary dispensary = dm.dispensary; string component = dispensary.GetSelected(); if (component == string.Empty) { } List <CompatibleObject> objects = new List <CompatibleObject>(); foreach (StoreObjectReference obj in dm.database.GetComponentObjects(dispensary.GetSelected())) { objects.Add(new CompatibleObject(obj.productName, obj.gameObject_, obj.objectID, 100)); } return(objects); }
public void SetupGrid(Vector2 dimensions) { if (dm == null) { Start(); } //gameObject.transform.localPosition = new Vector3 (0, 0, 0); dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); planePrefab = dm.gridPlanePrefab; nodeDiameter = nodeRadius * 2; gridWorldSize.x = dimensions.x * 10; gridWorldSize.y = dimensions.y * 10; width = gridWorldSize.x; length = gridWorldSize.y; gridSizeX = Mathf.RoundToInt(gridWorldSize.x / nodeDiameter); gridSizeY = Mathf.RoundToInt(gridWorldSize.y / nodeDiameter); CreateGrid(); }
public void Select() { selected = true; if (!InBox()) { PlayOpenAnimation(); } try { GetProductGO().HighlightOn(Color.green); } catch (System.NullReferenceException) { DispensaryManager temp = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); temp.Tempprint("Didnt highlight"); // dont highlight a product that doesnt exist } }
void Start() { try { cam = Camera.main; state = CameraState.zoomedOut_Exterior; dm = gameObject.GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); uiManager = GameObject.Find("UIManager").GetComponent <UIManager_v5>(); zoomedOut_ExteriorState = new PreviousCameraState(state, cam.transform.position, cam.transform.eulerAngles, dm.dispensary.gameObject.transform.position); zoomedOut_InteriorState = new PreviousCameraState(); zoomedInState = new PreviousCameraState(); preFocusState = new PreviousCameraState(); } catch (NullReferenceException) { // Main menu } }
public void CreateOrderList() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <Order> orders = dm.dispensary.GetOrders(); if (orders != null) { orderScrollbar.value = 1; foreach (OrderDisplayObject disp in orderDisplayedObjects) { Destroy(disp.gameObject); } orderDisplayedObjects.Clear(); //orders = SortList(panel.sortMode, vendors); RectTransform rectTransform = orderContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = orderDisplayPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = orders.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); rectTransform.sizeDelta = new Vector2(orderContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < orders.Count; i++) { Image orderDisplayGO = Instantiate(orderDisplayPrefab); Button[] buttonComponents = orderDisplayGO.GetComponentsInChildren <Button>(); Order order = orders[i]; buttonComponents[0].onClick.AddListener(() => dm.uiManagerObject.GetComponent <UIManager_v3>().CreateOrderPreviewPanel(order)); buttonComponents[1].onClick.AddListener(() => DeleteOrder(order)); Text[] textComponents = orderDisplayGO.GetComponentsInChildren <Text>(); textComponents[0].text = orders[i].orderName; orderDisplayGO.transform.SetParent(orderContentPanel.transform.parent, false); orderDisplayGO.gameObject.SetActive(true); orderDisplayGO.rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); OrderDisplayObject orderDisplayObject = orderDisplayGO.gameObject.AddComponent <OrderDisplayObject>(); orderDisplayedObjects.Add(orderDisplayObject); //newStaffDisplayObject } foreach (OrderDisplayObject obj in orderDisplayedObjects) { obj.transform.SetParent(orderContentPanel.transform); } } }
public void OnPlace() // Moves the windows into a better position, after performing the raycasts { foreach (Window window in windows) { window.gameObject.layer = 20; DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); //string side = dm.DetermineSide(new Vector2(window.gridIndex.x, window.gridIndex.y), grid.gameObject.name); switch (side) { case "Left": Vector3 currentLPos = window.gameObject.transform.position; Vector3 newLPos = new Vector3(currentLPos.x, currentLPos.y, currentLPos.z + grid.nodeRadius * 1.05f); Vector3 newLEulers = new Vector3(0, 180, 0); window.gameObject.transform.position = newLPos; window.gameObject.transform.eulerAngles = newLEulers; break; case "Right": Vector3 currentRPos = window.gameObject.transform.position; Vector3 newRPos = new Vector3(currentRPos.x, currentRPos.y, currentRPos.z - grid.nodeRadius * 1.05f); Vector3 newREulers = new Vector3(0, 0, 0); window.gameObject.transform.position = newRPos; window.gameObject.transform.eulerAngles = newREulers; break; case "Top": Vector3 currentTPos = window.gameObject.transform.position; Vector3 newTPos = new Vector3(currentTPos.x + grid.nodeRadius * 1.05f, currentTPos.y, currentTPos.z); Vector3 newTEulers = new Vector3(0, 270, 0); window.gameObject.transform.position = newTPos; window.gameObject.transform.eulerAngles = newTEulers; break; case "Bottom": Vector3 currentBPos = window.gameObject.transform.position; Vector3 newBPos = new Vector3(currentBPos.x - grid.nodeRadius * 1.05f, currentBPos.y, currentBPos.z); Vector3 newBEulers = new Vector3(0, 90, 0); window.gameObject.transform.position = newBPos; window.gameObject.transform.eulerAngles = newBEulers; break; } } }
public void SpawnCustomer() // Command to spawn one customer, at the closest spawn location { float distance = 10000; Vector3 spawnLocation = Vector3.zero; foreach (GameObject obj in customerSpawnLocations) { DispensaryManager dispensaryManager = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); float newDistance = Vector3.Distance(obj.transform.position, dispensaryManager.dispensary.Main_c.GetRandomEntryDoor().transform.position); if (newDistance < distance) { distance = newDistance; spawnLocation = obj.transform.position; } } float randomTwoGender_value = UnityEngine.Random.value; string customerName = (randomTwoGender_value > .5) ? db.GetRandomFullName(true) : db.GetRandomFullName(false); GameObject customer = Instantiate(customerModel); customer.name = "Customer: " + customerName; customer.transform.position = spawnLocation; try { customer.transform.parent = customersParent.transform; } catch (Exception) { CreateCustomerParentObject(); customer.transform.parent = customersParent.transform; } Customer customerComponent = customer.GetComponent <Customer>(); customerComponent.uniqueID = Dispensary.GetUniqueCustomerID(); Dispensary.GetUniqueCustomersInStoreCount(); // increments the in-store value customerComponent.customerName = customerName; customerComponent.OnSpawn(true); customers.Add(customerComponent); }
public void SetPurchaseButtonCallback(Button button, string component, float money) { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); Dispensary dispensary = dm.dispensary; switch (component) { case "Storage": button.onClick.AddListener(() => dm.AddStorageComponent(dispensary.GetStorageCount() + 1, money)); break; case "GlassShop": button.onClick.AddListener(() => dm.AddGlassShopComponent(money)); break; case "SmokeLounge": button.onClick.AddListener(() => dm.AddSmokeLoungeComponent(money)); break; case "Workshop": button.onClick.AddListener(() => dm.AddWorkshopComponent(money)); break; case "Growroom": button.onClick.AddListener(() => dm.AddGrowroomComponent(dispensary.GetGrowroomCount() + 1, money)); break; case "Processing": button.onClick.AddListener(() => dm.AddProcessingComponent(dispensary.GetProcessingCount() + 1, money)); break; case "Hallway": button.onClick.AddListener(() => dm.AddHallwayComponent(dispensary.GetHallwayCount() + 1, money)); break; } }
public void SetButtonCallback(Button button, CompatibleObject obj) { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); Dispensary dispensary = dm.dispensary; //button.onClick.AddListener(() => dm.CreateObject(obj.gObj, obj.ID)); }
void Start() { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); database = GameObject.Find("Database").GetComponent <Database>(); PopulateDropdowns(); }
public void OnPlace() { DispensaryManager dm = GetStoreObject().dm; if (!BuildActivatedShelves()) { BuildDefaultShelves(); } RaycastHit[] hits = Physics.RaycastAll(transform.position + new Vector3(0, 2, 0), Vector3.down); string component = string.Empty; int subGridIndex = -1; if (hits.Length > 0) { foreach (RaycastHit hit in hits) { if (hit.transform.tag == "Floor") { FloorTile tile = hit.transform.GetComponent <FloorTile>(); component = tile.gameObject.name; StoreObject storeObj = GetStoreObject(); storeObj.gridIndex = new Vector2(tile.gridX, tile.gridY); subGridIndex = tile.subGridIndex; } } } if (component == string.Empty) { component = dm.dispensary.GetSelected(); } StoreObject obj = GetStoreObject(); switch (component) { case "MainStore": case "MainStoreComponent": dm.dispensary.Main_c.AddStoreObject(obj); obj.grid = dm.dispensary.Main_c.grid.GetSubGrid(subGridIndex); break; case "Storage0": case "StorageComponent0": dm.dispensary.Storage_cs[0].AddStoreObject(obj); obj.grid = dm.dispensary.Storage_cs[0].grid.GetSubGrid(subGridIndex); break; case "Storage1": case "StorageComponent1": dm.dispensary.Storage_cs[1].AddStoreObject(obj); obj.grid = dm.dispensary.Storage_cs[1].grid.GetSubGrid(subGridIndex); break; case "Storage2": case "StorageComponent2": dm.dispensary.Storage_cs[2].AddStoreObject(obj); obj.grid = dm.dispensary.Storage_cs[2].grid.GetSubGrid(subGridIndex); break; case "SmokeLounge": case "SmokeLoungeComponent": dm.dispensary.Lounge_c.AddStoreObject(obj); obj.grid = dm.dispensary.Lounge_c.grid.GetSubGrid(subGridIndex); break; } foreach (BoxCollider col in gameObject.transform.GetComponents <BoxCollider>()) { col.gameObject.layer = 19; } }
public void OnPlace() { ResetPosition(true); PerformRaycast(); gameObject.layer = 19; DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); RaycastHit[] hits = Physics.RaycastAll(transform.position + new Vector3(0, 2, 0), Vector3.down); // Let the component know its here string component = string.Empty; int subGridIndex = -1; if (hits.Length > 0) { foreach (RaycastHit hit in hits) { if (hit.transform.tag == "Floor") { FloorTile tile = hit.transform.GetComponent <FloorTile>(); component = tile.gameObject.name; //StoreObject storeObj = GetStoreObject(); //storeObj.gridIndex = new Vector2(tile.gridX, tile.gridY); //subGridIndex = tile.subGridIndex; } } } if (component == string.Empty) { component = dm.dispensary.GetSelected(); } StoreObject obj = GetStoreObject(); switch (component) { case "MainStore": case "MainStoreComponent": dm.dispensary.Main_c.AddStoreObject(obj); break; case "Storage0": case "StorageComponent0": dm.dispensary.Storage_cs[0].AddStoreObject(obj); break; case "Storage1": case "StorageComponent1": dm.dispensary.Storage_cs[1].AddStoreObject(obj); break; case "Storage2": case "StorageComponent2": dm.dispensary.Storage_cs[2].AddStoreObject(obj); break; case "SmokeLounge": case "SmokeLoungeComponent": dm.dispensary.Lounge_c.AddStoreObject(obj); break; } string side = dm.DetermineSide(obj.gridIndex, obj.grid.subGridIndex, mainComponent); switch (side) { case "Left": Vector3 currentLPos = gameObject.transform.position; Vector3 newLPos = new Vector3(currentLPos.x, currentLPos.y, currentLPos.z + obj.grid.nodeRadius * 1.25f); Vector3 newLEulers = new Vector3(0, 270, 0); //gameObject.transform.position = newLPos; gameObject.transform.eulerAngles = newLEulers; break; case "Right": Vector3 currentRPos = gameObject.transform.position; Vector3 newRPos = new Vector3(currentRPos.x, currentRPos.y, currentRPos.z - obj.grid.nodeRadius * 1.25f); Vector3 newREulers = new Vector3(0, 90, 0); //gameObject.transform.position = newRPos; gameObject.transform.eulerAngles = newREulers; break; case "Top": Vector3 currentTPos = gameObject.transform.position; Vector3 newTPos = new Vector3(currentTPos.x + obj.grid.nodeRadius * 1.25f, currentTPos.y, currentTPos.z); Vector3 newTEulers = new Vector3(0, 0, 0); //gameObject.transform.position = newTPos; gameObject.transform.eulerAngles = newTEulers; break; case "Bottom": Vector3 currentBPos = gameObject.transform.position; Vector3 newBPos = new Vector3(currentBPos.x - obj.grid.nodeRadius * 1.25f, currentBPos.y, currentBPos.z); Vector3 newBEulers = new Vector3(0, 180, 0); //gameObject.transform.position = newBPos; gameObject.transform.eulerAngles = newBEulers; break; } }
public void ReceiveCameraDirection(List <string> lookingAt) { if (dm == null || db == null) { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); } List <WallSection> newHidden = new List <WallSection>(); List <WindowSection> newHiddenWindows = new List <WindowSection>(); List <WindowSection> componentWindows = dm.dispensary.GetComponentWindows(gameObject.name); foreach (string dir in lookingAt) { switch (dir) { case "Top": foreach (ComponentSubWalls walls in subWalls) { newHidden.Add(walls.bottomWall.Hide()); } foreach (WindowSection window in componentWindows) { if (window.side == "Bottom") { newHiddenWindows.Add(window); foreach (Window window_ in window.windows) { window_.gameObject.SetActive(false); } } } break; case "Right": foreach (ComponentSubWalls walls in subWalls) { newHidden.Add(walls.leftWall.Hide()); } foreach (WindowSection window in componentWindows) { if (window.side == "Left") { newHiddenWindows.Add(window); foreach (Window window_ in window.windows) { window_.gameObject.SetActive(false); } } } break; case "Left": foreach (ComponentSubWalls walls in subWalls) { newHidden.Add(walls.rightWall.Hide()); } foreach (WindowSection window in componentWindows) { if (window.side == "Right") { newHiddenWindows.Add(window); foreach (Window window_ in window.windows) { window_.gameObject.SetActive(false); } } } break; case "Bottom": foreach (ComponentSubWalls walls in subWalls) { newHidden.Add(walls.topWall.Hide()); } foreach (WindowSection window in componentWindows) { if (window.side == "Top") { newHiddenWindows.Add(window); foreach (Window window_ in window.windows) { window_.gameObject.SetActive(false); } } } break; } } foreach (WallSection wallSection in hiddenWalls) { if (!CheckAgainstList(wallSection, newHidden)) { wallSection.Show(); } } foreach (WindowSection windows in hiddenWindows) { if (!CheckAgainstList(windows, newHiddenWindows)) { foreach (Window window_ in windows.windows) { window_.gameObject.SetActive(true); } } } previousCameraDirection = lookingAt; hiddenWalls = newHidden; hiddenWindows = newHiddenWindows; }
void Start() { dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); db = GameObject.Find("Database").GetComponent <Database>(); }
public void CreateList_Jobs() { DispensaryManager dm = GameObject.Find("DispensaryManager").GetComponent <DispensaryManager>(); List <Dispensary.JobType> jobs = dm.dispensary.GetAvailableJobs(); foreach (DraggableJobItem disp in displayedJobs) { Destroy(disp.gameObject); } displayedJobs.Clear(); RectTransform contentPanelRectTransform = jobContentPanel.GetComponent <RectTransform>(); //rectTransform.sizeDelta = new Vector2(contentPanel.rectTransform.sizeDelta.x, 0); float prefabHeight = jobDisplayPrefab.gameObject.GetComponent <RectTransform>().rect.height; float contentPanelHeight = jobs.Count * prefabHeight + (prefabHeight * .5f); //print("Prefab Height: " + prefabHeight + "\nContent Panel Height(Old): " + contentPanel.rectTransform.sizeDelta.y // + "\nContent Panel Height(New): " + contentPanelHeight + "\nPrefab Height, New: " + displayPrefab.gameObject.GetComponent<RectTransform>().rect.height); contentPanelRectTransform.sizeDelta = new Vector2(jobContentPanel.rectTransform.sizeDelta.x, contentPanelHeight); for (int i = 0; i < jobs.Count; i++) { Dispensary.JobType job = jobs[i]; DraggableJobItem newJobDisplay = Instantiate(jobDisplayPrefab); newJobDisplay.gameObject.SetActive(true); newJobDisplay.uiPanel = this; RectTransform rectTransform = newJobDisplay.GetComponent <RectTransform>(); newJobDisplay.transform.SetParent(jobContentPanel.transform.parent, false); rectTransform.anchoredPosition = new Vector2(0, -prefabHeight * i); switch (job) { case Dispensary.JobType.Cashier: newJobDisplay.jobType = job; newJobDisplay.text.text = "Cashier"; newJobDisplay.icon.sprite = SpriteManager.cashierIcon; break; case Dispensary.JobType.StoreBudtender: newJobDisplay.jobType = job; newJobDisplay.text.text = "Store Budtender"; newJobDisplay.icon.sprite = SpriteManager.storeBudtenderIcon; break; case Dispensary.JobType.SmokeBudtender: newJobDisplay.jobType = job; newJobDisplay.text.text = "Smoke Budtender"; newJobDisplay.icon.sprite = SpriteManager.smokeBudtenderIcon; break; case Dispensary.JobType.Security: newJobDisplay.jobType = job; newJobDisplay.text.text = "Security"; newJobDisplay.icon.sprite = SpriteManager.securityIcon; break; } /*StaffDisplayObject newStaffDisplay = Instantiate(staffDisplayPrefab); * newStaffDisplay.staff = staff_s; * newStaffDisplay.staffNameText.text = jobs[i].staffName; * Rect newStaffDisplayRect = newStaffDisplay.GetComponent<RectTransform>().rect; * newStaffDisplay.gameObject.transform.SetParent(staffContentPanel.transform.parent, false); * newStaffDisplay.gameObject.SetActive(true); * displayedObjects.Add(newStaffDisplay);*/ displayedJobs.Add(newJobDisplay); //newStaffDisplayObject } foreach (DraggableJobItem obj in displayedJobs) { obj.transform.SetParent(jobContentPanel.transform); } }