public void ApplyUse(IInteractionComponent interactor) { if (state == States.Closed) { Open(); return; } switch (interactor.CurrentItem) { case null: var newMilk = Instantiate(milkPrefab).GetComponent <Milk>(); if (!interactor.ReceiveItem(newMilk)) { Destroy(newMilk.gameObject); return; } GameManager.House.AddTemporaryItem(newMilk); break; case Milk _: var milk = interactor.RemoveItem(); milk.Destroy(); break; } Close(); }
public InteractionTypes Use(IInteractionComponent interactor) { switch (state) { case States.Empty: if (interactor.CurrentItem != null) { return(InteractionTypes.Place); } return(InteractionTypes.None); case States.HasItem: if (interactor.CurrentItem != null) { return(item.CanCombine(interactor.CurrentItem.Ingredient)); } return(InteractionTypes.Grab); default: Debug.LogError("invalid state: " + state); break; } return(InteractionTypes.None); }
public void ApplyUse(IInteractionComponent interactor) { switch (state) { case States.None: if (interactor.CurrentItem is Cup c && !c.HasCoffee) { state = States.Operating; TakeCup((Cup)interactor.RemoveItem()); GameManager.Gameplay.DisablePlayerInput(); } break; case States.Ready: if (interactor.ReceiveItem(heldCup)) { heldCup.gameObject.SetActive(true); heldCup.AddCoffee(true); cupVisual.gameObject.SetActive(false); heldCup = null; state = States.None; } break; } }
public void ApplyUse(IInteractionComponent interactor) { switch (state) { case States.Empty: if (interactor.CurrentItem == null) { return; } Set(interactor.RemoveItem()); break; case States.HasItem: if (interactor.CurrentItem != null) { item.Combine(interactor.CurrentItem.Ingredient); return; } if (interactor.ReceiveItem(item)) { item = null; state = States.Empty; } break; default: throw new ArgumentOutOfRangeException(); } }
public InteractionTypes Use(IInteractionComponent interactor) { switch (state) { case States.None: if (heldCup == null && interactor.CurrentItem is Cup c && !c.HasCoffee) { GameManager.Camera.Zoom(zoomTransform); return(InteractionTypes.Place); } break; case States.Ready: if (interactor.CurrentItem == null) { return(InteractionTypes.Grab); } break; default: return(InteractionTypes.None); } return(InteractionTypes.None); }
public override void Use(IInteractionComponent interactor) { if (!CanDrink(interactor)) { return; } GameManager.Data.HadCoffee = true; Empty(); }
public InteractionTypes Use(IInteractionComponent interactor) { if (!hasSpoken) { hasSpoken = true; GameManager.UI.ShowDialogue("Cow", "Yes?"); } return(InteractionTypes.None); }
public void TestInvalidInit() { var map = LanguageMap.EnglishUS("test"); var resp = new ResponsePattern(new CharacterString("test")); var choice = new IInteractionComponent[] { new InteractionComponent("test") }; Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, null, null, null)); Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, null, map, null)); Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(resp, null, map, map)); Assert.Throws <ArgumentNullException>(() => new ChoiceInteractionActivityDefinition(null, choice, map, map)); }
public void ApplyUse(IInteractionComponent interactor) { if (state == States.Closed) { Open(); } else { Close(); } }
public override InteractionTypes Use(IInteractionComponent interactor) { var currentDay = GameManager.Data.Day; var canLeave = GameManager.Data.HadCoffee; var text = canLeave ? GetSuccessText(currentDay) : GetFailureText(currentDay); GameManager.UI.ShowDialogue("Door", text); if (canLeave) { return(base.Use(interactor)); } return(InteractionTypes.None); }
public InteractionTypes Use(IInteractionComponent interactor) { if (state == States.Closed) { return(InteractionTypes.Open); } switch (interactor.CurrentItem) { case null: return(InteractionTypes.Grab); case Milk _: return(InteractionTypes.Place); default: return(InteractionTypes.None); } }
public override void Draw(SpriteBatch spriteBatch) { if (player.Inventory.HasToolSelected) { Tool selectedTool = player.Inventory.SelectedTool; IInteractionComponent interactionComponent = selectedTool.Components.GetComponent( c => c is IInteractionComponent) as IInteractionComponent; // ei pitäs olla null ikinä if (interactionComponent != null && interactionComponent.IsInteracting) { foreach (RenderMatrix l_render in m_renderList) { Texture2D texture = m_tx[l_render.Folder]; Rectangle?source = m_rect[l_render.Folder][l_render.File]; if (l_render.Folder == 2) { texture = selectedTool.Texture ?? texture; source = null; } spriteBatch.Draw( texture, l_render.Location, source, m_color * l_render.Alpha, l_render.Rotation, l_render.Pivot, l_render.Scale, l_render.Effects, /*(float)l_render.ZOrder*/ 0.0f ); } return; } } base.Draw(spriteBatch); }
public override InteractionTypes CanUse(IInteractionComponent interactor) { return(CanDrink(interactor) ? InteractionTypes.Drink : InteractionTypes.None); }
private bool CanDrink(IInteractionComponent interactor) { return(IsReady && interactor.CurrentItem is Cup cup && cup == this); }
public abstract InteractionTypes CanUse(IInteractionComponent interactor);
public override void Use(IInteractionComponent interactor) { }
public override InteractionTypes CanUse(IInteractionComponent interactor) => InteractionTypes.None;
public abstract void Use(IInteractionComponent interactor);
public virtual InteractionTypes Use(IInteractionComponent interactor) { return(InteractionTypes.Open); }
public void ApplyUse(IInteractionComponent interactor) { }