void Update() { if (EzFlick && GvrController.AppButton) { OnFlickForward.Invoke(Vector3.zero); OnFlickBackward.Invoke(Vector3.zero); } if (Horizontal) { if (GvrController.Gyro.y > FlickCheck) { OnFlickForward.Invoke(GvrController.Orientation.eulerAngles); } if (GvrController.Gyro.y < -FlickCheck) { OnFlickBackward.Invoke(GvrController.Orientation.eulerAngles); } } if (Vertical) { if (GvrController.Gyro.x > FlickCheck) { OnFlickForward.Invoke(GvrController.Orientation.eulerAngles); } if (GvrController.Gyro.x < -FlickCheck) { OnFlickBackward.Invoke(GvrController.Orientation.eulerAngles); } } }
void OnTriggerStay(Collider other) { if (other.transform.tag == "Collectable") { woodTimer += Time.deltaTime; //set harvestJuice position Vector3 harvestPos = new Vector3(other.gameObject.transform.position.x, transform.position.y, other.gameObject.transform.position.z); if (harvestJuice == null) { harvestJuice = Instantiate(harvestJuicePrefab, harvestPos, Quaternion.identity, null); } harvestJuice.transform.localScale *= 1 - Time.deltaTime; if (woodTimer > 1) { onWoodHarvestAtPos.Invoke(other.transform.position); GameObject.Destroy(other.transform.gameObject); IncrementInventory(); onWoodHarvest.Invoke(); onWoodHarvestAtPos.Invoke(other.transform.position); woodTimer = 0; Destroy(harvestJuice); } } }
void Update() { if (!target || !outputOnUpdate) { return; } Output.Invoke(targetDirection); }
public void SetRotation(Vector3 vector3, bool force = false) { if (force) { transform.localRotation = Quaternion.Euler(vector3); RotateEvent.Invoke(transform.rotation.eulerAngles); return; } StopAllCoroutines(); StartCoroutine(C_SetRotation(vector3, LerpSpeed)); }
public void Vector3EventTest() { var e = new Vector3Event(); Vector3 counter = new Vector3(); e.AddListener((val) => counter += val); Assert.AreEqual(counter, new Vector3(0, 0, 0)); e.Invoke(new Vector3(1, 0, 0)); Assert.AreEqual(counter, new Vector3(1, 0, 0)); e.Invoke(new Vector3(0, 1, 0)); e.Invoke(new Vector3(0, 0, 1)); Assert.AreEqual(counter, new Vector3(1, 1, 1)); }
//public float debugOutput; public void Output3(float value) { //debugOutput = value; switch (outputAxis) { case Axis.X: OnOutput.Invoke(new Vector3(value, 0f, 0f)); break; case Axis.Y: OnOutput.Invoke(new Vector3(0f, value, 0f)); break; case Axis.Z: OnOutput.Invoke(new Vector3(0f, 0f, value)); break; default: Debug.Log("Invalid output axis " + outputAxis); break; } }
private void HandleFingerUp(LeanFinger finger) { if (ignoreStartedOverGui == true && finger.StartedOverGui == true) { return; } if (ignoreIsOverGui == true && finger.IsOverGui == true) { return; } if (requiredSelectable != null && requiredSelectable.IsSelected == false) { return; } if (onFinger != null) { onFinger.Invoke(finger); } if (onWorld != null) { var position = ScreenDepth.Convert(finger.StartScreenPosition, gameObject); onWorld.Invoke(position); } if (onScreen != null) { onScreen.Invoke(finger.ScreenPosition); } }
public void InputString(string input) { //Debug.Log("V3 " +input); Vector3 output = stringToVec(input); OutputVector3.Invoke(output); }
public IEnumerator BigBadaBoom() { doHitCheck = true; yield return(new WaitForSeconds(Random.Range(delayMin, delayMax))); if (onExplodedAt != null) { onExplodedAt.Invoke(transform.position); } ArrayUtils.Shuffle(anims); int expl = 0; while (expl < anims.Length) { anims[expl].Play(); ++expl; yield return(new WaitForSeconds(Random.Range(0.03f, 0.09f))); } // Wait a little before returning the control back to // ExplosionController. yield return(new WaitForSeconds(duration)); doHitCheck = false; }
public void SendRaycast() { if (EventSystem.current.IsPointerOverGameObject()) { //Debug.Log("sending RC hit UI"); return; } RaycastHit hit; //Physics.Raycast (cam.position, cam.forward, hit, 500) Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (TransformToRaycastFrom != null) { ray = new Ray(TransformToRaycastFrom.position, TransformToRaycastFrom.forward); } if (CameraToRaycastFrom != null) { ray = CameraToRaycastFrom.ScreenPointToRay(Input.mousePosition); } if (Physics.Raycast(ray, out hit)) { //Debug.Log("sending RC hit " + hit.transform.gameObject,hit.transform.gameObject); RaycastContol raycast; if (raycast = hit.collider.GetComponent <RaycastContol>()) { raycast.onRaycasted.GameObjectEvent.Invoke(hit.collider.gameObject); raycast.onRaycasted.PositionEvent.Invoke(hit.point); raycast.onRaycasted.GameObjectPositionEvent.Invoke(hit.collider.gameObject, hit.point); OutputRaycastPoint.Invoke(hit.point); //Debug.Log("hit " + name,hit.collider.gameObject); //onRaycasted.Invoke(); } } }
public virtual void OnFocusDrag(Vector3 dragDistance) { if (onFocusDragged != null) { onFocusDragged.Invoke(dragDistance); } }
public virtual void OnFocusScroll(Vector3 scrollDistance) { if (onFocusScrolled != null) { onFocusScrolled.Invoke(scrollDistance); } }
protected override Vector3 _Invoke(Vector3 input) { var v = base._Invoke(input); value.Invoke(v); return(v); }
// Update is called once per frame void LateUpdate() { if (Time.unscaledDeltaTime == 0) { return; } var curPosition = cachedTransform.position; var positionDelta = (curPosition - previousPosition) / Time.unscaledDeltaTime; var curRotation = cachedTransform.rotation; var rotationDelta = (curRotation.eulerAngles - previousRotation) / Time.unscaledDeltaTime; if (!positionDelta.IsNaN()) { Velocity.AddDataPoint(positionDelta); previousPosition = curPosition; } if (!rotationDelta.IsNaN()) { AngularVelocity.AddDataPoint(rotationDelta); previousRotation = curRotation.eulerAngles; } if (Events) { var eventVelocity = EventsSendLocalVelocity ? transform.TransformVector(Velocity) : Velocity; XVelocityEvent?.Invoke(eventVelocity.x); YVelocityEvent?.Invoke(eventVelocity.y); ZVelocityEvent?.Invoke(eventVelocity.z); VelocityEvent?.Invoke(eventVelocity); VelocityMagnitudeEvent?.Invoke(eventVelocity.magnitude); } }
/** * FUNCTION NAME: Update * DESCRIPTION : Manages game object movement. * INPUTS : None * OUTPUTS : None **/ void Update() { if (m_FollowMode == FollowMode.DIRECT) { //Get mouse position with z axis of 0. Vector3 vecMousePosition = Input.mousePosition; vecMousePosition = m_cMainCamera.ScreenToWorldPoint(vecMousePosition); vecMousePosition.z = -9.0f; //Assign position. m_cTransform.position = vecMousePosition; } else if (m_FollowMode == FollowMode.ROUNDED) { //Get mouse position. Vector3 vecMousePosition = Input.mousePosition; vecMousePosition = m_cMainCamera.ScreenToWorldPoint(vecMousePosition); //Rounding time! vecMousePosition.x = Mathf.RoundToInt(vecMousePosition.x); vecMousePosition.y = Mathf.RoundToInt(vecMousePosition.y); vecMousePosition.z = -9.0f; //Assign it out. m_cTransform.position = vecMousePosition; } Followed.Invoke(m_cTransform.position); }
protected override void TrySelect(LeanFinger finger, Component component, Vector3 worldPosition) { // Stores the component we will search for var selectSelf = default(LeanSelectSelf); // Was a component found? if (component != null) { var finalRoot = Root != null ? Root : transform; switch (Search) { case SearchType.GetComponent: { if (component == finalRoot) { selectSelf = this; } } break; case SearchType.GetComponentInParent: { if (TryFindInParent(component.transform, finalRoot) == true) { selectSelf = this; } } break; case SearchType.GetComponentInChildren: { if (TryFindInChildren(component.transform, finalRoot) == true) { selectSelf = this; } } break; } // Discard if tag doesn't match if (selectSelf != null && string.IsNullOrEmpty(RequiredTag) == false && selectSelf.tag != RequiredTag) { selectSelf = null; } } if (selectSelf == this) { if (onFinger != null) { onFinger.Invoke(finger); } if (onWorld != null) { onWorld.Invoke(worldPosition); } } }
public virtual void FireProyectile(RaycastHit AimRay) { float percent = Random.Range(0, 1); Vector3 AimDirection = (AimRay.point - transform.position).normalized; ReduceAmmo(1); OnFire.Invoke(AimDirection); DamageValues PistolDamage = new DamageValues(AimRay.normal, Mathf.Lerp(MinDamage, MaxDamage, percent)); //Set the Direction and Damage value if (AimRay.transform) //If the AIM Ray hit something { AimRay.transform.root.SendMessage("getDamaged", PistolDamage, SendMessageOptions.DontRequireReceiver); //Send to the thing that we hit the Damage Values if (AimRay.rigidbody) //If the thing we hit has a rigidbody { AimRay.rigidbody.AddForceAtPosition(AimDirection * Mathf.Lerp(MinForce, MaxForce, percent), AimRay.point); //Apply the force to it } BulletHole(AimRay); OnHit.Invoke(AimRay.transform); //Invoke OnHitSomething Event } }
private bool OnTouchDown(Vector3 pointerPosition) { UnityEngine.EventSystems.EventSystem eventsystem = UnityEngine.EventSystems.EventSystem.current; if (eventsystem.IsPointerOverGameObject()) { return(false); } // --- On Mouse Down --- // Check if Movement MouseArea is Hit mouseDownPosition = pointerPosition; // Do PlaneCast to Check WorldPosition of Mouse Plane plane = new Plane(transform.forward, boardOrigin.position); Ray ray = cameraReference.ScreenPointToRay(pointerPosition); if (plane.Raycast(ray, out float enter)) { mouseDownWorldPosition = ray.GetPoint(enter); //Debug.DrawLine(boardOrigin.position, mouseDownWorldPosition, Color.white, 10f); onMouseDown.Invoke(mouseDownWorldPosition); areaClicked = true; return(true); } return(false); }
protected override void UpdateState() { if (_interpolator.enabled) { _outputEvent.Invoke(new Vector3(_floatValueX.Step(_resultValue.x), _floatValueY.Step(_resultValue.y), _floatValueZ.Step(_resultValue.z))); } }
void Update() { if (_handController == null || !_handController.GetLeapController().IsConnected) { return; } var h = (Type == HandType.Left) ? Hands.Left : Hands.Right; if (h == null) { return; } if (h.Confidence < 0.7f) { return; } Direction.Invoke(h.Direction.ToQuaternion()); Position.Invoke(h.PalmPosition.ToVector3()); Fist.Invoke(Hands.GetFistStrength(h)); foreach (var f in h.Fingers) { _fingers [(int)f.Type].Invoke(f); } }
public void OnGroundClick(BaseEventData data) { PointerEventData pData = (PointerEventData)data; NavMeshHit hit; if (NavMesh.SamplePosition(pData.pointerCurrentRaycast.worldPosition, out hit, navMeshSampleDistance, NavMesh.AllAreas)) { destinationPosition = hit.position; } else { destinationPosition = pData.pointerCurrentRaycast.worldPosition; } if (PointUI) { Instantiate(PointUI, destinationPosition, Quaternion.FromToRotation(PointUI.transform.up, pData.pointerCurrentRaycast.worldNormal)); } interactables = Physics.OverlapSphere(destinationPosition, radius); foreach (var inter in interactables) { if (inter.GetComponent <IDestination>() != null) { OnInteractableClick.Invoke(inter.transform.root); //Invoke only the first interactable found return; } } OnPointClick.Invoke(destinationPosition); }
private void Target() { if (!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out var hit, Mathf.Infinity)) { return; } var target = hit.transform.GetComponent <ISelectable>(); if (target != null) { StartCoroutine(target.Highlight()); OnTarget?.Invoke(target); } else { if (SelectedUnits[0].Team == m_Team) { OnRightClick?.Invoke(hit.point + new Vector3(0, 0.25f, 0)); } Group(hit.point.With(y: 0), SelectedUnits); } }
private void HandleFingerUp(LeanFinger finger) { if (fingers.Remove(finger) == true) { if (fingers.Count + 1 == RequiredCount) { if (onFingers != null) { onFingers.Invoke(fingers); } var screenPosition = LeanGesture.GetScreenCenter(fingers); if (onWorld != null) { var worldPosition = ScreenDepth.Convert(screenPosition, gameObject); onWorld.Invoke(worldPosition); } if (onScreen != null) { onScreen.Invoke(screenPosition); } } } }
private void HandleFingerOld(LeanFinger finger) { // Ignore? if (IgnoreStartedOverGui == true && finger.StartedOverGui == true) { return; } if (IgnoreIsOverGui == true && finger.IsOverGui == true) { return; } if (RequiredSelectable != null && RequiredSelectable.IsSelected == false) { return; } if (onFinger != null) { onFinger.Invoke(finger); } if (onPosition != null) { var position = ScreenDepth.Convert(finger.ScreenPosition, gameObject); onPosition.Invoke(position); } }
private void HandleFingerDown(LeanFinger finger) { if (IgnoreStartedOverGui == true && finger.IsOverGui == true) { return; } if (RequiredSelectable != null && RequiredSelectable.IsSelected == false) { return; } if (finger.TapCount == RequiredTapCount) { if (onFinger != null) { onFinger.Invoke(finger); } if (onWorld != null) { var position = ScreenDepth.Convert(finger.StartScreenPosition, gameObject); onWorld.Invoke(position); } } }
public virtual void FireProyectile(RaycastHit AimRay) { float percent = Random.Range(0, 1); Vector3 AimDirection = (AimRay.point - transform.position).normalized; if (C_ReduceAmmoAfterShoot != null) { StopCoroutine(C_ReduceAmmoAfterShoot); } C_ReduceAmmoAfterShoot = ReduceAmmoAfterShoot(); StartCoroutine(C_ReduceAmmoAfterShoot); OnFire.Invoke(AimDirection); if (AimRay.transform) //If the AIM Ray hit something { var interactable = AimRay.transform.GetComponent <IInteractable>(); interactable?.Interact(); AffectStat.Value = Random.Range(MinDamage, MaxDamage); AffectStat.ModifyStat(AimRay.transform.GetComponentInParent <Stats>()); Damager.SetDamage(AimRay.normal, AimRay.transform, transform); if (AimRay.rigidbody) //If the thing we hit has a rigidbody { AimRay.rigidbody.AddForceAtPosition(AimDirection * Mathf.Lerp(MinForce, MaxForce, percent), AimRay.point); //Apply the force to it } BulletHole(AimRay); OnHit.Invoke(AimRay.transform); //Invoke OnHitSomething Event } }
protected virtual void Update() { // Get fingers var fingers = Use.GetFingers(); if (fingers.Count > 0) { var screenFrom = LeanGesture.GetStartScreenCenter(fingers); var screenTo = LeanGesture.GetScreenCenter(fingers); var finalDelta = screenTo - screenFrom; var timeScale = 1.0f; if (ScaleByTime == true) { timeScale = Time.deltaTime; } switch (Coordinate) { case CoordinateType.ScaledPixels: finalDelta *= LeanTouch.ScalingFactor; break; case CoordinateType.ScreenPercentage: finalDelta *= LeanTouch.ScreenFactor; break; } finalDelta *= Multiplier; if (onVector != null) { onVector.Invoke(finalDelta * timeScale); } if (onDistance != null) { onDistance.Invoke(finalDelta.magnitude * timeScale); } var worldFrom = ScreenDepth.Convert(screenFrom, gameObject); var worldTo = ScreenDepth.Convert(screenTo, gameObject); if (onWorldFrom != null) { onWorldFrom.Invoke(worldFrom); } if (onWorldTo != null) { onWorldTo.Invoke(worldTo); } if (onWorldDelta != null) { onWorldDelta.Invoke((worldTo - worldFrom) * timeScale); } if (onWorldFromTo != null) { onWorldFromTo.Invoke(worldFrom, worldTo); } } }
private void Submit(Vector3 value) { if (onValueX != null) { onValueX.Invoke(value.x); } if (onValueY != null) { onValueY.Invoke(value.y); } if (onValueZ != null) { onValueZ.Invoke(value.z); } if (onValueXY != null) { onValueXY.Invoke(value); } if (onValueXYZ != null) { onValueXYZ.Invoke(value); } }
void Update() { if (Body != null) { HeadPos.Invoke(Body.RobotHeadPosition); HeadRot.Invoke(Body.RobotHeadRotation); } }
private void raiseVertexSelected(Vector3 pointOnCollider) { if (OnVertexSelected != null) { if (SnapToVertex) { OnVertexSelected.Invoke(nearestVertex(pointOnCollider)); } else { // convert to local space pointOnCollider = transform.InverseTransformPoint(pointOnCollider); OnVertexSelected.Invoke(pointOnCollider); } } }