// Use this for initialization void Start () { Screen.orientation = ScreenOrientation.Portrait; Screen.sleepTimeout = SleepTimeout.NeverSleep; if (!Application.runInBackground) Application.runInBackground = true; scenery = GameObject.Find("Kitchen"); kagotchi = GameObject.Find("Kagotchi"); statusUI = GameObject.Find("StatusUI"); statusUICanvas = statusUI.GetComponent<CanvasGroup>(); cookingStatusUI = GameObject.Find("CookingStatusUI"); cookingStatusUICanvas = cookingStatusUI.GetComponent<CanvasGroup>(); cookingUI = GameObject.Find("CookingUI"); cookingUICanvas = cookingUI.GetComponent<CanvasGroup>(); FoodSelectorUI = GameObject.Find("FoodSelectorUI"); foodSelectorUICanvas = FoodSelectorUI.GetComponent<CanvasGroup>(); recipeSelectorUI = GameObject.Find("RecipeSelectorUI"); recipeSelectorUICanvas = recipeSelectorUI.GetComponent<CanvasGroup>(); recipeUI = GameObject.Find("RecipeUI"); recipeUICanvas = recipeUI.GetComponent<CanvasGroup>(); RecipeUICanvasGroup = recipeUICanvas; btnStopCooking = GameObject.Find("btnStopCooking"); sceneryRectTransform = scenery.GetComponent<RectTransform>(); kagotchyRectTransform = kagotchi.GetComponent<RectTransform>(); kagotchiStartPosition = kagotchyRectTransform.anchoredPosition; foodRectTransform = new csRectTransformData() { AnchorMin = new Vector2(1, 1), AnchorMax = new Vector2(1, 1), Pivot = new Vector2(0.5f, 0.5f), AnchoredPosition = new Vector2(-400, -89), SizeDelta = new Vector2(120, 114) }; //LoadInventoryItemInSelector(foodInventory, FoodSelectorUI, "Prefabs/Ingredients/Banana", foodRectTransform); //LoadInventoryItemInSelector(foodInventory, FoodSelectorUI, "Prefabs/Ingredients/HamburgerBread", foodRectTransform); //LoadInventoryItemInSelector(foodInventory, FoodSelectorUI, "Prefabs/Ingredients/Bacon", foodRectTransform); //LoadInventoryItemInSelector(foodInventory, FoodSelectorUI, "Prefabs/Ingredients/Cheese", foodRectTransform); //LoadInventoryItemInSelector(foodInventory, FoodSelectorUI, "Ingredients/Meat", foodRectTransform); inventoryIngredientsManager.Inventory = foodInventory; var recipeRectTransform = new csRectTransformData() { AnchorMin = new Vector2(0.5f, 0.5f), AnchorMax = new Vector2(0.5f, 0.5f), Pivot = new Vector2(0.5f, 0.5f), AnchoredPosition = new Vector2(7.629395e-06f, 1.239777e-05f), SizeDelta = new Vector2(110, 155) }; recipeInventory.Add(LoadItemInSelector(recipeSelectorUI, "Prefabs/Recipes/Hamburger Recipe", recipeRectTransform)); recipeInventory.Add(LoadItemInSelector(recipeSelectorUI, "Prefabs/Recipes/Salad Recipe", recipeRectTransform)); recipeInventory.Add(LoadItemInSelector(recipeSelectorUI, "Prefabs/Recipes/Hot Dog Recipe", recipeRectTransform)); inventoryRecipeManager.Inventory = recipeInventory; LoadItemInInventory(kitchenwareInventory, "Prefabs/Kitchenware/Grill"); if (foodInventory.Count > 0) noItemFood.gameObject.SetActive(false); else noItemFood.gameObject.SetActive(true); if (recipeInventory.Count > 0) noItemRecipe.gameObject.SetActive(false); else noItemRecipe.gameObject.SetActive(true); if(foodInventory.Count > 0) { var food = foodInventory[invIdx] as GameObject; food.SetActive(true); food.GetComponent<CanvasGroup>().blocksRaycasts = true; food.transform.SetParent(FoodSelectorUI.transform, false); } var recipe = recipeInventory[invIdx] as GameObject; recipe.SetActive(true); recipe.GetComponent<CanvasGroup>().blocksRaycasts = true; recipe.transform.SetParent(recipeSelectorUI.transform, false); inventoryIngredientsManager.HierarchyParent = FoodSelectorUI; inventoryRecipeManager.HierarchyParent = recipeSelectorUI; FoodInventoryManager = inventoryIngredientsManager; RecipeInventoryManager = inventoryRecipeManager; pnlMouthTrigger = GameObject.Find("pnlMouthTrigger"); LoadSceneData(); }
public void FinalizeRecipe() { var inventory = sceneManager.FoodInventoryManager.Inventory; var foodRectTransform = new csRectTransformData() { AnchorMin = new Vector2(1, 1), AnchorMax = new Vector2(1, 1), Pivot = new Vector2(0.5f, 0.5f), AnchoredPosition = new Vector2(-400, -89), SizeDelta = new Vector2(120, 114) }; inventory.Add(sceneManager.LoadItemInSelector(sceneManager.FoodSelectorUI, recipe.FinalResult, foodRectTransform)); var msg = new csMessage() { Enable = true, Message = "YOU CREATED THE RECIPE!!", Status = csMessageStatusEnum.None, Timeout = 3.0f, Type = csMessageTypeEnum.Success }; message.SetUIMessage(msg); sceneManager.ToggleStopCookingButton(false); sceneManager.CurrentRecipe.State = csRecipeStateEnum.Finished; sceneManager.ShowRecipeSelector(); Reset(); }
public GameObject LoadItemInSelector(GameObject selector, GameObject itemObject, csRectTransformData rectTransform) { if (itemObject != null) { var clone = (GameObject)Instantiate(itemObject); clone.name = itemObject.name; clone.transform.SetParent(FoodSelectorUI.transform, false); clone.GetComponent<RectTransform>().anchorMin = rectTransform.AnchorMin; clone.GetComponent<RectTransform>().anchorMax = rectTransform.AnchorMax; clone.GetComponent<RectTransform>().pivot = rectTransform.Pivot; clone.GetComponent<RectTransform>().anchoredPosition = rectTransform.AnchoredPosition; clone.GetComponent<RectTransform>().sizeDelta = rectTransform.SizeDelta; clone.GetComponent<RectTransform>().localScale = new Vector3(1.0f, 1.0f, 1.0f); clone.SetActive(false); if (clone.GetComponent<csDragHandler>() == null) clone.AddComponent<csDragHandler>(); var animator = clone.GetComponent<Animator>(); if (animator != null) animator.enabled = false; return clone; } return null; }