Esempio n. 1
0
    void UpdateMouseHover()
    {
        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);

        hoverObject = hit ? hit.collider.gameObject : null;

        MouseHoverCategories newHoverCat = MouseHoverCategories.NULL;

        if (hoverObject != null)
        {
            IClickable clickable = hoverObject.GetComponent <IClickable>();
            if (clickable != null)
            {
                newHoverCat = clickable.GetClickableCategory();
            }
            else
            {
                CharacterStats stats = hoverObject.GetComponent <CharacterStats>();
                if (stats != null)
                {
                    newHoverCat = MouseHoverCategories.ME;
                }
                else
                {
                    PlayerEgg egg = hoverObject.GetComponent <PlayerEgg>();
                    if (egg != null)
                    {
                        newHoverCat = MouseHoverCategories.EGG;
                    }
                    else
                    {
                        //Only other option initially is ground.
                        //This may need to be udpated later
                        newHoverCat = MouseHoverCategories.GROUND;
                    }
                }
            }
        }

        SetCurrentHover(newHoverCat);
    }