bool MouseOverHighlightAndClick() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool isFound = false; if (Physics.Raycast(ray, out hit)) { if (hit.point.y >= 0) { var go = hit.transform.gameObject; //Debug.Log("hit " + go); var gr = go.GetComponentInParent <EntityGraphics>(); if (gr != null && gr is IClickable) { isFound = true; if (!((IHighlightable)gr).CanBeHighlighted) { if (gr.highlight.isHighlightEnabled) { gr.highlight.DisableHighlight(); mouseOverClickable = null; } } else { if (gr != mouseOverClickable) { if (mouseOverClickable != null) { mouseOverClickable.highlight.DisableHighlight(); } mouseOverClickable = gr; gr.highlight.EnableHighlight(); } } } } } if (!isFound && mouseOverClickable != null) { mouseOverClickable.highlight.DisableHighlight(); mouseOverClickable = null; } if (mouseOverClickable != null && Input.GetMouseButtonDown(0)) { E.player.Clicked(mouseOverClickable.entity); return(true); } return(false); }
public void SetData(IEntity actor, EntityGraphics graphics) { m_entity = actor; m_entity.gameObject = this.gameObject; m_entity.OnSpawn(); m_graphics = graphics; GetComponent <SpriteRenderer>().sprite = m_graphics.defaultSprite; }
public Highlight(EntityGraphics mainGraphics) { this.mainGraphics = mainGraphics; }