IEnumerator DoCreateDispensaryList() { int counter = 0; float prefabHeight = loadDifferentBuilding_dispensaryPrefab.gameObject.GetComponent <RectTransform>().rect.height; List <Dispensary_s> dispensaries = currentCompany.dispensaries; if (dispensaries == null) { yield break; } foreach (Dispensary_s dispensary in dispensaries) { UIObjectAnimator newAnimator = Instantiate(loadDifferentBuilding_dispensaryPrefab, loadDifferentBuilding_dispensaryPrefab.transform.position, loadDifferentBuilding_dispensaryPrefab.transform.rotation, mainDispensariesScrollablePanel.transform); newAnimator.gameObject.SetActive(true); newAnimator.name = dispensary.dispensaryName; Text[] texts = newAnimator.GetComponentsInChildren <Text>(); texts[0].text = dispensary.dispensaryName; Vector2 prefabAnchorMin = loadDifferentBuilding_dispensaryPrefab.GetComponent <RectTransform>().anchorMin; Vector2 prefabAnchorMax = loadDifferentBuilding_dispensaryPrefab.GetComponent <RectTransform>().anchorMax; newAnimator.gameObject.SetActive(true); newAnimator.GetComponent <RectTransform>().anchorMin = prefabAnchorMin + new Vector2(0, -prefabHeight / 14 * counter); newAnimator.GetComponent <RectTransform>().anchorMax = prefabAnchorMax + new Vector2(0, -prefabHeight / 14 * counter); newAnimator.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * counter); //newAnimator.transform.position = newAnimator.transform.position + new Vector3(0, -prefabHeight * (counter+3), 0); dispensaryUIAnimators.Add(newAnimator); newAnimator.OnScreen(); counter++; yield return(new WaitForSeconds(.015f)); } }
IEnumerator DoCreateCareerSavegamesList() { int counter = 0; float prefabHeight = careerSavegamePrefab.gameObject.GetComponent <RectTransform>().rect.height; List <SaveGame> saveGames = database.GetCareerSaveGames(); foreach (SaveGame save in saveGames) { UIObjectAnimator newAnimator = Instantiate(careerSavegamePrefab, careerSavegamePrefab.transform.position, careerSavegamePrefab.transform.rotation, mainCareerScrollablePanel.transform); newAnimator.gameObject.SetActive(true); newAnimator.name = saveGames[counter].company.companyName; Text[] texts = newAnimator.GetComponentsInChildren <Text>(); texts[0].text = save.company.companyName; Vector2 prefabAnchorMin = careerSavegamePrefab.GetComponent <RectTransform>().anchorMin; Vector2 prefabAnchorMax = careerSavegamePrefab.GetComponent <RectTransform>().anchorMax; newAnimator.gameObject.SetActive(true); newAnimator.GetComponent <RectTransform>().anchorMin = prefabAnchorMin + new Vector2(0, -prefabHeight / 14 * counter); newAnimator.GetComponent <RectTransform>().anchorMax = prefabAnchorMax + new Vector2(0, -prefabHeight / 14 * counter); newAnimator.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * counter); //newAnimator.transform.position = newAnimator.transform.position + new Vector3(0, -prefabHeight * (counter+3), 0); careerSavegameUIAnimators.Add(newAnimator); newAnimator.OnScreen(); counter++; yield return(new WaitForSeconds(.015f)); } }
public void NewBuildingChooseLogo(int logoID) { Logo logo = controller.manager.db.GetLogo(logoID); newBuildingLogo = logo; newBuildingLogoImage.GetComponent <Image>().sprite = logo.sprite; newBuildingLogoImage.GetComponent <Image>().color = logo.GetColor(); }
// Create Company UI Grouping public void ActivateNewBuildingNameInputField() { DeactivateAllInputFields(); InputField thisInputField = newBuildingNameInputField.GetComponent <InputField>(); if (thisInputField != null) { thisInputField.ActivateInputField(); } anyInputFieldActive = true; newBuildingNameInputFieldActive = true; }
// Create Company UI Grouping public void ActivateManagersNameInputField() { DeactivateAllInputFields(); InputField thisInputField = managersNameInputField.GetComponent <InputField>(); if (thisInputField != null) { thisInputField.ActivateInputField(); } anyInputFieldActive = true; managersNameInputFieldActive = true; }
IEnumerator DoCreateLogoList() { int columnCounter = 0; int rowCounter = 0; float prefabHeight = chooseLogoPrefab.gameObject.GetComponent <RectTransform>().rect.height; Logo[] logos = controller.manager.db.logos; if (logos == null) { yield break; } for (int i = currentLogoListMin; i < currentLogoListMax; i++) { Logo logo = null; try { logo = logos[i]; } catch (System.IndexOutOfRangeException) { break; } UIObjectAnimator newAnimator = Instantiate(chooseLogoPrefab, chooseLogoPrefab.transform.position, chooseLogoPrefab.transform.rotation, mainChooseLogoContentPanel.transform); newAnimator.gameObject.SetActive(true); newAnimator.name = "Logo " + logo.ID; Image img = newAnimator.GetComponent <Image>(); if (img != null) { img.sprite = logo.sprite; img.color = logo.GetColor(); } Vector2 prefabAnchorMin = chooseLogoPrefab.GetComponent <RectTransform>().anchorMin; Vector2 prefabAnchorMax = chooseLogoPrefab.GetComponent <RectTransform>().anchorMax; newAnimator.gameObject.SetActive(true); newAnimator.GetComponent <RectTransform>().anchorMin = prefabAnchorMin + new Vector2(7.875f / 40 * columnCounter, -7.875f / 21 * rowCounter); newAnimator.GetComponent <RectTransform>().anchorMax = prefabAnchorMax + new Vector2(7.875f / 40 * columnCounter, -7.875f / 21 * rowCounter); //newAnimator.GetComponent<RectTransform>().anchoredPosition = new Vector2(7.875f / 14* columnCounter, -7.875f / 14* rowCounter); //newAnimator.transform.position = newAnimator.transform.position + new Vector3(0, -prefabHeight * (counter+3), 0); logosBeingDisplayed.Add(new DisplayedLogo(logo, newAnimator, new Vector2(columnCounter, rowCounter))); newAnimator.OnScreen(); columnCounter++; if (columnCounter > 4) { rowCounter++; columnCounter = 0; } yield return(new WaitForSeconds(.015f)); } }
void Update() { if (mainManager.canInteract) { backToMainMenuButton.GetComponent <Button>().interactable = true; browseCurrentCatalogButton.GetComponent <Button>().interactable = true; browseNextCategoryButton.GetComponent <Button>().interactable = true; } else { backToMainMenuButton.GetComponent <Button>().interactable = false; browseCurrentCatalogButton.GetComponent <Button>().interactable = false; browseNextCategoryButton.GetComponent <Button>().interactable = false; } }
public void ChooseLogoButtonsPanelOnScreen(DisplayedLogo displayedLogo) { if (chooseLogoButtonsPanelOnScreen) { ChooseLogoButtonsPanelOffScreen(); } currentlySelectedDisplayedLogo = displayedLogo; defaultLogoSiblingIndex = currentlySelectedDisplayedLogo.animator.transform.GetSiblingIndex(); print("Default: " + defaultLogoSiblingIndex); int buttonsPanelSiblingIndex = defaultLogoSiblingIndex + 2; chooseLogoButtonsPanelOnScreen = true; if (displayedLogo.NeedsRightButtonsPanel()) { currentLogoWithDisabledRaycasting = right_chooseLogoButtonsPanelPrefab.transform.parent.GetChild(defaultLogoSiblingIndex + 1).GetComponent <UIObjectAnimator>(); currentLogoWithDisabledRaycasting.GetComponent <BoxCollider>().enabled = false; currentlyDisplayedButtonsPanel = Instantiate(right_chooseLogoButtonsPanelPrefab, right_chooseLogoButtonsPanelPrefab.transform.position, right_chooseLogoButtonsPanelPrefab.transform.rotation, mainChooseLogoContentPanel.transform); currentlyDisplayedButtonsPanel.gameObject.SetActive(true); currentlyDisplayedButtonsPanel.transform.SetSiblingIndex(buttonsPanelSiblingIndex); currentlySelectedDisplayedLogo.animator.transform.SetSiblingIndex(buttonsPanelSiblingIndex); print("new: " + currentlyDisplayedButtonsPanel.transform.GetSiblingIndex()); Vector2 prefabAnchorMin = right_chooseLogoButtonsPanelPrefab.GetComponent <RectTransform>().anchorMin; Vector2 prefabAnchorMax = right_chooseLogoButtonsPanelPrefab.GetComponent <RectTransform>().anchorMax; currentlyDisplayedButtonsPanel.GetComponent <RectTransform>().anchorMin = prefabAnchorMin + new Vector2(7.875f / 40 * displayedLogo.index.x, -7.875f / 21 * displayedLogo.index.y); currentlyDisplayedButtonsPanel.GetComponent <RectTransform>().anchorMax = prefabAnchorMax + new Vector2(7.875f / 40 * displayedLogo.index.x, -7.875f / 21 * displayedLogo.index.y); currentlyDisplayedButtonsPanel.OnScreen(); } else { currentLogoWithDisabledRaycasting = right_chooseLogoButtonsPanelPrefab.transform.parent.GetChild(defaultLogoSiblingIndex - 1).GetComponent <UIObjectAnimator>(); currentLogoWithDisabledRaycasting.GetComponent <BoxCollider>().enabled = false; currentlyDisplayedButtonsPanel = Instantiate(left_chooseLogoButtonsPanelPrefab, left_chooseLogoButtonsPanelPrefab.transform.position, left_chooseLogoButtonsPanelPrefab.transform.rotation, mainChooseLogoContentPanel.transform); currentlyDisplayedButtonsPanel.gameObject.SetActive(true); currentlyDisplayedButtonsPanel.transform.SetSiblingIndex(buttonsPanelSiblingIndex); currentlySelectedDisplayedLogo.animator.transform.SetSiblingIndex(buttonsPanelSiblingIndex); Vector2 prefabAnchorMin = left_chooseLogoButtonsPanelPrefab.GetComponent <RectTransform>().anchorMin; Vector2 prefabAnchorMax = left_chooseLogoButtonsPanelPrefab.GetComponent <RectTransform>().anchorMax; currentlyDisplayedButtonsPanel.GetComponent <RectTransform>().anchorMin = prefabAnchorMin + new Vector2(0, -7.875f / 21 * displayedLogo.index.y); currentlyDisplayedButtonsPanel.GetComponent <RectTransform>().anchorMax = prefabAnchorMax + new Vector2(0, -7.875f / 21 * displayedLogo.index.y); currentlyDisplayedButtonsPanel.OnScreen(); } }
public void ChooseLogoButtonsPanelOffScreen() { if (currentLogoWithDisabledRaycasting != null) { currentLogoWithDisabledRaycasting.GetComponent <BoxCollider>().enabled = true; } currentLogoWithDisabledRaycasting = null; if (currentlyDisplayedButtonsPanel != null) { Destroy(currentlyDisplayedButtonsPanel.gameObject); } currentlyDisplayedButtonsPanel = null; if (currentlySelectedDisplayedLogo != null) { currentlySelectedDisplayedLogo.animator.transform.SetSiblingIndex(defaultLogoSiblingIndex); } currentlySelectedDisplayedLogo = null; chooseLogoButtonsPanelOnScreen = false; }
IEnumerator SmokeScreenOnScreen() { float timeStarted = Time.time; float timeElapsed = 0.0f; float percentageComplete = 0.0f; // Figure out how often a smoke obj needs to be made float spawnDelay = smokeScreenOnScreenLerpTime / maxSmokeObjects; float lastSpawnedTime = 0.0f; while (percentageComplete < 1) { timeElapsed = Time.time - timeStarted; percentageComplete = timeElapsed / smokeScreenOnScreenLerpTime; if (timeElapsed >= lastSpawnedTime + spawnDelay) { UIObjectAnimator newSmokeObject = Instantiate(smokePrefab, transform); //newSmokeObject.InitializeAnimator(); RectTransform rectTransform = newSmokeObject.GetComponent <RectTransform>(); rectTransform.sizeDelta = new Vector2(Random.Range(300, maxSmokeWidth), Random.Range(300, maxSmokeHeight)); rectTransform.transform.eulerAngles = (Random.value >= .5f) ? Vector3.zero : new Vector3(0, 0, 90); rectTransform.localPosition = new Vector2(Random.Range(-Screen.width / 2, Screen.width / 2), Random.Range(-Screen.height / 2, Screen.height / 2)); newSmokeObject.OnScreen(); smokeObjects.Add(newSmokeObject); lastSpawnedTime = timeElapsed; } yield return(null); } List <SceneTransitionManager.SmokeObject> compatibleSmokeObjects = new List <SceneTransitionManager.SmokeObject>(); foreach (UIObjectAnimator obj in smokeObjects) { Image smokeImage = obj.GetComponent <Image>(); if (smokeImage != null) { compatibleSmokeObjects.Add(new SceneTransitionManager.SmokeObject(smokeImage)); } } manager.currentSmokeObjects = compatibleSmokeObjects; }
public void FinishSmokeScreenTransition() { SceneTransition_SmokeEffect boundingImage = Instantiate(smokeScreenScreenTransitionPrefab); boundingImage.transform.SetParent(GetCurrentCanvas().transform, false); // Recreate smoke cloud if (currentSmokeObjects.Count > 0) { foreach (SmokeObject smokeObject in currentSmokeObjects) { UIObjectAnimator newSmokeObject = Instantiate(boundingImage.smokePrefab, boundingImage.transform); RectTransform rectTransform = newSmokeObject.GetComponent <RectTransform>(); rectTransform.sizeDelta = smokeObject.size; rectTransform.localPosition = smokeObject.position; rectTransform.eulerAngles = smokeObject.eulers; newSmokeObject.OnScreen(); newSmokeObjects.Add(newSmokeObject); } } // Clear smoke cloud if (newSmokeObjects.Count > 0) { foreach (UIObjectAnimator smokeObject in newSmokeObjects) { BoxCollider2D boundingBox = boundingImage.GetComponent <BoxCollider2D>(); if (boundingBox != null) { Vector3 thisPos = smokeObject.transform.position; Vector3 targetPos = boundingBox.bounds.ClosestPoint(thisPos); smokeObject.OffScreenToTargetPos(targetPos, 0.75f); } } //ClearSmokeObjects(); } }
public void LoadStrain(Strain toLoad) { strainTitleText.GetComponent <Text>().text = toLoad.name; THCGraph.LoadStrain(toLoad, true); sativaGraph.LoadStrain(toLoad, false); }