public bool IsEntityCompliant(Hoverable component) { if (component != null) { return(component.GetComponent <School>() != null); } return(false); }
public void OnHover(Hoverable hoverable) { var sinValue = (Mathf.Sin(Time.time * Frequency) * Stretch + YShift) * Squash; hoverable .GetComponent <Renderer>() .material .SetColor("_EmissionColor", Color.Lerp(Color.black, HoverColor, sinValue)); }
public bool IsEntityOrParentCompliant(Hoverable component) { return (component.GetComponentInParent <School>() != null || component.GetComponent <School>() != null); }
public void OnBlur(Hoverable hoverable) { hoverable .GetComponent <Renderer>() .material.SetColor("_EmissionColor", Color.black); }
public bool IsCompliant(Hoverable hoverable) { return(hoverable.GetComponent <House>() != null); }
void onHover(Ray ray, RaycastHit2D hit) { hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity); if (hit.collider != null) { if (hit.collider.GetComponent <Hoverable>()) { Hoverable entity = hit.collider.GetComponent <Hoverable>(); entity.hovering = true; if (prevEntity && entity.id != prevEntity.id) { prevEntity.hovering = false; } if (entity.GetComponent <Tile>()) { Tile tile = entity.GetComponent <Tile>(); player.hoveringTile = tile; if (Input.GetMouseButtonDown(0)) { if (!inventoryOpen) { if (player.selectedItem == "empty") { player.mineTile(tile); } else { player.placeItem(tile); } } } else if (Input.GetMouseButtonDown(1)) { player.breakMachine(tile); } else if (Input.GetKeyDown(KeyCode.R)) { player.rotateTile(tile); } } else { if (Input.GetMouseButtonDown(0)) { if (entity.GetComponent <Slot>()) { Slot slot = entity.GetComponent <Slot>(); player.setSelectedItem(slot.item); } } } if (entity.GetComponent <Recipe>()) { Recipe recipe = entity.GetComponent <Recipe>(); crafting.updateText(recipe); if (prevEntity && entity.id != prevEntity.id) { crafting.updateColors(recipe); } if (Input.GetMouseButtonDown(0)) { crafting.craft(recipe); } } else { crafting.resetText(); } if (entity.GetComponent <GroundItem>()) { if (Input.GetMouseButtonDown(0)) { SpriteRenderer renderer = entity.GetComponent <SpriteRenderer>(); inventoryService.addItem(renderer.sprite.name, 1); Destroy(entity.gameObject); } } prevEntity = entity; } } }