예제 #1
0
    private bool PlaceHoveringFurniture(uint fid, Furniture_hovering draggedObject)
    {
        Shop shop = Game.current.shop;

        if (shop != null)
        {
            var shopCoords = draggedObject.GetShopPosition();

            var furnitureObj = Furniture.InstantiateFurnitureByID(fid);
            var furniture    = furnitureObj.GetComponent <Furniture> ();


            if (!furniture.PlaceAtLocation(shop, shopCoords))
            {
                Destroy(furnitureObj);
                return(false);
            }
            else
            {
                return(true);
            }
        }
        else
        {
            Debug.LogError("No shop object found!");
            return(false);
        }
    }
예제 #2
0
    void OnWizardCreate()
    {
        GameObject myFurniture         = new GameObject(furnitureName);
        GameObject myFurnitureHovering = new GameObject(hoveringName);



        Furniture          furniture = myFurniture.AddComponent <Furniture> ();
        Furniture_hovering hovering  = myFurnitureHovering.AddComponent <Furniture_hovering> ();


        furniture.hoveringPrefab   = hovering;
        hovering.originalFurniture = furniture;
    }
예제 #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);
        }
    }
예제 #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.");
        }
    }