void CheckForLookedAtObjects() { Vector3 endPoint = (transform.forward * maxDistanceToActivate) + transform.position; Debug.DrawLine(transform.position, endPoint, Color.red); RaycastHit raycastHit; if (Physics.Raycast(transform.position, transform.forward, out raycastHit, maxDistanceToActivate, layerToCheckForInteractables)) { //Debug.Log(raycastHit.transform.gameObject.name); lookedAtNPC = raycastHit.transform.gameObject.GetComponent <IActivateable>(); lookedAtNPCObject = raycastHit.transform.gameObject; if (lookedAtNPCObject.GetComponent <NPC>() != null) { lookedAtNPCObject.transform.GetChild(0).gameObject.SetActive(true); //indicator showing you can talk to NPC } } else { if (lookedAtNPCObject != null && lookedAtNPCObject.GetComponent <NPC>() != null) { lookedAtNPCObject.transform.GetChild(0).gameObject.SetActive(false); } //indicator showing you can talk to NPC lookedAtNPC = null; lookedAtNPCObject = null; } }
private void Awake() { player = GameObject.Find("Player"); _input = player.GetComponent <playerInput>(); activateable = GetComponent <IActivateable>(); ePopup = this.transform.GetChild(0).gameObject; }
/** * Force an activatable to be unpressed even when the user has not released it. * Normally used when a button is about to be hidden. */ public void ForceUnpress(IActivateable button) { if (pressedActivatableReleases.ContainsKey(button)) { var unpress = pressedActivatableReleases[button]; unpress(); pressedActivatableReleases.Remove(button); } }
void Awake() { activator = activatingGameObject.GetComponent <IActivateable>(); if (activator == null) { return; } activator.OnActivated += onActivatorFired; }
//calls the activate method in any activateable traits public void Activate() { TraitBase[] tempTraits = GetArray(); for (int i = 0; i < tempTraits.Length; i++) { if (tempTraits[i] is IActivateable) { IActivateable activateable = (IActivateable)tempTraits[i]; activateable.Activate(); } } }
void Awake() { if (enablingGameObject == null) { return; } enabler = enablingGameObject.GetComponent <IActivateable>(); if (enabler == null) { return; } enabler.OnActivated += onEnablerTriggered; onMaterial = GetComponent <MeshRenderer>().material; }
void CheckForLookedAtObjects() { Vector3 endPoint = (transform.forward * maxDistanceToActivate) + transform.position; Debug.DrawLine(transform.position, endPoint, Color.red); RaycastHit raycastHit; if (Physics.Raycast(transform.position, transform.forward, out raycastHit, maxDistanceToActivate, layerToCheckForInteractables)) { //Debug.Log(raycastHit.transform.gameObject.name); lookAtObjectText.gameObject.SetActive(true); lookedAtNPC = raycastHit.transform.gameObject.GetComponent <IActivateable>(); lookedAtNPCObject = raycastHit.transform.gameObject; lookAtObjectText.text = "Activate " + raycastHit.transform.gameObject.name + " with 'Q'"; } else { lookAtObjectText.gameObject.SetActive(false); } }
// creates an auto scroller object for the tests private AutoScroller CreateAutoScroller(out IScrollView scrollView, out IRectangle content, out IActivateable elementToStartScroller) { scrollView = A.Fake <IScrollView>(); content = A.Fake <IRectangle>(); elementToStartScroller = A.Fake <IActivateable>(); AutoScroller autoScroller = new AutoScroller(scrollView, content, elementToStartScroller); return(autoScroller); }
public void AddToActivatable(IActivateable a) { activatable.Add(a); }