private void OnUpdate() { character.Aiming = Input.GetButton("Fire2"); var moveVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveVector = Quaternion.Euler(0, camera.transform.rotation.eulerAngles.y, 0) * moveVector; character.Move = moveVector; if (character.Aiming) { character.Fire = Input.GetButton("Fire1"); if (InputTools.MouseToFloorPoint(camera, 40, floorMask, out var point)) { point += Vector3.up; //do not shoot the floor) character.AimPoint = point; } var direction = character.AimPoint - character.Position; direction.y = 0; character.Direction = direction; } else if (moveVector.magnitude > 0) { character.Fire = false; character.Direction = moveVector; } }
private void Update() { if (testMode == TestMode.CustomInput) { #if UNITY_EDITOR_WIN || ((UNITY_STANDALONE_WIN || UNITY_WSA) && !UNITY_EDITOR) int state = 0; int key = 0; if (InputTools.GetMouseState(ref state, ref key)) { Vector2 position = new Vector2(); Rect target = new Rect(0, 0, webView.GetActualWidth(), webView.GetActualHeight()); position.x = Input.mousePosition.x * (target.width / Screen.width); position.y = (Screen.height - margine - Input.mousePosition.y) * (target.height / (Screen.height - margine)); if (target.Contains(position)) { webView.InputEvent(state, key, (int)position.x, (int)position.y); } } #else Debug.LogWarning("Texturing feature is only supported on Win32/WSA/Windows Editor."); #endif } }
// Update is called once per frame void Update() { m_clicked = InputTools.GetMouseClickObj(); if (m_clicked != null) { } }
void Del(string channel, string nick, string deletions, int?assocPat) { var numbers = InputTools.GetNumbers(deletions); // If we got no numbers, assume it's a list of patterns (or parts thereof) to be deleted. // Search include patterns (no search for excludes) for pattern by their substrings. if (assocPat == null && numbers.Count == 0) { var delPatterns = InputTools.GetPatterns(deletions); numbers = feedPatterns.Search(channel, delPatterns); // Search returns results in the order they were requested, so we need to sort. numbers.Sort(); } numbers = InputTools.PrepareDeletions(numbers); string removedPattern; if (assocPat == null) { foreach (int n in numbers) { removedPattern = feedPatterns.Remove(channel, n); if (removedPattern != null) { irc.SendNotice(nick, "Deleted pattern: {0}", removedPattern); } } } else if (assocPat >= 0) { foreach (int n in numbers) { removedPattern = feedPatterns.RemoveExclude(channel, assocPat.Value, n); if (removedPattern != null) { irc.SendNotice(nick, "Removed exclude pattern: {0}", removedPattern); } } } else { foreach (int n in numbers) { removedPattern = feedPatterns.RemoveGlobalExclude(channel, n); if (removedPattern != null) { irc.SendNotice(nick, "Removed global exclude pattern: {0}", removedPattern); } } } irc.SendNotice(nick, " -----"); }
protected override void OnElementChanged(ElementChangedEventArgs<Button> e) { base.OnElementChanged(e); if ((Control != null) && (e.NewElement != null)) { Control.Tag = ((RoundButton)e.NewElement).Tag; Control.TouchUpInside += (sender, ev) => { var responder = InputTools.FindFirstResponder(UIApplication.SharedApplication.KeyWindow.RootViewController.View); if (responder != null) responder.ResignFirstResponder(); }; } }
private void OnUpdate() { var aim = Input.GetButton("Fire2"); if (aim) { character.Aiming = true; character.Move = Vector3.zero; var layerMask = LayerMask.GetMask("Floor"); if (InputTools.MouseToFloorPoint(Camera.main, 20, layerMask, out character.AimPoint)) { aimDrawer.Enable = true; var p1 = character.Position; aimDrawer.Draw(p1, character.AimPoint); var direction = character.AimPoint - p1; direction.y = 0; character.Direction = direction; } else { aimDrawer.Enable = false; } } else { if (character.Aiming) { aimDrawer.Enable = false; character.Aiming = false; character.ThrowCurrentItem(); } var moveVector = new Vector3( Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); moveVector = Quaternion.Euler(0, camera.transform.rotation.eulerAngles.y, 0) * moveVector; character.Move = moveVector; if (moveVector.magnitude > 0) { character.Direction = moveVector; } } }
private void Update() { #if UNITY_EDITOR_WIN || ((UNITY_STANDALONE_WIN || UNITY_WSA) && !UNITY_EDITOR) int state = 0; int key = 0; if (InputTools.GetMouseState(ref state, ref key)) { RaycastHit hit; if (!Physics.Raycast(viewCamera.ScreenPointToRay(Input.mousePosition), out hit)) { Debug.Log("There was an input outside the webview area."); return; } Renderer renderer = hit.transform.GetComponent <Renderer>(); MeshCollider meshCollider = hit.collider as MeshCollider; if (renderer == null || renderer.sharedMaterial == null || renderer.sharedMaterial.mainTexture == null || meshCollider == null) { Debug.LogWarning("There are no Renderer or Texture or MeshCollider."); return; } Texture2D texture = renderer.material.mainTexture as Texture2D; Vector2 pixelUV = hit.textureCoord; pixelUV.x *= texture.width; pixelUV.y *= texture.height; pixelUV.y = texture.height - pixelUV.y; // NOTE: WSA does not support input processing YET. // To be honest, I couldn't find a way to programmatically pass the mouse event and keyboard input to the webview on WSA. // And I think there is a way to implement this obviously. Because I'm not used to developing Windows Store App. // So, I would be very happy if someone could tell me how. webView.InputEvent(state, key, (int)pixelUV.x, (int)pixelUV.y); } #else Debug.LogWarning("Texturing feature is only supported on Win32/WSA/Windows Editor."); #endif }
void Add(string channel, string nick, string patternsStr, int?assocPat) { var patterns = InputTools.GetPatterns(patternsStr); int amount = 0; if (assocPat == null) { foreach (var pattern in patterns) { if (feedPatterns.Add(channel, pattern) != -1) { amount++; } } irc.SendNotice(nick, "Added {0} pattern(s)", amount); } else if (assocPat >= 0) { foreach (var pattern in patterns) { if (feedPatterns.AddExclude(channel, assocPat.Value, pattern) != -1) { amount++; } } irc.SendNotice(nick, "Added {0} exclude pattern(s)", amount); } else { foreach (var pattern in patterns) { if (feedPatterns.AddGlobalExclude(channel, pattern) != -1) { amount++; } } irc.SendNotice(nick, "Added {0} global exclude pattern(s)", amount); } }
public void SwitchToScene(string sceneName, SceneMeta meta = null) { if (_isBusy) { return; } _isBusy = true; InputTools.DisableAllInput(); StartFadingCoroutines(FadingType.FadeOut); WaitForFadingCoroutinesFinish(AfterFinish); void AfterFinish() { SceneMetaCourier.Instance.SceneMeta = meta; SceneManager.LoadScene(sceneName); _isBusy = false; } }
private void Start() { if (_isBusy) { return; } _isBusy = true; InputTools.DisableAllInput(); StartFadingCoroutines(FadingType.FadeIn); WaitForFadingCoroutinesFinish(AfterFinish); void AfterFinish() { InputTools.EnableAllInput(); _isBusy = false; SceneOpened?.Invoke(); } }
public void SolvePrecisely() { _audioSource.Play(); _isWaitingForSolution = false; StartCoroutine(Routine(OnRoutineFinished)); IEnumerator Routine(Action onFinish = null) { InputTools.DisableAllInput(); if (_figureSet != null) { _figureSet.ShowExactSolution(); } foreach (var figure in _figures) { figure.ShowExactSolution(); } while (IsBusy) { yield return(null); } InputTools.EnableAllInput(); onFinish?.Invoke(); } void OnRoutineFinished() { if (ShouldIncrementProgress) { PlayerProgress.Instance.IncrementLevel(); PlayerProgress.Instance.SetNewLevelAsCurrent(); } LevelSolved?.Invoke(); } }
private void OnKeyboardNotification(NSNotification notification) { float neededOffset = 0; var visible = notification.Name == UIKeyboard.WillShowNotification; var keyboardFrame = visible ? UIKeyboard.FrameEndFromNotification(notification) : UIKeyboard.FrameBeginFromNotification(notification); if (visible) { KeyboardShown?.Invoke(this, (float)keyboardFrame.Height); } var parentView = UIApplication.SharedApplication.KeyWindow.RootViewController.View; bool isSubview = false; var responder = InputTools.FindFirstResponder(parentView); if ((responder == null) && (UIApplication.SharedApplication.KeyWindow.Subviews != null)) { foreach (var subview in UIApplication.SharedApplication.KeyWindow.Subviews) { responder = InputTools.FindFirstResponder(subview); if (responder != null) { parentView = subview; isSubview = true; break; } } } if (responder != null) { var offsetFromBottom = getOffsetFromBottom(responder); if (responder.Tag > 0) { var views = getTaggedViews(parentView, responder.Tag); if (views.Any()) { var offsets = new List <nfloat>(); foreach (var view in views) { offsets.Add(getOffsetFromBottom(view)); } offsetFromBottom = offsets.Min(); } } if (keyboardFrame.Height > offsetFromBottom) { neededOffset = (float)(keyboardFrame.Height - offsetFromBottom + responder.Frame.Height); } } if ((KeyboardChanged != null) && ((neededOffset > 0) || !visible)) { if (isSubview) { parentView.Transform = CoreGraphics.CGAffineTransform.MakeTranslation(0, -neededOffset); } else { KeyboardChanged(this, new KeyboardHelperEventArgs(visible, (float)keyboardFrame.Height, neededOffset)); } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // 0. Generate input menu list Component = this; GrasshopperDocument = this.OnPingDocument(); // Only generate it if the input has no source if (Component.Params.Input[0].SourceCount == 0) { InputTools.TopoSelect(ref Component, ref GrasshopperDocument, 0, 11); } // 1. Retrieve input int cellType = 0; if (!DA.GetData(0, ref cellType)) { return; } // 2. Instantiate line list var lines = new List <Line>(); // 3. Set cell size double d = 5; // 4. Switch statement for the different cell types switch (cellType) { // "GRID" case 0: lines = GridLines(d); break; // "X" case 1: lines = XLines(d); break; // "STAR" case 2: lines = StarLines(d); break; // "CROSS" case 3: lines = CrossLines(d); break; // "TESSERACT" case 4: lines = TesseractLines(d); break; // "VINTILES" case 5: lines = VintileLines(d); break; // "OCTET" case 6: lines = OctetLines(d); break; // "DIAMOND" case 7: lines = DiamondLines(d); break; // "HONEYCOMB" case 8: lines = Honeycomb(d); break; // "AUXETIC HONEYCOMB" case 9: lines = AuxeticHoneycomb(d); break; } // 5. Instantiate UnitCell object and check validity. var cell = new UnitCell(lines); if (!cell.isValid) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid cell - this is embarassing."); } // 6. Construct normalized cell lines (for optional output) var lines2 = new List <Line>(); foreach (IndexPair nodePair in cell.NodePairs) { lines2.Add(new Line(cell.Nodes[nodePair.I], cell.Nodes[nodePair.J])); } // 7. Set output (as LatticeCellGoo) DA.SetData(0, new UnitCellGoo(cell)); DA.SetDataList(1, lines2); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // 0. Setup input Component = this; GrasshopperDocument = this.OnPingDocument(); // Generate default input menu if (Component.Params.Input[0].SourceCount == 0) { InputTools.GradientSelect(ref Component, ref GrasshopperDocument, 0, 11); } // 1. Retrieve input int gradientType = 0; if (!DA.GetData(0, ref gradientType)) { return; } // 2. Initialize string mathString = null; // 3. Define gradients here // Assume unitized domain ( 0<x<1 , 0<y<1, 0<z<1), where radius values range from minRadius (mathString=0) to maxRadius (mathString=1) // Based on this assumption, the actual values are scaled to the size of the bounding box of the lattice switch (gradientType) { case 0: // Linear (X) mathString = "Abs(x)"; break; case 1: // Linear (Y) mathString = "Abs(y)"; break; case 2: // Linear (Z) mathString = "Abs(z)"; break; case 3: // Centered (X) mathString = "Abs(2*x-1)"; break; case 4: // Centered (Y) mathString = "Abs(2*y-1)"; break; case 5: // Centered (Z) mathString = "Abs(2*z-1)"; break; case 6: // Cylindrical (X) mathString = "Sqrt(Abs(2*y-1)^2 + Abs(2*z-1)^2)/Sqrt(2)"; break; case 7: // Cylindrical (Y) mathString = "Sqrt(Abs(2*x-1)^2 + Abs(2*z-1)^2)/Sqrt(2)"; break; case 8: // Cylindrical (Z) mathString = "Sqrt(Abs(2*x-1)^2 + Abs(2*y-1)^2)/Sqrt(2)"; break; case 9: // Spherical mathString = "Sqrt(Abs(2*x-1)^2 + Abs(2*y-1)^2 + Abs(2*z-1)^2)/Sqrt(3)"; break; // If you add a new gradient, don't forget to add it in the value list (GradientSelect method) } // Output report DA.SetData(0, mathString); }
void SanitizeLastPrinted() { // Do not accept a DateTime too far in the past, to prevent flooding/spam. lastPrintedTime = InputTools.SanitizeDate(lastPrintedTime, TimeSpan.FromHours(24)); }