void UpdateMouseCursor(MouseHoverCategories category, GameObject hoverObject) { switch (category) { case MouseHoverCategories.RESOURCE: Cursor.SetCursor(resourceCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.FOOD: Cursor.SetCursor(foodCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.PLAY: Cursor.SetCursor(playCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.TRAIN: Cursor.SetCursor(trainCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.ME: Cursor.SetCursor(patThePetCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.EGG: Cursor.SetCursor(eggCrackCursor, Vector2.zero, CursorMode.ForceSoftware); break; case MouseHoverCategories.NULL: case MouseHoverCategories.GROUND: default: Cursor.SetCursor(defaultCursor, Vector2.zero, CursorMode.ForceSoftware); break; } }
void SetCurrentHover(MouseHoverCategories newHoverCat) { if (currentHover != newHoverCat) { currentHover = newHoverCat; EventsManager.instance.FireMouseHoverObjectUpdatedEvent(currentHover, hoverObject); } }
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); }
private void OnMouseHoverObjectChange(MouseHoverCategories hoverCategory, GameObject hoverObject) { clickableHover = null; switch (hoverCategory) { case MouseHoverCategories.ME: hoverPopupText.text = "What a cute little pet"; hoverPopupParent.SetActive(true); break; case MouseHoverCategories.RESOURCE: case MouseHoverCategories.FOOD: case MouseHoverCategories.PLAY: case MouseHoverCategories.TRAIN: IClickable clickable = hoverObject.GetComponent <IClickable>(); if (clickable == null) { Debug.LogError("Clickable object has no clickable component", hoverObject); hoverPopupText.text = ""; hoverPopupParent.SetActive(false); } else { clickableHover = clickable; UpdateClickablePopup(); } break; case MouseHoverCategories.EGG: case MouseHoverCategories.NULL: case MouseHoverCategories.GROUND: default: hoverPopupText.text = ""; hoverPopupParent.SetActive(false); break; } }
public void FireMouseHoverObjectUpdatedEvent(MouseHoverCategories hoverObjectCategory, GameObject hoverObject) { MouseHoverObjectUpdatedEvent?.Invoke(hoverObjectCategory, hoverObject); }
private void Awake() { currentHover = MouseHoverCategories.NULL; Cursor.SetCursor(defaultCursor, Vector2.zero, CursorMode.ForceSoftware); }