private bool IsAxisClicked() { if (Input.GetMouseButton(0)) { if (!_axisClicked) { var hitAxis = HitAxis(); _axisClicked = hitAxis?.GetComponent <SrGizmoAxis>()?.SrAxis == SrAxis; } if (_axisClicked) { OnMovement?.Invoke(SrAxis); } return(_axisClicked); } OnMovementStopped?.Invoke(); return(false); }
private void OnGameTick(object sender, GameTickEventArgs args) { _ticks++; if (_ticks < 1000 / _MovementsPerSecond / GameplayConstants.GameTicksPerSecond) { return; } _ticks = 0; bool success = false; bool isMovementStopped = false; // Don't move if wrong state if (_stateManager.GetPlayerState(PlayerId) != PlayerStateConstants.Free) { return; } lock (_lock) { while (!success && _movementQueue.Count > 0) { success = TryMoveEntity(_movementQueue.Dequeue()); } isMovementStopped = _movementQueue.Count <= 0; if (isMovementStopped) { PerformAction(); } } if (isMovementStopped && _canInvokeMovementStopped) { Task.Run(() => OnMovementStopped?.Invoke(this, new System.EventArgs())); _canInvokeMovementStopped = false; } }
private void Update() { if (Input.GetAxisRaw("Horizontal") != 0 || Input.GetAxisRaw("Vertical") != 0) { //UpdateRotation(); //Move(); OnPlayerMoved.Invoke(); } else { OnMovementStopped.Invoke(); } if (Input.GetKeyDown(KeyCode.Q)) { this.OnSkillPressed.Invoke(0); } if (Input.GetKeyDown(KeyCode.Space)) { this.OnSkillPressed.Invoke(2); } if (Input.GetKeyDown(KeyCode.R)) { this.OnSkillPressed.Invoke(3); } if (Input.GetMouseButtonUp(0)) { if (!IsPointerOverUIElement()) { this.OnSkillPressed.Invoke(1); } } }