/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> /// <returns>True, if the event is handled</returns> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var eventReturn = InvokeInfo(Map.Layers, Map.GetWidgetsOfMapAndLayers(), Viewport, screenPosition, screenPosition, _renderer.SymbolCache, WidgetTouched, numOfTaps); if (eventReturn != null) { if (!eventReturn.Handled) { // Double tap as zoom return(OnZoomIn(screenPosition)); } } return(false); }
public void OnPointerDown(PointerEventData eventData) { if (_clickTime > 0) { if ((Time.realtimeSinceStartup - _clickTime) < 0.3f) { if (_timeRefreshDoubleTap > 5) { DoubleTap?.Invoke(); _timeRefreshDoubleTap = 0; } } else { if (eventData.pressPosition.x > (Camera.main.pixelWidth / 2)) { isRight = true; } else if (eventData.pressPosition.x < (Camera.main.pixelWidth / 2)) { isLeft = true; } } } _clickTime = Time.realtimeSinceStartup; }
public void setDoubleTapListener(DoubleTap doubleTap) { DoubleTapListener doubleTapListener = new DoubleTapListener(); doubleTapListener.addCallback(doubleTap); javaTouchListenerManager.Call("setDoubleTapListener", doubleTapListener); }
private void TapTimer_Expired() { if (Mode == TouchMode.Normal) { if (TapCount == 1) { Tap?.Invoke(this, null); } else if (TapCount >= 2) { DoubleTap?.Invoke(this, null); } TapCount = 0; } }
// Use this for initialization void Start() { shield = new Shield(); blur = new BlurEffect(); rb = GetComponent <Rigidbody>(); speedometer = new Speedometer(); udpSendRef = sendRef.GetComponent <UDPSend> (); aDoubleTap = new DoubleTap(KeyCode.A, 0.2f, DashLeft); bDoubleTap = new DoubleTap(KeyCode.D, 0.2f, DashRight); wheelSmoke = GameObject.FindGameObjectsWithTag("WheelSmoke"); portalDesertSpawner = gameObject.GetComponent <PortalDesertSpawner>(); Invoke("ReadyToDie", 5.0f); }
/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> /// <returns>True, if the event is handled</returns> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var eventReturn = InvokeInfo(screenPosition, screenPosition, numOfTaps); if (eventReturn?.Handled == true) { return(true); } // Double tap as zoom return(OnZoomIn(screenPosition)); }
/// <summary> /// Called, when mouse/finger/pen tapped on map 2 or more times /// </summary> /// <param name="screenPosition">First clicked/touched position on screen</param> /// <param name="numOfTaps">Number of taps on map (2 is a double click/tap)</param> private bool OnDoubleTapped(Geometries.Point screenPosition, int numOfTaps) { var args = new TappedEventArgs(screenPosition, numOfTaps); DoubleTap?.Invoke(this, args); if (args.Handled) { return(true); } var tapWasHandled = Map.InvokeInfo(screenPosition, screenPosition, _scale, _renderer.SymbolCache, WidgetTouched, numOfTaps); if (!tapWasHandled) { // Double tap as zoom return(OnZoomIn(screenPosition)); } return(false); }
public bool SpawnButton(int index) { if (modeTheGame == VisualLevelsManager.Modes.ColorMode) { buttonToSpawn.GetComponentInChildren <Text>().text = ""; } else { buttonToSpawn.GetComponentInChildren <Text>().text = GameTapTapManager.numbersForThebuttons[index]; } buttons[index] = GameObject.Instantiate(buttonToSpawn, buttonPosition, Quaternion.identity, GameObject.FindGameObjectWithTag("Canvas").transform); GameTapTapManager.buttonsInTheGame.Add(buttons[index]); DoubleTap doubleTap = buttons[index].GetComponent <DoubleTap>(); doubleTap.SetNumber(index + 1); if (modeTheGame == VisualLevelsManager.Modes.ColorMode) { int colorNumbers = Random.Range(0, (colors.Length - 1)); doubleTap.SetColor(colors[colorNumbers]); colorsNumbers[colorNumbers]++; } return(true); }
public void Process(int raw) { if (TapQueued) { Console.WriteLine("Tap queued at start..."); } bool wasPressed = Pressed; bool isPressed = (raw != 0); if (Raw != null && Raw.AcceptAnalog) { Raw.Analog(raw); } if (wasPressed != isPressed) { if (isPressed) { // Pressed if (PressReceived != null) { PressReceived(this, EventArgs.Empty); } if (Link != null) { Link.Press(Intensity); } } else { // Released Held = false; if (ReleaseReceived != null) { ReleaseReceived(this, EventArgs.Empty); } if (Link != null) { Link.Release(Intensity); } if (EnableGestures && PressedStamp + new TimeSpan(0, 0, 0, 0, Core.TapTimeout) > DateTime.Now) { // Tap if (DoubleTap != null) { if (TapQueued && TapStamp + new TimeSpan(0, 0, 0, 0, Core.DoubleTapTimeout) > DateTime.Now) { // Second tap Console.WriteLine("Double Tap!"); DoubleTap.Activate(Intensity); TapStamp = DateTime.Now; TapQueued = false; } else if (!TapQueued) { // First tap TapStamp = DateTime.Now; TapQueued = true; Console.WriteLine("Tap! [queued]"); } } else { Console.WriteLine("Tap!"); if (Tap != null) { Tap.Activate(Intensity); } } } } Pressed = isPressed; PressedStamp = DateTime.Now; } if (TapQueued) { Console.WriteLine("Tap queued in middle..."); } if (EnableGestures && TapQueued && TapStamp + new TimeSpan(0, 0, 0, 0, Core.DoubleTapTimeout) < DateTime.Now) { Console.WriteLine("Real Tap!"); if (Tap != null) { Tap.Activate(Intensity); } TapQueued = false; } if (isPressed) { if (Link != null) { Link.Active(Intensity); } if (EnableGestures && !Held && PressedStamp + new TimeSpan(0, 0, 0, 0, Core.HoldTimeout) <= DateTime.Now) { Console.WriteLine("Hold!"); if (Hold != null) { Hold.Activate(Intensity); } Held = true; } } if (TapQueued) { Console.WriteLine("Tap queued at end..."); } }
private void OnMouseStuff(object sender, MouseEventArgs args) { if (args.RoutedEvent == UIElement.MouseUpEvent || (args.RoutedEvent == UIElement.MouseLeftButtonDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.MouseMoveEvent && args.Source == null && args.LeftButton == MouseButtonState.Released)) { MultitouchWindow.RemoveMouseListener(_attachedElement, OnMouseStuff); if (!_downpoint.ContainsKey(-1)) { return; } //if (args.OriginalSource != _attachedElement) return; args.Handled = true; Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); Vector jitter = Point.Subtract(current, _downpoint[-1]); if (jitter.Length < Threshold) { if (Tap != null) { Tap.Invoke(_attachedElement, new TapEventArgs(args.MouseDevice, jitter)); } if (args.Timestamp - _lasttap < DoubleTapDelay.TotalMilliseconds && DoubleTap != null) { DoubleTap.Invoke(_attachedElement, new TapEventArgs(args.MouseDevice, jitter)); } if (_attachedElement is Control) { ((Control)_attachedElement).RaiseEvent( new MouseButtonEventArgs(args.MouseDevice, args.Timestamp, ((MouseButtonEventArgs)args).ChangedButton) { RoutedEvent = Control.MouseDoubleClickEvent }); } _lasttap = args.Timestamp; } } else if (args.RoutedEvent == UIElement.MouseDownEvent) { MultitouchWindow.AddMouseListener(_attachedElement, OnMouseStuff); _downpoint[-1] = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); } else if (args.RoutedEvent == UIElement.MouseMoveEvent) { if (!_downpoint.ContainsKey(-1)) { return; } Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (Point.Subtract(current, _downpoint[-1]).Length > Threshold) { _downpoint.Remove(-1); } } }
private void OnStylusStuff(object sender, StylusEventArgs args) { if (args.RoutedEvent == UIElement.StylusUpEvent || (args.RoutedEvent == UIElement.StylusDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.StylusMoveEvent && args.Source == null && args.InAir)) { MultitouchWindow.RemoveStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); if (!_downpoint.ContainsKey(args.StylusDevice.Id)) { return; } //if (args.OriginalSource != _attachedElement) return; args.Handled = true; Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); Vector jitter = Point.Subtract(current, _downpoint[args.StylusDevice.Id]); if (jitter.Length < Threshold) { if (Tap != null) { Tap.Invoke(_attachedElement, new TapEventArgs(args.StylusDevice, jitter)); } if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, true); _button.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); ExecuteCommandSource(_button); } if ((args.Timestamp - _lasttap) < DoubleTapDelay.TotalMilliseconds && DoubleTap != null) { DoubleTap.Invoke(_attachedElement, new TapEventArgs(args.StylusDevice, jitter)); } if (_attachedElement is Control) { ((Control)_attachedElement).RaiseEvent( new MouseButtonEventArgs(Mouse.PrimaryDevice, args.Timestamp, MouseButton.Left, args.StylusDevice) { RoutedEvent = Control.MouseDoubleClickEvent }); } _lasttap = args.Timestamp; } } else if (args.RoutedEvent == UIElement.StylusDownEvent) { MultitouchWindow.AddStylusListener(args.StylusDevice, _attachedElement, OnStylusStuff); _downpoint[args.StylusDevice.Id] = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, true); } } else if (args.RoutedEvent == UIElement.StylusMoveEvent) { if (!_downpoint.ContainsKey(args.StylusDevice.Id)) { return; } Point current = args.GetPosition(args.Device.ActiveSource.RootVisual as IInputElement); if (Point.Subtract(current, _downpoint[args.StylusDevice.Id]).Length > Threshold) { _downpoint.Remove(args.StylusDevice.Id); if (_button != null) { _button.SetValue(TapBehavior.IsPressedProperty, false); } } } }
// regex = /(?<=([^5])[^5\1]{0,4}5{1,7})(?=[^5\1]{0,3}\1)/g public static int FindDoubleTaps(InputBufferReader reader, Factory inputFactory, List <Combination> activeInputs) { int numFound = 0; reader.ResetCurrIndex(); FightingGameAbsInputCodeDir currDir = FightingGameAbsInputCodeDir.None; while (reader.ReadyNext()) { int inputFrameIndex = reader.ReadBuffer(out GameInputStruct curr); if (currDir != curr.direction) { currDir = curr.direction; FightingGameAbsInputCodeDir direction = FightingGameAbsInputCodeDir.None; if (curr.direction != FightingGameAbsInputCodeDir.Neutral) { direction = curr.direction; bool continueSearch = true; int n = 0; //FightingGameInputCodeDir prevDir = direction; n = 0; while (continueSearch && reader.ReadyNextLookBehind()) { if (n < 5) { int lookBehindFrameIndex = reader.LookBehind(out GameInputStruct lb); if (lb.direction == FightingGameAbsInputCodeDir.Neutral) { break; } ++n; } else { continueSearch = false; break; } } n = 0; while (continueSearch && reader.ReadyNextLookBehind()) { if (n < 8) { int lookBehindFrameIndex = reader.LookBehind(out GameInputStruct lb); if (lb.direction != FightingGameAbsInputCodeDir.Neutral) { break; } ++n; } else { continueSearch = false; break; } } n = 0; while (continueSearch && reader.ReadyNextLookBehind()) { if (n < 4) { int lookBehindFrameIndex = reader.LookBehind(out GameInputStruct lb); if (lb.direction == direction) { DoubleTap input = AddToActiveInputs <DoubleTap>(activeInputs, inputFactory, reader.currentFrame, newInput => { numFound++; newInput.Init(inputFrameIndex, lookBehindFrameIndex, direction); }); } ++n; } else { continueSearch = false; break; } } } } } return(numFound); }
public static void removeDoubleTapListener(DoubleTap doubleTap) { Debug.Log("<><>right removeDoubleTapListener<><>"); DoubleTapEvent -= doubleTap; }
public static void addDoubleTapListener(DoubleTap doubleTap) { Debug.Log("<><>right addDoubleTapListener<><>"); DoubleTapEvent += doubleTap; }
void Start(){ for (int i=0;i<100;i++){ singleDoubleTap[i] = new DoubleTap(); } int index = touchCameras.FindIndex( delegate(ECamera c){ return c.camera == Camera.main; } ); if (index<0) touchCameras.Add(new ECamera(Camera.main,false)); // Fire ready event if (On_EasyTouchIsReady!=null){ On_EasyTouchIsReady(); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { if (PlayerManager.Instance.pause) { PlayerManager.Instance.pause = false; } else { PlayerManager.Instance.pause = true; } } if (PlayerManager.Instance.pause) { GameObject.Find("Canvas").transform.GetChild(0).gameObject.SetActive(true); //GameObject.Find("Player UI").transform.GetChild(0).gameObject.SetActive(false); } else { GameObject.Find("Canvas").transform.GetChild(0).gameObject.SetActive(false); //GameObject.Find("Player UI").transform.GetChild(0).gameObject.SetActive(true); if (Input.GetKeyDown(KeyCode.KeypadEnter)) { if (Hotbar.Instance.GetInstanceID() == 0) { PlayerManager.Instance.arrowType = 0; } if (Hotbar.Instance.GetInstanceID() == 1) { PlayerManager.Instance.arrowType = 1; } if (Hotbar.Instance.GetInstanceID() == 2) { PlayerManager.Instance.arrowType = 2; } } bowSkill1 = false; for (int i = 0; i < doubleTap.Count; i++) { doubleTap[i].time -= Time.deltaTime; if (doubleTap[i].time <= 0) { doubleTap.Remove(doubleTap[i]); i--; } } if (dash) { if (dashTime <= 0) { dashSpeedUp = 1; dashSpeedDown = 1; dashSpeedLeft = 1; dashSpeedRight = 1; dash = false; } } dashTime -= 1; // Check if player presses Inventory button if (Input.GetKeyDown(KeyCode.Tab)) { // Set player menu active to the opposite of itself PlayerMenu.Instance.SetMenuActive(!PlayerMenu.Instance.MenuIsActive()); // Set the menu object to active GameObject.FindGameObjectWithTag("Inventory").transform.GetChild(0).gameObject.SetActive(PlayerMenu.Instance.MenuIsActive()); if (PlayerMenu.Instance.MenuIsActive()) { skillTree = false; levelTree = false; GameObject.FindGameObjectWithTag("Skill").transform.GetChild(0).gameObject.SetActive(skillTree); GameObject.FindGameObjectWithTag("Level").transform.GetChild(0).gameObject.SetActive(levelTree); GameObject.FindGameObjectWithTag("Skill").transform.GetChild(1).gameObject.SetActive(skillTree); GameObject.FindGameObjectWithTag("Level").transform.GetChild(1).gameObject.SetActive(levelTree); } } if (Input.GetKeyDown(KeyCode.K)) { if (skillTree) { skillTree = false; menuOpen = false; } else { skillTree = true; levelTree = false; PlayerMenu.Instance.SetMenuActive(false); GameObject.FindGameObjectWithTag("Inventory").transform.GetChild(0).gameObject.SetActive(PlayerMenu.Instance.MenuIsActive()); GameObject.FindGameObjectWithTag("Level").transform.GetChild(0).gameObject.SetActive(levelTree); GameObject.FindGameObjectWithTag("Level").transform.GetChild(1).gameObject.SetActive(levelTree); menuOpen = true; } GameObject.FindGameObjectWithTag("Skill").transform.GetChild(0).gameObject.SetActive(skillTree); GameObject.FindGameObjectWithTag("Skill").transform.GetChild(1).gameObject.SetActive(skillTree); } if (Input.GetKeyDown(KeyCode.L)) { if (levelTree) { levelTree = false; menuOpen = false; } else { levelTree = true; skillTree = false; PlayerMenu.Instance.SetMenuActive(false); GameObject.FindGameObjectWithTag("Inventory").transform.GetChild(0).gameObject.SetActive(PlayerMenu.Instance.MenuIsActive()); GameObject.FindGameObjectWithTag("Skill").transform.GetChild(0).gameObject.SetActive(skillTree); GameObject.FindGameObjectWithTag("Skill").transform.GetChild(1).gameObject.SetActive(skillTree); menuOpen = true; } GameObject.FindGameObjectWithTag("Level").transform.GetChild(0).gameObject.SetActive(levelTree); GameObject.FindGameObjectWithTag("Level").transform.GetChild(1).gameObject.SetActive(levelTree); } if (Input.GetKeyDown(KeyCode.Alpha1)) { if (isMelee && (PlayerManager.Instance.levels[0] == 0 || PlayerManager.Instance.allSkills)) { if (PlayerManager.Instance.m_currentMana >= 10) { for (int i = 0; i < GameObject.FindGameObjectsWithTag("Enemy").Length; i++) { float dist = Vector3.Distance(GameObject.FindGameObjectsWithTag("Enemy")[i].transform.position, transform.position); if (dist < 5) { if (!GameObject.FindGameObjectsWithTag("Enemy")[i].GetComponent <AI>().knockback) { GameObject.FindGameObjectsWithTag("Enemy")[i].GetComponent <AI>().knockback = true; GameObject.FindGameObjectsWithTag("Enemy")[i].GetComponent <AI>().knockbackTime = 15; GameObject.FindGameObjectsWithTag("Enemy")[i].GetComponent <AI>().knockbackDist = 10; } } } var clone = (GameObject)Instantiate(damageCounter, transform.position, transform.rotation); clone.GetComponentInChildren <DamageNumbers>().dmgText.text = "KNOCKBACK"; PlayerManager.Instance.m_currentMana -= 10; } } else if (!isMelee && (PlayerManager.Instance.levels[0] == 1 || PlayerManager.Instance.allSkills)) { if (PlayerManager.Instance.m_currentMana >= 10) { for (int i = 0; i < GameObject.FindGameObjectsWithTag("Enemy").Length; i++) { float dist = Vector3.Distance(GameObject.FindGameObjectsWithTag("Enemy")[i].transform.position, transform.position); if (dist < 10) { bowSkill1 = true; } } if (!PlayerManager.Instance.unlimited) { if (PlayerManager.Instance.arrowType == 0) { Inventory.Instance.Remove("Arrow", 1); } if (PlayerManager.Instance.arrowType == 1) { Inventory.Instance.Remove("Slow Arrow", 1); } if (PlayerManager.Instance.arrowType == 2) { Inventory.Instance.Remove("Homing Arrow", 1); } } PlayerManager.Instance.m_currentMana -= 10; } } } if (Input.GetKeyDown(KeyCode.Alpha2)) { if (isMelee && (PlayerManager.Instance.levels[1] == 2 || PlayerManager.Instance.allSkills)) { bowSkill2 = false; transform.GetChild(0).GetChild(1).GetChild(0).gameObject.SetActive(false); if (!swordSkill2) { swordSkill2 = true; transform.GetChild(1).gameObject.SetActive(true); } else { swordSkill2 = false; } } else if (!isMelee && (PlayerManager.Instance.levels[1] == 1 || PlayerManager.Instance.allSkills)) { swordSkill2 = false; transform.GetChild(1).gameObject.SetActive(false); transform.GetChild(0).GetChild(1).GetChild(0).gameObject.SetActive(true); if (!bowSkill2) { bowSkill2 = true; transform.GetChild(0).GetChild(1).GetChild(0).gameObject.SetActive(true); } else { bowSkill2 = false; } } } if (Input.GetKeyDown(KeyCode.Alpha3)) { if (isMelee && (PlayerManager.Instance.levels[2] == 2 || PlayerManager.Instance.allSkills)) { bowSkill3 = false; if (!swordSkill3) { swordSkill3 = true; } else { swordSkill3 = false; } } else if (!isMelee && (PlayerManager.Instance.levels[2] == 1 || PlayerManager.Instance.allSkills)) { swordSkill3 = false; if (!bowSkill3) { bowSkill3 = true; } else { bowSkill3 = false; } } } if (Input.GetKeyDown(KeyCode.Alpha4)) { if (PlayerManager.Instance.allSkills) { PlayerManager.Instance.allSkills = false; } else { PlayerManager.Instance.allSkills = true; } } // For double tap dash if (Input.GetKeyDown(KeyCode.W)) { bool check = false; for (int i = 0; i < doubleTap.Count; i++) { if (doubleTap[i].key == KeyCode.W) { if (doubleTap[i].time > 0) { check = true; if (!dash) { dash = true; dashTime = dashTimeSet; dashSpeedUp = dashTime; PlayerManager.Instance.m_currentMana -= 10; } doubleTap[i].time = 0; } break; } } if (!check) { DoubleTap pressedKey = new DoubleTap(); pressedKey.key = KeyCode.W; pressedKey.time = pressedTime; doubleTap.Add(pressedKey); } } if (Input.GetKeyDown(KeyCode.A)) { bool check = false; for (int i = 0; i < doubleTap.Count; i++) { if (doubleTap[i].key == KeyCode.A) { if (doubleTap[i].time > 0) { check = true; if (!dash) { dash = true; dashTime = dashTimeSet; dashSpeedLeft = dashSpeed; PlayerManager.Instance.m_currentMana -= 10; } doubleTap[i].time = 0; } break; } } if (!check) { DoubleTap pressedKey = new DoubleTap(); pressedKey.key = KeyCode.A; pressedKey.time = pressedTime; doubleTap.Add(pressedKey); } } if (Input.GetKeyDown(KeyCode.S)) { bool check = false; for (int i = 0; i < doubleTap.Count; i++) { if (doubleTap[i].key == KeyCode.S) { if (doubleTap[i].time > 0) { check = true; if (!dash) { dash = true; dashTime = dashTimeSet; dashSpeedDown = dashSpeed; PlayerManager.Instance.m_currentMana -= 10; } doubleTap[i].time = 0; } break; } } if (!check) { DoubleTap pressedKey = new DoubleTap(); pressedKey.key = KeyCode.S; pressedKey.time = pressedTime; doubleTap.Add(pressedKey); } } if (Input.GetKeyDown(KeyCode.D)) { bool check = false; for (int i = 0; i < doubleTap.Count; i++) { if (doubleTap[i].key == KeyCode.D) { if (doubleTap[i].time > 0) { check = true; if (!dash) { dash = true; dashTime = dashTimeSet; dashSpeedRight = dashSpeed; PlayerManager.Instance.m_currentMana -= 10; } doubleTap[i].time = 0; } break; } } if (!check) { DoubleTap pressedKey = new DoubleTap(); pressedKey.key = KeyCode.D; pressedKey.time = pressedTime; doubleTap.Add(pressedKey); } } bool inventoryIsActive = PlayerMenu.Instance.MenuIsActive(); isMoving = false; if (isMelee) { transform.GetChild(0).GetChild(0).gameObject.SetActive(true); transform.GetChild(0).GetChild(1).gameObject.SetActive(false); } else { transform.GetChild(0).GetChild(0).gameObject.SetActive(false); transform.GetChild(0).GetChild(1).gameObject.SetActive(true); } if (!isAttacking) { if (!menuOpen) { if (Input.GetAxisRaw("Horizontal") > 0.5 || Input.GetAxisRaw("Horizontal") < -0.5) { body.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * moveSpeed, body.velocity.y); if (Input.GetAxisRaw("Horizontal") > 0) { body.velocity *= dashSpeedRight; } if (Input.GetAxisRaw("Horizontal") < 0) { body.velocity *= dashSpeedLeft; } dir = new Vector2(0f, Input.GetAxisRaw("Vertical")); isMoving = true; dir = new Vector2(Input.GetAxisRaw("Horizontal"), 0f); } if (Input.GetAxisRaw("Vertical") > 0.5 || Input.GetAxisRaw("Vertical") < -0.5) { body.velocity = new Vector2(body.velocity.x, Input.GetAxisRaw("Vertical") * moveSpeed); isMoving = true; if (Input.GetAxisRaw("Vertical") > 0) { body.velocity *= dashSpeedUp; } if (Input.GetAxisRaw("Vertical") < 0) { body.velocity *= dashSpeedDown; } dir = new Vector2(0f, Input.GetAxisRaw("Vertical")); } if (Input.GetAxisRaw("Horizontal") < 0.5f && Input.GetAxisRaw("Horizontal") > -0.5f) { body.velocity = new Vector2(0f, body.velocity.y); //body.velocity *= dashSpeedLeft; } if (Input.GetAxisRaw("Vertical") < 0.5f && Input.GetAxisRaw("Vertical") > -0.5f) { body.velocity = new Vector2(body.velocity.x, 0f); //body.velocity *= dashSpeedDown; } } } if (Input.GetMouseButtonDown(1) && !inventoryIsActive && !menuOpen) { if (isMelee) { isMelee = false; swordSkill1 = false; swordSkill2 = false; swordSkill3 = false; } else { isMelee = true; bowSkill1 = false; bowSkill2 = false; bowSkill3 = false; } } if (bowSkill2) { PlayerManager.Instance.m_currentMana--; if (!PlayerManager.Instance.unlimited) { if (PlayerManager.Instance.arrowType == 0) { Inventory.Instance.Remove("Arrow", 1); } if (PlayerManager.Instance.arrowType == 1) { Inventory.Instance.Remove("Slow Arrow", 1); } if (PlayerManager.Instance.arrowType == 2) { Inventory.Instance.Remove("Homing Arrow", 1); } } if (PlayerManager.Instance.m_currentMana <= 0) { bowSkill2 = false; } } else { transform.GetChild(0).GetChild(1).GetChild(0).gameObject.SetActive(false); } if (swordSkill2) { PlayerManager.Instance.m_currentMana--; if (!PlayerManager.Instance.invulnerable) { PlayerManager.Instance.m_currentHealth--; } if (PlayerManager.Instance.m_currentMana <= 0) { swordSkill2 = false; } } else { transform.GetChild(1).gameObject.SetActive(false); } if (bowSkill3) { PlayerManager.Instance.unlimited = true; PlayerManager.Instance.m_currentMana--; } else { PlayerManager.Instance.unlimited = false; } if (swordSkill3) { PlayerManager.Instance.invulnerable = true; PlayerManager.Instance.m_currentMana--; } else { PlayerManager.Instance.invulnerable = false; } if (Input.GetMouseButtonDown(0) && attackTimer <= 0 && !inventoryIsActive && !menuOpen) { if (!isMelee && count > 0) { //mouseClick.Set(Camera.main.ScreenToWorldPoint(Input.mousePosition).x - transform.position.x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y - transform.position.y); attackTimer = attackTime; isAttacking = true; body.velocity = Vector2.zero; if (isMelee) { anim.SetBool("isAttacking", isAttacking); } count--; if (!PlayerManager.Instance.unlimited) { if (PlayerManager.Instance.arrowType == 0) { Inventory.Instance.Remove("Arrow", 1); } if (PlayerManager.Instance.arrowType == 1) { Inventory.Instance.Remove("Slow Arrow", 1); } if (PlayerManager.Instance.arrowType == 2) { Inventory.Instance.Remove("Homing Arrow", 1); } } } if (isMelee) { attackTimer = attackTime; isAttacking = true; body.velocity = Vector2.zero; if (isMelee) { anim.SetBool("isAttacking", isAttacking); } } } if (attackTimer > 0) { attackTimer -= Time.deltaTime; } else { isAttacking = false; if (isMelee) { anim.SetBool("isAttacking", isAttacking); } } anim.SetFloat("MoveX", Input.GetAxisRaw("Horizontal")); anim.SetFloat("MoveY", Input.GetAxisRaw("Vertical")); anim.SetFloat("LastMoveX", dir.x); anim.SetFloat("LastMoveY", dir.y); anim.SetBool("isMoving", isMoving); if (ShopMenu.Instance) { // Check if shop is active if (ShopMenu.Instance.MenuIsActive()) { // If player presses E, interact if (Input.GetKeyDown(KeyCode.E)) { // Make shop inactive ShopMenu.Instance.transform.GetChild(0).gameObject.SetActive(false); // Set Shop Menu as inative ShopMenu.Instance.SetMenuActive(false); } } else { // Check if there are interactables if (PlayerManager.Instance.m_interactable != null) { // If player presses E, interact if (Input.GetKeyDown(KeyCode.E)) { // Interact PlayerManager.Instance.m_interactable.Interact(); } } } } if ((ShopMenu.Instance && ShopMenu.Instance.MenuIsActive()) || PlayerMenu.Instance.MenuIsActive() || skillTree || levelTree) { // Set Hotbar to inactive HotbarParent.Instance.transform.GetChild(0).gameObject.SetActive(false); HotbarParent.Instance.SetMenuActive(false); menuOpen = true; } else if (!HotbarParent.Instance.transform.GetChild(0).gameObject.activeSelf) { // Set Hotbar to active HotbarParent.Instance.transform.GetChild(0).gameObject.SetActive(true); HotbarParent.Instance.SetMenuActive(true); menuOpen = false; } // Check if menu is open if (!menuOpen) { // Check if player used left shift if (Input.GetKeyDown(KeyCode.LeftShift)) { // Use the item Hotbar.Instance.UseHotbarItem(HotbarParent.Instance.GetCurrentSlotID()); } } } }
public void addCallback(DoubleTap doubleTap) { mDoubleTap = doubleTap; }