示例#1
0
    void OnMouseUp()
    {
#else
    void OnHoverMouseUp()
    {
#endif

        if (!librarian.CanSelect())
        {
            return;
        }

        librarian.WallSelected(this);
        Select();
    }

#if MOBILE
    void OnMouseOver()
    {
#else
    void OnHover()
    {
#endif

        if (!IsSelected && !librarian.IsSwipingCamera)
        {
            highlight.SetActive(true);
            librarian.HoveringOver(this);
        }
    }

#if MOBILE
    void OnMouseExit()
    {
#else
    void OnHoverExit()
    {
#endif

        highlight.SetActive(false);
        librarian.HoveringOverEnded(this);
    }

    private void GenerateShelves()
    {
        for (int i = 0; i < 5; i++)
        {
            var newShelfPos = firstShelf.transform.position;
            newShelfPos.y += i * ShelfDistance;

            var newShelfGO = Instantiate(firstShelf.gameObject, transform, true) as GameObject;
            newShelfGO.transform.position = newShelfPos;
            newShelfGO.name = "Shelf " + (i + 1);
            var shelf = newShelfGO.GetComponent <Shelf>();
            shelf.librarian = librarian;
            shelf.Wall      = this;
            shelf.Number    = i + 1;

            shelf.GenerateBooks();
        }

        firstShelf.GenerateBooks();
        firstShelf.gameObject.SetActive(false);
    }

    public void Select()
    {
        IsSelected = true;
        highlight.SetActive(false);

        foreach (var collider in boxColliders)
        {
            collider.enabled = false;
        }
    }