public void Add(FurnitureStack stack)
    {
        FurnitureStack existing = FindStackMatching(stack);

        if (existing != null)
        {
            existing.IncrementCount(stack.Count);
        }
        else
        {
            furnitureStacks.Add(stack);
        }
    }
    public void SubtractOne(uint fid)
    {
        FurnitureStack existing = FindStackMatching(fid);

        if (existing != null)
        {
            existing.IncrementCount(-1);
            if (existing.Count <= 0)
            {
                RemoveStacksWithID(existing.FurnitureID);
            }
        }
        else
        {
            Debug.LogError("Trying to subtract from a stack that doesn't exist!");
        }
    }
Beispiel #3
0
    private IEnumerator StartPlacing(FurnitureStack stack, Furniture_hovering draggedObject)
    {
        if (stack.Count > 0)
        {
            if (furnitureCount != null)
            {
                furnitureCount.text = (stack.Count - 1).ToString();
            }

            while (true)
            {
                if (Input.GetMouseButton(0))
                {
                    draggedObject.PositionOverMouse();
                    yield return(new WaitForFixedUpdate());
                }
                else
                {
                    if (PlaceHoveringFurniture(stack.FurnitureID, draggedObject))
                    {
                        // Placed successfully. Subtract item from Game.current.furnitureInventory
                        Game.current.furnitureInventory.SubtractOne(stack.FurnitureID);
                        PlaySound(placedSuccessfullySound);
                    }
                    else
                    {
                        // Didn't place successfully. Restore the count.
                        furnitureCount.text = stack.Count.ToString();
                    }

                    Destroy(draggedObject.gameObject);
                    break;
                }
            }
        }
        else
        {
            Debug.Log("You don't have enough of this furniture item.");
            Destroy(draggedObject.gameObject);
        }
    }
Beispiel #4
0
    public void DisplayFurnitureItem(FurnitureStack stack)
    {
        MetaInformation info = MetaInformation.Instance();

        if (info != null)
        {
            GameObject furnitureObj = info.GetFurniturePrefabByID(stack.FurnitureID);

            if (furnitureObj != null)
            {
                Furniture furniture = furnitureObj.GetComponent <Furniture> ();

                if (furnitureIcon != null)
                {
                    furnitureIcon.sprite = furniture.GetIcon();
                }
                if (furnitureName != null)
                {
                    furnitureName.text = furnitureObj.name;
                }
                if (furnitureCount != null)
                {
                    furnitureCount.text = stack.Count.ToString();
                }

                representedStack = stack;
                okayToDrag       = true;
                hoverPrefab      = furniture.GetHoveringPrefab();
            }
            else
            {
                Debug.LogErrorFormat("Furniture doesn't exist! Something's wrong.");
            }
        }
        else
        {
            Debug.Log("MetaInformation is null.");
        }
    }
 private FurnitureStack FindStackMatching(FurnitureStack stack)
 {
     return(FindStackMatching(stack.FurnitureID));
 }
Beispiel #6
0
 public DisplayedFurnitureStack(FurnitureStack f)
 {
     fid   = f.FurnitureID;
     count = f.Count;
 }