// Update is called once per frame void Update() { // activationRay = new Ray (transform.position, transform.forward); RaycastHit hit; try{ if (Physics.Raycast(transform.position, transform.forward, out hit, ActivationDistance)) { if (hit.collider.GetComponent <IActivate> () != null) { IActivate active = hit.collider.GetComponent <IActivate> (); if (Input.GetKeyDown(KeyCode.F)) { active.Activate(this); } else { ActivationToolTipText.text = active.GetToolTip(); } } else { ActivationToolTipText.text = emptyString; } } else { ActivationToolTipText.text = emptyString; } } catch { //idc } }
private bool TryActivateScript(IActivate puzzleScript) { if (puzzleScript != null) { puzzleScript.Activate(); return(true); } return(false); }
public void WhenActivated_ItSetsTheLocationText() { gpsLocatorMock.Setup(service => service.GetCurrentLocationAsync()).ReturnsAsync(new GpsLocation(1, 2)); gpsLocatorMock.Setup(service => service.GetCivilAddressAsync()).ReturnsAsync("Cluj Napoca"); IActivate activateableVm = viewModel as IActivate; Assert.IsTrue(viewModel.LocationText.Contains("please wait")); activateableVm.Activate(); Assert.AreEqual("Cluj Napoca", viewModel.LocationText); }
///<summary> /// Activates a child whenever the specified parent is activated. ///</summary> ///<param name="child">The child to activate.</param> ///<param name="parent">The parent whose activation triggers the child's activation.</param> public static void ActivateWith(this IActivate child, IActivate parent) { EventHandler <ActivationEventArgs> handler = (s, e) => child.Activate(); parent.Activated += handler; var deactivator = parent as IDeactivate; if (deactivator != null) { EventHandler <DeactivationEventArgs> handler2 = null; handler2 = (s, e) => { if (e.WasClosed) { parent.Activated -= handler; deactivator.Deactivated -= handler2; } }; deactivator.Deactivated += handler2; } }
public void Activate(Activator a) { target.Activate(a); }