private void MouseNKeyboardInput() { // directional movement input float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); _walkVector = new Vector3(horizontal, 0, vertical); // camera control input float camX = Input.GetAxis("Mouse X"); float camY = Input.GetAxis("Mouse Y"); _cameraVector = new Vector3(camX, camY); _cameraDistance -= Input.GetAxis("Mouse ScrollWheel") * scrollMultiplier; _cameraDistance = Mathf.Clamp(_cameraDistance, 1f, 10f); if (Input.GetButtonDown("Jump")) { JumpEvent.Invoke(); } if (Input.GetButtonDown("Attack")) { Attack(); } }
public void OnJump(InputAction.CallbackContext context) { if (context.phase == InputActionPhase.Performed) { JumpEvent.Invoke(); } }
private bool ShouldSkipJump(List <JumpEvent> priorEvents, Dictionary <string, long> currentRegisters, long currentLine, string targetedRegister) { var matchingEvent = priorEvents.FirstOrDefault(it => it.JumpLine == currentLine); if (matchingEvent == null) { var newEvent = new JumpEvent { JumpLine = currentLine, RegisterState = new Dictionary <string, long>(currentRegisters) }; priorEvents.Add(newEvent); return(false); } var stepSize = Math.Abs(matchingEvent.RegisterState[targetedRegister] - currentRegisters[targetedRegister]); var totalSteps = currentRegisters[targetedRegister] / stepSize; currentRegisters[targetedRegister] = 0; var registersToUpdate = currentRegisters.Keys.Where(it => it != targetedRegister).ToList(); foreach (var item in registersToUpdate) { var change = currentRegisters[item] - matchingEvent.RegisterState[item]; currentRegisters[item] += (change * totalSteps); } priorEvents.Clear(); return(true); }
//--------------------------------------------------------------------------------------------/ // Events //--------------------------------------------------------------------------------------------/ private void OnJumpEvent(JumpEvent e) { if (characterMovement.grounded && !this.jumping) { this.Jump(); } }
public override void ProcessEvent(GameEvent gameEvent) { var jump = gameEvent as JumpEvent; if (jump == null) { return; } if (lastEvent != null) { if (jump.TimeStamp - lastEvent.TimeStamp < TimeSpan.FromSeconds(1)) { consecutiveJumps++; } else { consecutiveJumps = 1; } } if (consecutiveJumps >= 5) { this.LogInfo("Jump combo: {consecutiveJumps} jumps.", consecutiveJumps); } lastEvent = jump; }
private void OnJumpEvent(JumpEvent e) { if (grounded && !jumping) { Jump(); } }
public void Jump() { if (_playerAnimator != null && _isGround) { JumpEvent?.Invoke(_playerAnimator); _pLayerRigitBody2D.AddForce(transform.up * _jumpForce, ForceMode2D.Impulse); } }
void Handle(JumpEvent e) { constraint.ForEachGameObject((egoComponent, transform, movement) => { MovementComponent.ViewDirection moveDirectionVar; moveDirectionVar = movement.viewDirection; EgoEvents <JumpEvent> .AddEvent(new JumpEvent(moveDirectionVar.ToString())); }); }
public void FillJumpEventData(PlayerController playerController) { JumpEvent newJumpEvent = new JumpEvent(); newJumpEvent.pdata = playerData; newJumpEvent.eventID = ++evendIdCount; newJumpEvent.position = playerController.gameObject.GetComponent <Transform>().position; newJumpEvent.timeStamp = Time.time; jumpEvents.events.Add(newJumpEvent); }
void GoJump() { if (_needJump) { _needJump = false; float jumpForce = _jumpForce; _rigidBody.AddForce(Coordinate.Instance.UpVec * jumpForce, ForceMode.Force); JumpEvent?.Invoke(); } }
void Handle(JumpEvent e) { constraint.ForEachGameObject((egoComponent, sfx, actor) => { if (actor.guid == e.actorGuid) { sfx.jumpSound.pitch = Random.Range(0.9f, 1.1f); sfx.jumpSound.Play(); } }); }
protected override void PlayerSystemJumpEventHandler(JumpEvent data, Player @group) { base.PlayerSystemJumpEventHandler(data, @group); if (jumpCount < 2) { jumpCount++; group.GetComponent <Rigidbody>().velocity = new Vector3(); group.GetComponent <Rigidbody>().AddForce(new Vector3(0, group.jumpForce, 0)); } }
// Update is called once per frame void Update() { Debug.Log(JumpEvent.GetInvocationList().Length); if (InputManager.instance.GetButtonDown(0, EInputAction.Jump)) { if (JumpEvent != null) { JumpEvent.Invoke(); } } }
void Handle(JumpEvent e) { var emitParams = new ParticleSystem.EmitParams(); emitParams.velocity = -e.velocity.normalized * 4f; constraint.ForEachGameObject((egoComponent, jumpParticle, actor) => { if (actor.guid == e.actorGuid) { jumpParticle.ps.Emit(emitParams, 3); } }); }
private void Jump() { if (!_floatScript.onGround) { return; } if (_jumpTimer < jumpTime) { return; } _rb.velocity += Vector2.up * jumpVelocity; _jumpTimer = 0f; JumpEvent?.Invoke(); }
void Jumping() { if (isGround && Input.GetKeyDown(KeyCode.Space))//Start Jumping { isJumping = true; jumpTimeCounter = jumpTime; rb.velocity = Vector3.up * jumpVelocity; isGround = false; if (JumpEvent != null) { JumpEvent.Invoke(); } } if (Input.GetKey(KeyCode.Space) && isJumping) //Jumping { if (jumpTimeCounter > 0) //Jumping Time didn't end { rb.velocity = Vector3.up * jumpVelocity; jumpTimeCounter -= Time.deltaTime; } else//Jumping Time Ended { if (DownEvent != null) { DownEvent.Invoke(); } isJumping = false; isDown = true; } } if (Input.GetKeyUp(KeyCode.Space))//End Jump (getkeyUP) { if (DownEvent != null) { DownEvent.Invoke(); } isJumping = false; isDown = true; } if ((camera.transform.position.z - transform.position.z) <= zDistance) { isDown = false; } }
private void TriggerEvent() { //print("trigger: " + nextEventToExecute.GetType()); MoveEvent me = nextEventToExecute as MoveEvent; if (me != null) { //print("clone is moving"); Main_Move(me.MoveData); cloneEventIndex++; } JumpEvent je = nextEventToExecute as JumpEvent; if (je != null) { //print("clone is jumping"); Main_Jump(je.JumpData); cloneEventIndex++; } DropEvent de = nextEventToExecute as DropEvent; if (de != null) { //print("clone is dropping"); Main_Drop(); cloneEventIndex++; } BulletEvent be = nextEventToExecute as BulletEvent; if (be != null) { //print("clone is bulleting"); Main_Action(be.MouseScreenPos); cloneEventIndex++; } if (gameManager.listEvents.Count > cloneEventIndex) { nextEventToExecute = gameManager.listEvents[cloneEventIndex]; } }
private void Update() { if (GetJumpInput()) { JumpEvent?.Invoke(); } (bool, Vector2)shootTuple = GetShootInput(); if (shootTuple.Item1 && shootTuple.Item2.sqrMagnitude != 0) // Make sure vector is not 0 { ShootEvent?.Invoke(shootTuple.Item2); } if (GetMenuInput()) { MenuEvent?.Invoke(); } }
private void Awake() { if (staminaUp == null) { staminaUp = new UnityEvent(); } if (staminaDown == null) { staminaDown = new UnityEvent(); } if (staminaDownJump == null) { staminaDownJump = new JumpEvent(); } staminaUp.AddListener(RenewStamina); staminaDown.AddListener(LessStamina); staminaDownJump.AddListener(LessStaminaJump); InitializeStats(); }
public void OnButtonPress(string buttonType) { switch (buttonType) { case "Jump": JumpEvent?.Invoke(); break; case "MoveRight": MoveEvent?.Invoke(1); break; case "MoveLeft": MoveEvent?.Invoke(-1); break; case "Stop": MoveEvent?.Invoke(0); break; } }
void TryJump(Movement movement, Rigidbody rigidbody, ActorComponent actor) { if (movement.numberOfJumpsRemaining > 0) { float jumpStrength = movement.jumpStrengths[movement.numberOfJumpsRemaining - 1]; if (movement.velocity.y <= 0f) { movement.velocity.y = jumpStrength; } else { movement.velocity.y += jumpStrength; } var e = new JumpEvent(actor.guid, movement.velocity); EgoEvents <JumpEvent> .AddEvent(e); movement.numberOfJumpsRemaining--; //movement.onGround = false; movement.onPassThrough = false; } }
private void Movement() { if (!_swinging && !_falling) { _controller.Move(Inputs.MoveInput * speed * _deltaTime); } if (Inputs.Jump && _jumpNumber > 0) { if (_head != null) { _jumpNumber--; JumpEvent?.Invoke(transform.position); _head.Hit(5, Vector3.up * jump, head.position); _landed = false; } } if (!_falling && _controller.isGrounded) { _jumpNumber = 1; } }
private void OnEnable() { jumpEvent += JumpEventFired; }
private void OnDisable() { jumpEvent -= JumpEventFired; }
public void InvokeJumpEvent() => JumpEvent?.Invoke();
internal void Jump() { JumpEvent?.Invoke(); }
void FixedUpdate() { if (RigidBody.IsSleeping()) { RigidBody.WakeUp(); } JumpAfterCollideCountdown -= Time.fixedDeltaTime; WallJumpAfterCollideCountdown -= Time.fixedDeltaTime; if (transform.position.y <= MasterController.Instance.YDeath) { RigidBody.velocity = Vector3.zero; RigidBody.angularVelocity = Vector3.zero; transform.position = MasterController.Instance.SpawnPoint.transform.position; transform.rotation = MasterController.Instance.SpawnPoint.transform.rotation; Camera.Reset(); return; } //Rotation Vector3 fromCamera = transform.position - Camera.transform.position; fromCamera.y = 0; fromCamera.Normalize(); if (fromCamera.magnitude < .1f) { fromCamera = Vector3.forward; } float tickSpeed = Speed; if ((Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S)) && (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))) { tickSpeed *= .5f; } if (Input.GetKey(KeyCode.W)) { AddMovementForce(Quaternion.identity, fromCamera, tickSpeed); } if (Input.GetKey(KeyCode.S)) { AddMovementForce(Quaternion.Euler(0, 180, 0), fromCamera, tickSpeed); } if (Input.GetKey(KeyCode.A)) { AddMovementForce(Quaternion.Euler(0, -90, 0), fromCamera, tickSpeed); } if (Input.GetKey(KeyCode.D)) { AddMovementForce(Quaternion.Euler(0, 90, 0), fromCamera, tickSpeed); } TimeBetweenJumpsAccum += Time.fixedDeltaTime; if (Input.GetKeyUp(KeyCode.Space)) { HasLetGoOfJump = true; } if (IsInJumpMode) { FallingTime += Time.fixedDeltaTime; if (Input.GetKey(KeyCode.Space)) { if (FallingTime >= TimeBetweenJumps) { IsInJumpMode = false; } else { AddJumpForce(); } } else { IsInJumpMode = false; } } else if (HasLetGoOfJump && Input.GetKey(KeyCode.Space) && TimeBetweenJumpsAccum >= TimeBetweenJumps) { bool jumped = false; if (JumpAfterCollideCountdown > 0) { HasWallJumped = false; JumpAfterCollideCountdown = 0; if (JumpEvent != null) { JumpEvent.Invoke(this, false); } jumped = true; Debug.Log(DateTime.Now + ": Jump!"); } else if (!HasWallJumped && WallJumpAfterCollideCountdown > 0) { HasWallJumped = true; WallJumpAfterCollideCountdown = 0; if (JumpEvent != null) { JumpEvent.Invoke(this, true); } jumped = true; Debug.Log(DateTime.Now + ": Wall Jump!"); } if (jumped) { AddJumpForce(); TimeBetweenJumpsAccum = 0; FallingTime = 0; IsInJumpMode = true; HasLetGoOfJump = false; } } }