private void Update() { shootTime -= Time.deltaTime; if (shootTime <= 0) { Fire(); } if (canJump) { jumpTime -= Time.deltaTime; if (jumpTime <= 0) { if (movComp.IsGrounded()) { movComp.Jump(); if (!isWaitingDestroy) { audioSource.PlayOneShot(jumpStartClip, 3); } } jumpTime = Random.Range(minJumpRate, maxJumpRate); } } }
/// <summary> /// Forces the player to jump. If it is blocking, cancels it. /// </summary> public void Jump(bool multijump) { MC.Jump(multijump); if (CC.IsBlocking) { CC.EndBlock(); } }
void FixedUpdate() { //Send input to the Movement Component in order to move the character movementComponent.MoveCharacter(Input.GetAxis("Horizontal")); if (Input.GetKeyDown(KeyCode.UpArrow)) { movementComponent.Jump(); } }
void FixedUpdate() { //Send input to the Movement Component in order to move the character movementComponent.MoveCharacter(Input.GetAxis("Horizontal")); //Check if the Up Arrow has been pressed, and if so, send the Jump input to the Movement Component if (Input.GetKeyDown(KeyCode.UpArrow)) { movementComponent.Jump(); } }
private void FixedUpdate() { float h = Input.GetAxisRaw("Horizontal"); m_movement.Movement(h); if (Input.GetKeyDown(KeyCode.Space)) { m_movement.Jump(); } }
public void OnPointerDown(PointerEventData eventData) { movementComponent.Jump(); }
//TODO: Make this account for attack range and entity size. //TODO: Maybe make this not allow them to leave their platform as well, just to avoid issues with pathing. private void FollowEntity(Entity e, GameTime Time) { var entity = this.Parent; Random r = new Random(); float attackRange = AttributesComponent.MeleeAttackRange.X; if (entity.Location.Contains((int)e.Location.Center.X, (int)e.Location.Center.Y)) { if (!PhysicsComponent.IsGrounded) { return; // Do nothing, just wait for us to fall on our location. } } else { bool MissingHorizontally = e.Location.Center.X - attackRange > entity.Location.Right || e.Location.Center.X + attackRange < entity.Location.Left; if (entity.Location.Bottom > e.Location.Bottom && !MissingHorizontally) { if (CanJumpToChase) { MovementComponent.Jump(AllowMultiJump); } } if (MissingHorizontally) { //Most of this code prevents the AI from jumping off their current platform to chase player. //Often results in death. float checkDistance = PhysicsComponent.VelocityX * Time.GetTimeScalar(); Vector2 leftPlatformVector = new Vector2(Parent.Location.Left + checkDistance, Parent.Location.Bottom + 1); Vector2 rightPlatformVector = new Vector2(Parent.Location.Right + checkDistance, Parent.Location.Bottom + 1); Vector2 leftWallVector = new Vector2(Parent.Location.Left + checkDistance, Parent.Location.Center.Y); Vector2 rightWallVector = new Vector2(Parent.Location.Right + checkDistance, Parent.Location.Center.Y); bool leftPossible = PhysicsSystem.IsLocationSolid(leftPlatformVector) && !PhysicsSystem.IsLocationSolid(leftWallVector); bool rightPossible = PhysicsSystem.IsLocationSolid(rightPlatformVector) && !PhysicsSystem.IsLocationSolid(rightWallVector); if (entity.Location.Center.X > e.Location.Center.X + attackRange) { if (leftPossible) { MovementComponent.BeginWalking(Direction.Left); } else { MovementComponent.StopWalking(); } } else if (entity.Location.Center.X < e.Location.Center.X - attackRange) { if (rightPossible) { MovementComponent.BeginWalking(Direction.Right); } else { MovementComponent.StopWalking(); } } } else { if (MovementComponent.IsWalking) { MovementComponent.StopWalking(); } } //Ensure they are facing the correct direction, if they move within AI rectangle. if (entity.Location.Center.X > e.Location.Center.X) { MovementComponent.CurrentDirection = Direction.Left; } else if (entity.Location.Center.X < e.Location.Center.X) { MovementComponent.CurrentDirection = Direction.Right; } } }
public void OnClick() { movement.Jump(); }