private IEnumerator ReEnableRecipe(RecipeUI recipeUI, float delay) { recipeUI.gameObject.SetActive(false); float time = Time.time; yield return(new WaitUntil(() => { if (spawnNewRecipes && Time.time >= time + delay) { return true; } else { return false; } })); for (int i = 0; i < recipeUI.transform.parent.childCount; ++i) { Transform child = recipeUI.transform.parent.GetChild(i); if (recipeUI.transform != child && !child.gameObject.activeSelf) { recipeUI.transform.SetSiblingIndex(i - 1); break; } else if (i == recipeUI.transform.parent.childCount - 1) { recipeUI.transform.SetAsLastSibling(); break; } } recipeUI.SetRecipe(availableRecipes[Random.Range(0, availableRecipes.Count)]); recipeUI.gameObject.SetActive(true); }
public override void ProcessTriggers(TriggersSet triggersSet) { BrowserUI BrowserUI = WhatsThis.Instance.BrowserUI; RecipeUI RecipeUI = WhatsThis.Instance.RecipeUI; if (!Main.HoverItem.IsAir) { //if (WhatsThis.ShowRecipe.JustPressed && Main.HoverItem.HasRecipes()) //{ // if (BrowserUI.visible) // { // BrowserUI.visible = false; // RecipeUI.wasInBrowser = true; // } // if (!RecipeUI.visible) RecipeUI.Toggle(); // RecipeUI.DisplayRecipe(Main.HoverItem); //} //if (WhatsThis.ShowUsage.JustPressed && Main.HoverItem.HasUsages()) //{ // if (BrowserUI.visible) // { // BrowserUI.visible = false; // RecipeUI.wasInBrowser = true; // } // if (!RecipeUI.visible) RecipeUI.Toggle(); // RecipeUI.DisplayRecipe(Main.HoverItem); //} if (WhatsThis.FindItem.JustPressed && !Keys.RightControl.IsKeyDown()) { mod.GetModWorld <WTWorld>().QueryContainers(); } } if (WhatsThis.OpenBrowser.JustPressed) { //if (RecipeUI.visible && RecipeUI.wasInBrowser) //{ // RecipeUI.visible = false; // BrowserUI.visible = true; // RecipeUI.wasInBrowser = false; // return; //} BrowserUI.Toggle(); } //if (RecipeUI != null) //{ // if (WhatsThis.PrevRecipe.JustPressed) // { // RecipeUI.GoBack(); // } //} //if (BrowserUI != null && BrowserUI.visible && Keys.RightControl.IsKeyDown() && Keys.F.IsKeyDown()) BrowserUI.inputItems.Focus(); }
private void CheckIngredients(RecipeBase.Recipe recipe, RecipeUI src) { string[] ings = { recipe.strIngredient1, recipe.strIngredient2, recipe.strIngredient3, recipe.strIngredient4, recipe.strIngredient5, recipe.strIngredient6, recipe.strIngredient7, recipe.strIngredient8 }; for (int i = 0; i < ings.Length; i++) { if (src.ingredientIMG.Length >= ings.Length && ings[i].Length <= 1) { DestroyImmediate(src.ingredientIMG[i].transform.parent.gameObject); } } }
public void OnInputChange() { if (recipeGrid == null) { return; } for (int i = 0; i < recipeGrid.transform.childCount; ++i) { recipeGrid.transform.GetChild(i).GetComponent <RecipeSlot>().recipeUI.Destroy(); } List <ItemStack> items = new List <ItemStack>(); for (int i = 0; i < craftingInventory.GetInventorySize(); ++i) { if (craftingInventory.GetItemStackAt(i) != null) { items.Add(craftingInventory.GetItemStackAt(i)); } } if (items.Count == 0) { return; } List <List <Recipe> > recipes = craftingData.GetRecipes(items.ToArray()); ////////////////////////////////////////////////////////////////////////// if (recipes == null || recipes.Count == 0) { return; } for (int i = 0; i < recipes[0].Count; ++i) { bool canMakeRecipe = false; if (craftingData.CanMakeRecipe(recipes[0][i], items)) { canMakeRecipe = true; } RecipeUI recipeUI = new RecipeUI(recipes[0][i], canMakeRecipe); recipeUI.gameObject.transform.SetParent(recipeGrid.transform); recipeUI.AddClickListener(RecipeSlotClick); } for (int i = 1; i < recipes.Count; ++i) { for (int j = 0; j < recipes[i].Count; ++j) { RecipeUI recipeUI = new RecipeUI(recipes[i][j], false); recipeUI.gameObject.transform.SetParent(recipeGrid.transform); recipeUI.AddClickListener(RecipeSlotClick); } } }
public bool Deliver(Ingredient ingredient) { if (!RecipeManager.Instance.IsFinalIngredient(ingredient.data)) { return(false); } int index; RecipeUI recipeUI = RecipeManager.Instance.GetRecipeUI(ingredient, out index); if (!recipeUI) { AudioManager.Instance.PlaySoundEffect(AudioManager.FX.WRONGDELIVERY); GameManager.Instance.currentMoney -= GameManager.Instance.moneyPenaltyOnFail; GameManager.Instance.failedMoney += GameManager.Instance.moneyPenaltyOnFail; } else { AudioManager.Instance.PlaySoundEffect(AudioManager.FX.CORRECTDELIVERY); RecipeManager.Instance.RecipeDelivered(recipeUI); float bonus = recipeUI.recipe.moneyBonus * (1 - Mathf.Clamp(recipeUI.counter / recipeUI.recipe.timeLimit, 0f, 1f)); GameManager.Instance.currentMoney += recipeUI.recipe.moneyInflow + bonus; GameManager.Instance.deliveredMoney += recipeUI.recipe.moneyInflow; GameManager.Instance.bonusMoney += bonus; } WigDispenser.Instance.itemsSpawned -= 1; #region ADD TO BELT ingredient.transform.rotation = transform.rotation; ingredient.transform.position = new Vector3(8.5f, beltRenderer.bounds.size.y + ingredient.renderer.bounds.extents.y, ingredient.transform.position.z); ingredient.gameObject.SetActive(true); if (ingredient.rb) { ingredient.rb.velocity = ingredient.rb.angularVelocity = Vector3.zero; ingredient.rb.isKinematic = true; } if (ingredient.collider) { ingredient.collider.enabled = false; } translatedIngredients.Add(ingredient); #endregion ScoreUI.Instance.RepositionProgressBar(); return(true); }
private void Start() { List <Recipe> recipes = GameState.instance.GetRestaurant().GetMenu(); foreach (Recipe recipe in recipes) { RecipeUI obj = Instantiate(recipeUIPrefab, container); obj.SetRecipe(recipe); obj.GetButton().onClick.AddListener(() => PrepareRecipe(obj)); obj.PointerEnter += Obj_PointerEnter; obj.PointerExit += Obj_PointerExit; } }
public override void Load() { if (!Main.dedServ) { recipeUI = new RecipeUI(); recipeUI.Activate(); UI = new UserInterface(); UI.SetState(recipeUI); ItemRecipeKey = RegisterHotKey("Show Item Recipe", "R"); ItemUsageKey = RegisterHotKey("Show Item Usage", "U"); Utils.I18n.InitializeI18n(); } }
// Use this for initialization void Start() { _RecipeUIPrefab = Resources.Load("Prefab/UI/Factory/Recipe") as GameObject; //レシピUI作成 BulletRecipe[] Recipes = Data.bulletsRecipe; foreach (BulletRecipe recipe in Recipes) { if (recipe.cost > 0) { //生成。 GameObject recipeui = Instantiate(_RecipeUIPrefab, transform); RecipeUI ui = recipeui.GetComponent <RecipeUI>(); //配列の何番目にあるか設定。 ui.bulletID = recipe.bulletID; } } }
public override void Load() { Instance = this; OpenBrowser = this.Register("Open Browser", Keys.OemCloseBrackets); ShowRecipe = this.Register("Show Recipe", Keys.R); ShowUsage = this.Register("Show Usage", Keys.U); FindItem = this.Register("Find Item in containers", Keys.F); PrevRecipe = this.Register("Previous recipe", Keys.Back); if (!Main.dedServ) { for (int i = 0; i < 4; i++) { textureSortMode.Add(ModLoader.GetTexture(TexturePath + "SortMode_" + i)); } texturePause = ModLoader.GetTexture(TexturePath + "Pause"); texturePlay = ModLoader.GetTexture(TexturePath + "Play"); textureEntity = ModLoader.GetTexture(TexturePath + "Entity"); textureWorld = ModLoader.GetTexture(TexturePath + "World"); textureMagnet = ModLoader.GetTexture(TexturePath + "Magnet"); textureMapDeath = TextureManager.Load("Images" + Path.DirectorySeparatorChar + "MapDeath"); IBrowserUI = new UserInterface(); BrowserUI = new BrowserUI(); BrowserUI.Activate(); IBrowserUI.SetState(BrowserUI); IRecipeUI = new UserInterface(); RecipeUI = new RecipeUI(); RecipeUI.Activate(); IRecipeUI.SetState(RecipeUI); ICheatUI = new UserInterface(); CheatUI = new CheatUI(); CheatUI.Activate(); ICheatUI.SetState(CheatUI); IMobUI = new UserInterface(); MobUI = new MobUI(); MobUI.Activate(); IMobUI.SetState(MobUI); MobUI.visible = true; } }
public RecipeUI GetRecipeUI(Ingredient ingredient, out int index) { for (int i = 0; i < recipeBoxes.Count; ++i) { RecipeUI recipeUI = recipeBoxes[i]; if (!recipeUI.gameObject.activeSelf) { break; } if (recipeUI.recipe.ingredients[recipeUI.recipe.ingredients.Count - 1] == ingredient.data) { index = i; return(recipeUI); } } index = -1; return(null); }
//Put a new item in the UI void UpdateGUI(Piece p, GameObject prefab, Transform parent) { //Instantiate the gui item GameObject go = ObjectPool.Instantiate(prefab, prefab.transform.position, prefab.transform.rotation, parent); //Fix the scale error RectTransform rect = go.GetComponent <RectTransform>(); rect.transform.localScale = Vector3.one; //Load the data in the UI RecipeUI itemUI = go.GetComponent <RecipeUI>(); itemUI.item = p.ToInventory(); itemUI.UpdateUI(); itemUI.ResetListeners(); itemUI.AddListener <string>(actualUI.UpdateRecipe, p.id); itemUI.AddListener(UIManager.Instance.BackFromRecipes); print("Updating"); }
public void RecipeDelivered(RecipeUI recipeUI) { StartCoroutine(ReEnableRecipe(recipeUI, recipeRespawnTime)); }
void PrepareRecipe(RecipeUI recipe) { GameState.instance.GetRestaurant().PrepareFood(recipe.GetRecipe()); }
private void Obj_PointerEnter(UnityEngine.EventSystems.PointerEventData obj, RecipeUI recipe) { infoObject.SetActive(true); recipeText.text = recipe.GetRecipe().food.foodName; timeText.text = recipe.GetRecipe().timeToPrepare.ToString("F0"); }
private void Obj_PointerExit(UnityEngine.EventSystems.PointerEventData obj, RecipeUI recipe) { infoObject.SetActive(false); }