コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: CookingPot.cs プロジェクト: TotallyNotYifei/wedding
        /// <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);
            }
        }
コード例 #3
0
 public void Hold(IHoldable toHold)
 {
     toHold.holder         = this;
     held                  = toHold;
     toHold.SmoothMovement = smoothMovement;
     toHold.OnHold(this);
 }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
    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);
    }
コード例 #6
0
        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();
                }
            }
        }
コード例 #7
0
    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);
        }
    }
コード例 #8
0
ファイル: Plate.cs プロジェクト: TotallyNotYifei/wedding
        /// <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);
        }
コード例 #9
0
 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;
 }
コード例 #10
0
    void ThrowHeldObject()
    {
        m_HoldingObject = false;
        heldObject.Throw(transform.forward * m_ThrowStrenght);
        m_HeldRigidbody = null;
        heldObject      = null;

        m_InteractableSensor.SetHoldingObject(false);
    }
コード例 #11
0
    private void AvailabilityChanged()
    {
        IHoldable card = _cardData as IHoldable;

        if (card != null)
        {
            _onAvailabilityChanged.Invoke(card.Available);
        }
    }
コード例 #12
0
    void DropHeldObject()
    {
        m_HoldingObject = false;
        heldObject.Drop();
        m_HeldRigidbody = null;
        heldObject      = null;

        m_InteractableSensor.SetHoldingObject(false);
    }
コード例 #13
0
    void GetHeldObject(IHoldable holdable, Rigidbody rb)
    {
        this.heldObject = holdable;
        m_HeldRigidbody = rb;
        m_HoldingObject = true;

        m_InteractableSensor.SetHoldingObject(true);
        m_InteractableSensor.ResetClosestInteractable();
    }
コード例 #14
0
        public bool TryAdd(IHoldable newItem)
        {
            if (this.CurrentlyHolding != null)
            {
                return(false);
            }

            this.CurrentlyHolding = newItem;
            return(true);
        }
コード例 #15
0
ファイル: Player.cs プロジェクト: MarkShteller/Overcleaned
    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;
    }
コード例 #16
0
ファイル: Player.cs プロジェクト: MarkShteller/Overcleaned
    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;
    }
コード例 #17
0
        public void Release()
        {
            if (held == null)
            {
                return;
            }

            held.OnRelease();
            held.holder     = null;
            held.holderLast = this;
            held            = null;
        }
コード例 #18
0
 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();
     }
 }
コード例 #19
0
    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;
            }
        }
    }
コード例 #20
0
        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();
            }
        }
コード例 #21
0
        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();
            }
        }
コード例 #22
0
ファイル: Room.cs プロジェクト: gammilen/CISO-simulator
    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();
        }
    }
コード例 #23
0
ファイル: Room.cs プロジェクト: gammilen/CISO-simulator
    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();
        }
    }
コード例 #24
0
ファイル: ControllerPickup.cs プロジェクト: jgrgic/Unity
    // 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);
        }
    }
コード例 #25
0
        /// <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);
        }
コード例 #26
0
    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;
                }
            }
        }
    }
コード例 #27
0
    /// <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;
    }
コード例 #28
0
ファイル: GrabCommand.cs プロジェクト: Predatorie/QuestLike
        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);
        }
コード例 #29
0
ファイル: CookingPan.cs プロジェクト: TotallyNotYifei/wedding
        /// <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);
        }
コード例 #30
0
ファイル: ControllerState.cs プロジェクト: jgrgic/Unity
 // Creates a new state with the given information.
 public ControllerState NewHoldingState(IHoldable newHolding)
 {
     return(new ControllerState(Squeezing, newHolding, Interacting));
 }
コード例 #31
0
ファイル: Item.cs プロジェクト: technorover/Technorover-Labs
 public Item(IHoldable item, int maxStackSize, Boolean placeable)
 {
     this.objectInSlot = item;
     this.maxStackSize = maxStackSize;
     this.placeable = placeable;
 }