/// <summary> /// Try to place an item /// </summary> /// <param name="item">Item to be placed</param> /// <returns>True if the item can be placed on this map object</returns> public override bool TryAdd(IHoldable item) { var itemObj = item as Holdable; if (!itemObj) { return(false); } if (this.CurrentlyPlaced != null) { var currentPlacecdContainer = this.CurrentlyPlaced as IContainer; if (currentPlacecdContainer != null) { return(currentPlacecdContainer.TryAdd(item as Ingredient)); } else { return(false); } } this.CurrentlyPlaced = itemObj; itemObj.transform.position = this.transform.position + new Vector3(0, Config.ItemPlacementHeight); return(true); }
/// <summary> /// Try to add an additional ingredient /// </summary> /// <param name="newItem"></param> /// <returns></returns> public override bool TryAdd(IHoldable newItem) { var newIngredient = newItem as Ingredient; if (newIngredient == null) { return(false); } if (newIngredient.IngredientType != IngredientEnum.Onion || !newIngredient.IsChopped) { return(false); } if (this.Ingredients.Count < 3) { this.Ingredients.Add(newIngredient); newIngredient.gameObject.SetActive(false); this.ProgressLimit = 0.334f * this.Ingredients.Count; this.ResetTimeTillBurn(); this.ProgressBar.gameObject.SetActive(true); return(true); } else { return(false); } }
public void Hold(IHoldable toHold) { toHold.holder = this; held = toHold; toHold.SmoothMovement = smoothMovement; toHold.OnHold(this); }
/// <summary> /// Try to place an item /// </summary> /// <param name="item">New item to be placed</param> /// <returns>True if operation succeed</returns> public override bool TryAdd(IHoldable item) { if (!(item is Ingredient)) { return(false); } var ingredient = item as Ingredient; if (ingredient.IsChopped) { return(false); } if (!Choppable.Contains(ingredient.IngredientType)) { return(false); } this.CurrentlyPlaced = ingredient; this._currentPlacedIngredient = ingredient; this._chopProgress = 0; ingredient.transform.position = this.transform.position + new UnityEngine.Vector3(0, Config.ItemPlacementHeight); this.ProgressBar.gameObject.SetActive(true); return(true); }
public bool addItem(IHoldable item) { int counter = 0; bool final = false; for (int i = 1; i < inventory.Length; i++) { if (inventory[i] != null) { if (inventory[i].Equals(item)) { final = false; break; } if (counter == inventory.Length - 1) { ReplaceInventory(item); final = true; } else { counter++; } } else { inventory[i] = item; final = true;; break; } } return(final); }
protected void PutInSlot(Button slot, IHoldable holdable) { if (slot != null) { var trigger = slot.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerUp; entry.callback.AddListener((data) => { player.TakeInHand(holdable); foreach (var item in AllSlots) { slotSelector.Deselect(item.gameObject); } slotSelector.Select(data.selectedObject); }); trigger.triggers.Add(entry); // set name to slot var text = slot.GetComponentInChildren <Text>(); if (text != null) { text.text = holdable == null ? "Empty" : holdable.ToString(); } } }
int addItem(IHoldable item) { int counter = 0; if (inventory.Contains(item)) { return(0); } else { for (int i = 1; i < inventory.Length; i++) { if (inventory [i] == null) { inventory [i] = item; break; } else { if (counter == inventory.Length - 1) { ReplaceInventory(item); } else { counter++; } } } return(1); } }
/// <summary> /// Try to add a new ingredient to a plate /// </summary> /// <param name="newItem">New ingredient to be added</param> /// <returns>True if operation succeed</returns> public override bool TryAdd(IHoldable newItem) { var newIngredient = newItem as Ingredient; if (newIngredient == null) { return(false); } if (_choppedOnlyitems.Contains(newIngredient.IngredientType) && !newIngredient.IsChopped) { return(false); } if (this.Ingredients.Any(existIng => existIng.IngredientType == newIngredient.IngredientType)) { return(false); } // Check for single plate stuff if (this.Ingredients.Count != 0 && _singleOnlyItems.Contains(newIngredient.IngredientType)) { return(false); } this.Ingredients.Add(newIngredient); newIngredient.transform.parent = this.transform; newIngredient.transform.localPosition = UnityEngine.Vector3.zero; return(true); }
public void PickUpObject(GameObject p_currentFood) { m_holdableObject = p_currentFood.GetComponent <IHoldable>(); m_heldObjectTrasform = p_currentFood.transform; p_currentFood.transform.position = m_heldFoodPosition.position; p_currentFood.transform.parent = m_heldFoodPosition; p_currentFood.transform.localRotation = Quaternion.identity; }
void ThrowHeldObject() { m_HoldingObject = false; heldObject.Throw(transform.forward * m_ThrowStrenght); m_HeldRigidbody = null; heldObject = null; m_InteractableSensor.SetHoldingObject(false); }
private void AvailabilityChanged() { IHoldable card = _cardData as IHoldable; if (card != null) { _onAvailabilityChanged.Invoke(card.Available); } }
void DropHeldObject() { m_HoldingObject = false; heldObject.Drop(); m_HeldRigidbody = null; heldObject = null; m_InteractableSensor.SetHoldingObject(false); }
void GetHeldObject(IHoldable holdable, Rigidbody rb) { this.heldObject = holdable; m_HeldRigidbody = rb; m_HoldingObject = true; m_InteractableSensor.SetHoldingObject(true); m_InteractableSensor.ResetClosestInteractable(); }
public bool TryAdd(IHoldable newItem) { if (this.CurrentlyHolding != null) { return(false); } this.CurrentlyHolding = newItem; return(true); }
public void DropGameObject(Vector3 position) { GameObject gObj = this._currentHeld.GetGameObject(); gObj.transform.parent = null; gObj.transform.position = position; gObj.transform.rotation = Quaternion.identity; gObj.GetComponent <Collider>().enabled = true; this._currentHeld = null; }
public void HoldGameObject(IHoldable obj) { GameObject gObj = obj.GetGameObject(); gObj.transform.parent = PlayerHand.transform; gObj.transform.localPosition = Vector3.zero; gObj.transform.localRotation = Quaternion.identity; gObj.GetComponent <Collider>().enabled = false; this._currentHeld = obj; }
public void Release() { if (held == null) { return; } held.OnRelease(); held.holder = null; held.holderLast = this; held = null; }
public virtual void TakeInHand(IHoldable holdable) { if (Holds != null) // hides previous object in hands { Holds.Hide(); } Holds = holdable; if (Holds != null) // shows new object in hands { Holds.Show(); } }
void ReplaceInventory(IHoldable item) { IHoldable repalce = inventory[0]; for (int i = 1; i < inventory.Length; i++) { if (inventory[i].Equals(repalce)) { inventory[i] = item; inventory[0] = item; } } }
public void ReleaseResource(ICard card) { IHoldable cardH = card as IHoldable; ICardWithParameters cardP = card as ICardWithParameters; DepartmentResources dr = GetResourcesForType(card.type); if (dr != null && cardH != null && cardP != null && dr.Cards.SingleOrDefault(c => c == card) != null) { int sum = cardP.GetSumByParam(DepartmentParameter); dr.Available += sum; ResourcesChanged(dr); cardH.Release(); } }
public void OccupyResource(ICard card) { IHoldable cardH = card as IHoldable; ICardWithParameters cardP = card as ICardWithParameters; DepartmentResources rc = GetResourcesForType(card.type); if (rc != null && cardH != null && cardP != null && rc.Cards.SingleOrDefault(c => c == card) != null) { int sum = cardP.GetSumByParam(DepartmentParameter); rc.Available -= sum; ResourcesChanged(rc); cardH.Hold(); } }
public void ReleaseResource(ICard card) /// { IHoldable cardH = card as IHoldable; ICardWithParameters cardP = card as ICardWithParameters; RoomResources rc = GetRoomResourcesForType(card.type); if (rc != null && cardH != null && cardP != null && rc.cards.SingleOrDefault(c => c == card) != null) { int sum = cardP.GetSumByParam(Designation.value); rc.available += sum; resourcesChanged.Invoke(rc.general, rc.available, card.type); cardH.Release(); } }
public void OccupyResource(ICard card) /// { Debug.Log("occupy resource1"); IHoldable cardH = card as IHoldable; ICardWithParameters cardP = card as ICardWithParameters; RoomResources rc = GetRoomResourcesForType(card.type); if (rc != null && cardH != null && cardP != null && rc.cards.SingleOrDefault(c => c == card) != null) { Debug.Log("occupy resource2"); int sum = cardP.GetSumByParam(Designation.value); rc.available -= sum; resourcesChanged.Invoke(rc.general, rc.available, card.type); cardH.Hold(); } }
// Picks up a game object. public void PickUp(IHoldable holdable) { // TODO: set the anchor to the hand with: holdable.rigidbody.transform if (_fixedJoint.connectedBody != holdable.PhysicsBody) { // If already holding an item, then let go of it. if (_fixedJoint.connectedBody != null) { LetGo(); } // Hold the new item. holdable.PhysicsBody.transform.position = transform.position; _fixedJoint.connectedBody = holdable.PhysicsBody; OnStartedHolding(EventArgs.Empty); } }
/// <summary> /// Try to place an item /// </summary> /// <param name="newItem">New item to be placed</param> /// <returns>True if operation succeed</returns> public override bool TryAdd(IHoldable newItem) { // If there's nothing on top, only pans and pots can be placed if (this.CurrentContainer != null) { return(false); } var newCookingContainer = newItem as CookingContainer; if (newCookingContainer == null) { return(false); } newCookingContainer.transform.position = this.transform.position + new Vector3(0, Config.ItemPlacementHeight); newCookingContainer.IsOnBurner = true; this.CurrentContainer = newCookingContainer; return(true); }
private void InputCheck() { if (GlobalInputController.Instance.useKeyDown) { if (currentHold != null) { if (currentHold.HoldState == HoldState.Holding) { AnimState = AnimState.Attack; _anim.SetInteger("ActionState", (int)AnimState); _anim.SetTrigger("ActionStateOnChange"); currentHold.Use(); } } else if (currentItem != null) { if (currentItem.InteractState == InteractState.Interactable) { currentItem.Interact(this); var holdable = currentItem.GameObject.GetComponent <IHoldable>(); if (holdable != null) { AnimState = AnimState.Hold; currentHold = holdable; _anim.SetInteger("ActionState", (int)AnimState); _anim.SetTrigger("ActionStateOnChange"); } } } } if (GlobalInputController.Instance.cancelKeyDown) { if (currentHold != null) { if (currentHold.HoldState == HoldState.Holding) { currentHold.Release(); currentHold = null; } } } }
/// <summary> /// Empties the player's hand, dropping whatever they are currently holding /// </summary> /// <param name="p_objectUsed"></param> public void EmptyHand(bool p_objectUsed, bool p_discardItem = true) { SetHoldingSandwhichState(false); m_heldObjectTrasform.parent = null; if (p_discardItem) { if (p_objectUsed) { m_holdableObject.UseObject(); } else { m_holdableObject.DropObject(); } } m_holdableObject = null; m_heldObjectTrasform = null; }
bool HoldableSafePlace(Item item, IHoldable holdable) { if (!item.Grabable) { GameScreen.PrintLine("\nYou cannot grab this item."); return(false); } else if (!Game.GetPlayer.IsInRangeOf(item, Game.GetPlayer.InteractionRanges.grabRange)) { GameScreen.PrintLine("\nYou are not close enough to grab this."); return(false); } if (holdable.IsHoldingItem) { GameScreen.PrintLine($"\nThe item <{Color.Cyan.ToInteger()},look at {holdable.HoldingItem.ID}>{holdable.HoldingItem.Name}@ is already being held - would you like to swap it for <{Color.Cyan.ToInteger()},look at {item.ID}>{item.Name}@?"); Utilities.PromptYesNo((answer, cancelled) => { if (answer && !cancelled) { var old = holdable.SwitchItems(item); var casted = holdable as GameObject; GameScreen.PrintLine($"\nMoved <{Color.Cyan.ToInteger()},look at {item.ID}>{item.Name}@ to <{Color.Cyan.ToInteger()},look at {casted.ID}>{casted.Name}@"); GameScreen.PrintLine($"Moved <{Color.Cyan.ToInteger()},look at {old.ID}>{old.Name}@ to <{Color.Cyan.ToInteger()},look at {old.container.GetTypedCollection().owner.ID}>{ old.container.GetTypedCollection().owner.Name}@"); } else { GameScreen.PrintLine($"\nLeft the <{Color.Cyan.ToInteger()},look at {item.ID}>{ item.Name }@ where it is."); } }); } else { holdable.PutItem(item); GameScreen.PrintLine($"\nMoved <{Color.Cyan.ToInteger()},look at {item.ID}>{ item.Name }@ to <{Color.Cyan.ToInteger()},look at {(holdable as GameObject).ID}>{ (holdable as GameObject).Name }@"); } return(false); }
/// <summary> /// Try to add an ingredient to the pan /// </summary> /// <param name="newIngredient">new ingredient to be added</param> /// <returns>True if ingredient was added successfull</returns> public override bool TryAdd(IHoldable newIngredient) { var newIngObj = newIngredient as Ingredient; if (newIngObj == null) { return(false); } if (this.Ingredients.Count > 0) { return(false); } if (newIngObj.IngredientType == IngredientEnum.RawMeat && newIngObj.IsChopped) { this.Ingredients.Add(newIngObj); newIngObj.transform.position = this.transform.position; this.ProgressBar.gameObject.SetActive(true); this.ProgressLimit = 1; return(true); } return(false); }
// Creates a new state with the given information. public ControllerState NewHoldingState(IHoldable newHolding) { return(new ControllerState(Squeezing, newHolding, Interacting)); }
public Item(IHoldable item, int maxStackSize, Boolean placeable) { this.objectInSlot = item; this.maxStackSize = maxStackSize; this.placeable = placeable; }