public void Accept() { FindObjectOfType <Seller>().Sell(RecipeSelector.recipeHolderSelected.recipe, invoice); RecipeSelector.UnSelectRecipe(); Hide(); }
private void CloseSale() { GameController.instance.IsGameSceneEnabled = true; GameController.instance.time.UnPause(); RecipeSelector.UnSelectRecipe(); EventManager.StopListening("OnRecipeRemove", view.RemoveCheckmarks); view.cancelBtn.gameObject.SetActive(true); view.gameObject.SetActive(false); }
private void Start() { EventManager.StartListening("ContinueTutorial", tutorial.ContinueTutorial); selector = GetComponent <RecipeSelector>(); // selector.SetVisualizer(this); if (gameObject.activeInHierarchy) { gameObject.SetActive(false); } }
public void SetDescription() { if (!CompareTag("Basic")) { if (!GameController.instance.crafter.view.gameObject.activeInHierarchy) { RecipeSelector.UnSelectRecipe(); } descriptionPanel.SetPanel(recipe, this); } }
public override void Hide() { if (!gameObject.activeInHierarchy) { return; } RecipeSelector.UnSelectRecipe(); GameController.instance.IsGameSceneEnabled = true; GameController.instance.time.UnPause(); EventManager.StopListening("OnRecipeRemove", ResetBar); anim.Play("Laboratory_Disappear"); }
public void OnPointerDown(PointerEventData eventData) { if (dragger != null) { return; } ClearDescription(); SetDescription(); if (!GameController.instance.crafter.view.gameObject.activeInHierarchy) { RecipeSelector.UnSelectRecipe(); } }
public IngredientSelector(Manager manager, IngredientCount ingredient, int count, RecipeDef targetRecipe) { // set up vars this.ingredient = ingredient; this.targetRecipe = targetRecipe; this.manager = manager; targetCount = (int)Math.Sqrt(count) * (int)ingredient.GetBaseCount(); allowedThingDefs = ingredient.filter.AllowedThingDefs.ToList(); // if there's only one allowed we don't need to manually choose. if (allowedThingDefs.Count == 1) { recipeSelector = new RecipeSelector(manager, allowedThingDefs.First(), targetCount); } }
public void SaleOn(Area area, int transferCost) { this.area = area; this.transferCost = transferCost; view.gameObject.SetActive(true); view.SetViewToArea(area); EventManager.StartListening("OnRecipeRemove", view.RemoveCheckmarks); GameController.instance.time.Pause(); RecipeSelector.UnSelectRecipe(); GameController.instance.IsGameSceneEnabled = false; ListPopulator.PopulateRecipeList(view.recipeView, view.recipePrefab, GameController.instance.player.inventory.recipes.Where(x => x.GetDeathRating() <= area.deathRatingAllowed && GameController.instance.player.inventory.GetQuantity(x.description.Name) > 0).ToList()); if (!tutorial.isTutorialCompleted) { tutorial.ContinueTutorial(); } if (!GameController.instance.generalTutorial.isTutorialCompleted) { view.returnBtn.gameObject.SetActive(false); } }
private void OnEndDrag() { if (RecipeSelector.recipeHolderSelected != null) { RecipeSelector.SelectRecipe(recipe); Debug.Log("EndDrag1"); dragger.ResetDragItem(); GameController.instance.audio.MakeSound(onEndDragSound); return; } if (GameController.instance.crafter.view.holderSelected == null) { dragger.ResetDragItem(); return; } if (!GameController.instance.crafter.view.holderSelected.isUnlocked || (GameController.instance.crafter.view.holderSelected == null && dragger.dragItem != null)) { dragger.ResetDragItem(); return; } if (GameController.instance.crafter.view.holderSelected != null && GameController.instance.crafter.view.recipeHolderSelected == null) { GameController.instance.crafter.controller.OnAddRecipe(this); GameController.instance.audio.MakeSound(onEndDragSound); dragger.ResetDragItem(); } else { Debug.Log("EndDragEND"); dragger.ResetDragItem(); } }
private void Start() { selector = GetComponent <RecipeSelector>(); selector.SetVisualizer(this); }
public void DrawSelectorRow( ref Vector2 cur, float width, int nesting, Vector2 parentPosition ) { // draw a label / dropdown for the thingdef to use in this ingredient slot. // once selected, draw a label / dropdown for the recipe to use for that thingdef. // finally, a textbox for the target count of that thing ( with a sensible default ). cur.x = nesting * _nestingOffset; float colWidth = ( width - _countFieldSize.x ) / 2; var thingRect = new Rect( cur.x, cur.y, colWidth - cur.x, _entryHeight ); var recipeRect = new Rect( thingRect.xMax, cur.y, colWidth, _entryHeight ); var countRect = new Rect( width - _countFieldSize.x, cur.y, _countFieldSize.x, _countFieldSize.y ); cur.y += _entryHeight; // Draw line from parent to here. if ( parentPosition != Vector2.zero ) { // vertical line segment Widgets.DrawLineVertical( parentPosition.x + Utilities.Margin, parentPosition.y, cur.y - parentPosition.y - _entryHeight / 2 ); // horizontal line segment Widgets.DrawLineHorizontal( parentPosition.x + Utilities.Margin, cur.y - _entryHeight / 2, cur.x - parentPosition.x - Utilities.Margin ); } // THINGDEF SELECTOR // draw the label string label = recipeSelector?.target.LabelCap ?? "FMP.SelectIngredient".Translate(); Utilities.Label( thingRect, label, "FMP.SelectIngredientTooltip".Translate( targetRecipe.LabelCap, ingredient.GetBaseCount() ), TextAnchor.MiddleLeft, Utilities.Margin ); // if there are choices do a dropdown on click if ( allowedThingDefs.Count > 1 ) { Widgets.DrawHighlightIfMouseover( thingRect ); if ( Widgets.ButtonInvisible( thingRect ) ) { List<FloatMenuOption> options = allowedThingDefs .Where( td => RecipeSelector.HasRecipe( manager, td ) ) .Select( td => new FloatMenuOption( td.LabelCap, delegate { recipeSelector = new RecipeSelector( manager, td, ingredient .CountRequiredOfFor ( td, targetRecipe ) * (int) Math.Sqrt( targetCount ) ); } ) ).ToList(); if ( allowedThingDefs.Any( td => !RecipeSelector.HasRecipe( manager, td ) ) ) { options.Add( new FloatMenuOption( "FMP.RawResource".Translate(), delegate { recipeSelector = null; } ) ); } Find.WindowStack.Add( new FloatMenu( options ) ); } } // RECIPE SELECTOR recipeSelector?.DrawRecipeSelector( recipeRect ); // COUNT FIELD if ( recipeSelector?.selectedRecipe != null ) { recipeSelector?.DrawCountField( countRect ); } // DRAW YOUR CHILDREN if ( recipeSelector != null && recipeSelector.selectedRecipe != null && recipeSelector.children != null ) { // For some reason just plain copying cur (or even the elements of cur) doesn't work (I'm quite possibly misunderstanding how this works) float x = cur.x; float y = cur.y; var pos = new Vector2( x, y ); foreach ( IngredientSelector child in recipeSelector.children ) { child.DrawSelectorRow( ref cur, width, nesting + 1, pos ); } } }
public RecipeDef targetRecipe; // the parent recipe itself. #endregion Fields #region Constructors public IngredientSelector( Manager manager, IngredientCount ingredient, int count, RecipeDef targetRecipe ) { // set up vars this.ingredient = ingredient; this.targetRecipe = targetRecipe; this.manager = manager; targetCount = (int) Math.Sqrt( count ) * (int) ingredient.GetBaseCount(); allowedThingDefs = ingredient.filter.AllowedThingDefs.ToList(); // if there's only one allowed we don't need to manually choose. if ( allowedThingDefs.Count == 1 ) { recipeSelector = new RecipeSelector( manager, allowedThingDefs.First(), targetCount ); } }
public void DrawSelectorRow(ref Vector2 cur, float width, int nesting, Vector2 parentPosition) { // draw a label / dropdown for the thingdef to use in this ingredient slot. // once selected, draw a label / dropdown for the recipe to use for that thingdef. // finally, a textbox for the target count of that thing ( with a sensible default ). cur.x = nesting * _nestingOffset; float colWidth = (width - _countFieldSize.x) / 2; var thingRect = new Rect(cur.x, cur.y, colWidth - cur.x, _entryHeight); var recipeRect = new Rect(thingRect.xMax, cur.y, colWidth, _entryHeight); var countRect = new Rect(width - _countFieldSize.x, cur.y, _countFieldSize.x, _countFieldSize.y); cur.y += _entryHeight; // Draw line from parent to here. if (parentPosition != Vector2.zero) { // vertical line segment Widgets.DrawLineVertical(parentPosition.x + Utilities.Margin, parentPosition.y, cur.y - parentPosition.y - _entryHeight / 2); // horizontal line segment Widgets.DrawLineHorizontal(parentPosition.x + Utilities.Margin, cur.y - _entryHeight / 2, cur.x - parentPosition.x - Utilities.Margin); } // THINGDEF SELECTOR // draw the label string label = recipeSelector?.target.LabelCap ?? "FMP.SelectIngredient".Translate(); Utilities.Label(thingRect, label, "FMP.SelectIngredientTooltip".Translate(targetRecipe.LabelCap, ingredient.GetBaseCount()), TextAnchor.MiddleLeft, Utilities.Margin); // if there are choices do a dropdown on click if (allowedThingDefs.Count > 1) { Widgets.DrawHighlightIfMouseover(thingRect); if (Widgets.ButtonInvisible(thingRect)) { List <FloatMenuOption> options = allowedThingDefs .Where(td => RecipeSelector.HasRecipe(manager, td)) .Select( td => new FloatMenuOption(td.LabelCap, delegate { recipeSelector = new RecipeSelector(manager, td, ingredient .CountRequiredOfFor ( td, targetRecipe) * (int) Math.Sqrt( targetCount)); })).ToList(); if (allowedThingDefs.Any(td => !RecipeSelector.HasRecipe(manager, td))) { options.Add(new FloatMenuOption("FMP.RawResource".Translate(), delegate { recipeSelector = null; })); } Find.WindowStack.Add(new FloatMenu(options)); } } // RECIPE SELECTOR recipeSelector?.DrawRecipeSelector(recipeRect); // COUNT FIELD if (recipeSelector?.selectedRecipe != null) { recipeSelector?.DrawCountField(countRect); } // DRAW YOUR CHILDREN if (recipeSelector != null && recipeSelector.selectedRecipe != null && recipeSelector.children != null) { // For some reason just plain copying cur (or even the elements of cur) doesn't work (I'm quite possibly misunderstanding how this works) float x = cur.x; float y = cur.y; var pos = new Vector2(x, y); foreach (IngredientSelector child in recipeSelector.children) { child.DrawSelectorRow(ref cur, width, nesting + 1, pos); } } }
public static bool HasRecipeChoices(Map map, IngredientSelector ingredient) { return(ingredient.allowedThingDefs.Any(td => RecipeSelector.HasRecipe(map, td))); }