public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); if (stateInput.playerController.isGrounded) { character.ChangeState <PlayerIdleState>(); } else if (stateInput.rb.velocity.y <= 0) { character.ChangeState <PlayerFallingState>(); } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); // if (InputMap.Instance.GetInput(ActionType.RIGHT)) // { // horizontalMovement++; // } // if (InputMap.Instance.GetInput(ActionType.LEFT)) // { // horizontalMovement--; // } if (stateInput.lastXDir != horizontalMovement) { if (horizontalMovement != 0) { //stateInput.spriteRenderer.flipX = horizontalMovement == -1; stateInput.lastXDir = horizontalMovement; } } }
public override void Update(PlayerStateInput stateInput) { if (dashTimer > 0) { stateInput.rb.velocity = new Vector2(dir * stateInput.playerController.dashSpeed, 0); dashTimer -= Time.deltaTime; if (stateInput.playerController.tookDamage()) { stateInput.playerController.setDamaged(false); Vector2 launchDirection = stateInput.playerController.launchVelocity; if (stateInput.player.transform.rotation.y == 0) { launchDirection.x = -launchDirection.x; } character.ChangeState <PlayerLaunchState>(new LaunchStateTransitionInfo(launchDirection, stateInput.playerController.moveAfterLaunchTime, true)); return; } } else { stateInput.rb.velocity = Vector2.zero; character.ChangeState <PlayerFallingState>(); } }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { //stateInput.canDash = false; //stateInput.playerController.dashing = true; dashTimer = stateInput.playerController.dashTime; stateInput.playerController.canDash = false; }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); if (stateInput.playerController.isGrounded) { character.ChangeState <PlayerIdleState>(); return; } if (stateInput.rb.velocity.y <= 0) { character.ChangeState <PlayerFallingState>(); return; } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { Debug.Log(stateInput.lastXDir + " " + horizontalMovement); stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.lastXDir = horizontalMovement; }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { dashTimer = stateInput.playerController.dashTime; dir = stateInput.player.transform.rotation.eulerAngles.y == 180 ? -1 : 1; stateInput.anim.Play("Player_Dash"); EventManager.TriggerEvent <PlayerDashEvent, Vector3>(stateInput.player.transform.position); }
public override void FixedUpdate(PlayerStateInput stateInput) { if (false)//timer <= 0) { stateInput.playerController.HandleMovement(); } }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = stateInput.playerController.checkIfGrounded(); Debug.Log(stateInput.rb.velocity); if (stateInput.playerController.isGrounded && timer <= 0) { character.ChangeState <PlayerIdleState>(); } if (timer <= 0) { // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.lastXDir = horizontalMovement; } timer -= Time.deltaTime; }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = stateInput.playerController.checkIfGrounded(); if (stateInput.playerController.canDash() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerControls.InGame.SwitchLeft.WasPressedThisFrame()) { stateInput.playerController.switchGun(false); } if (stateInput.playerControls.InGame.SwitchRight.WasPressedThisFrame()) { stateInput.playerController.switchGun(true); } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.anim.SetTrigger("shoot"); stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.Jump(); } if (stateInput.rb.velocity.y <= 0) { character.ChangeState <PlayerFallingState>(); return; } if (stateInput.playerControls.InGame.Jump.WasReleasedThisFrame()) { stateInput.playerController.JumpRelease(); character.ChangeState <PlayerFallingState>(); return; } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.lastXDir = horizontalMovement; }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); if (stateInput.playerController.canDash() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerControls.InGame.SwitchLeft.WasPressedThisFrame()) { stateInput.playerController.switchGun(false); } if (stateInput.playerControls.InGame.SwitchRight.WasPressedThisFrame()) { stateInput.playerController.switchGun(true); } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.hasJumpedOnce = true; stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); return; } if (stateInput.playerController.isGrounded) { character.ChangeState <PlayerIdleState>(); return; } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { Debug.Log(stateInput.lastXDir + " " + horizontalMovement); stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.lastXDir = horizontalMovement; }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); // if (stateInput.playerController.canDash && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { // character.ChangeState<PlayerDashState>(); // return; // } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.IsPressed() && stateInput.playerController.isGrounded) { stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); } else if ((stateInput.rb.velocity.y < 0) && !stateInput.playerController.isGrounded) { character.ChangeState <PlayerFallingState>(); } else { // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } // if (InputMap.Instance.GetInput(ActionType.RIGHT)) // { // horizontalMovement++; // } // if (InputMap.Instance.GetInput(ActionType.LEFT)) // { // horizontalMovement--; // } if (stateInput.lastXDir != horizontalMovement) { if (horizontalMovement != 0) { stateInput.lastXDir = horizontalMovement; //stateInput.anim.Play("Player_Run"); //stateInput.spriteRenderer.flipX = horizontalMovement == 1; } else { //stateInput.anim.Play("Player_Idle"); } } } }
public override void FixedUpdate(PlayerStateInput stateInput) { if (timer >= 0) { stateInput.playerController.HandleLerpMovement(); } else { stateInput.playerController.HandleMovement(); } }
public override void Update(PlayerStateInput stateInput) { if (dashTimer > 0) { stateInput.rb.velocity = new Vector2(stateInput.lastXDir * stateInput.playerController.dashSpeed, 0); dashTimer -= Time.deltaTime; } else { stateInput.rb.velocity = Vector2.zero; character.ChangeState <PlayerFallingState>(); } }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { if (transitionInfo == null) { timer = launchTime; } else { LaunchStateTransitionInfo launchTransition = (LaunchStateTransitionInfo)transitionInfo; timer = launchTransition.moveAfterLaunchTime; stateInput.playerController.launchPlayer(launchTransition.launchVelocity); stateInput.playerController.SetPlayerImmunity(launchTransition.invincible); } //stateInput.anim.Play("Player_Jump"); }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); if (stateInput.playerController.canDash() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); } else if ((stateInput.rb.velocity.y < 0) && !stateInput.playerController.isGrounded) { character.ChangeState <PlayerFallingState>(); } else { // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); //stateInput.anim.Play("Player_Run"); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; if (horizontalMovement == 0) { //stateInput.anim.Play("Player_Idle"); } } stateInput.lastXDir = horizontalMovement; } }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = Physics2D.OverlapCircle(stateInput.playerController.groundCheck.position, stateInput.playerController.checkRadius, stateInput.playerController.whatIsGround); if (stateInput.playerController.canDash() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.hasJumpedOnce = true; stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); } if (stateInput.playerController.isGrounded) { character.ChangeState <PlayerIdleState>(); } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (stateInput.lastXDir != horizontalMovement) { if (horizontalMovement != 0) { stateInput.lastXDir = horizontalMovement; stateInput.spriteRenderer.flipX = horizontalMovement == -1; } } }
public override void FixedUpdate(PlayerStateInput stateInput) { stateInput.playerController.HandleMovement(); }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { stateInput.lastXDir = 0; stateInput.anim.Play("Player_Idle"); }
public override void ForceCleanUp(PlayerStateInput stateInput) { }
public override void ForceCleanUp(PlayerStateInput stateInput) { stateInput.rb.velocity = Vector2.zero; stateInput.playerController.startDashCooldown(); }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { timer = launchTime; //stateInput.anim.Play("Player_Jump"); }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { stateInput.lastXDir = 0; stateInput.playerController.canDash = true; //stateInput.anim.Play("Player_Idle"); }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { dashTimer = stateInput.playerController.dashTime; dir = stateInput.player.transform.rotation.eulerAngles.y == 180 ? -1 : 1; stateInput.anim.Play("Player_Dash"); }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = stateInput.playerController.checkIfGrounded(); if (stateInput.playerController.dashAble() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerController.tookDamage()) { stateInput.playerController.setDamaged(false); Vector2 launchDirection = stateInput.playerController.launchVelocity; if (stateInput.player.transform.rotation.y == 0) { launchDirection.x = -launchDirection.x; } Debug.Log("chaning to launch!"); character.ChangeState <PlayerLaunchState>(new LaunchStateTransitionInfo(launchDirection, stateInput.playerController.moveAfterLaunchTime, true)); return; } if (stateInput.playerControls.InGame.SwitchLeft.WasPressedThisFrame()) { stateInput.playerController.switchGun(-1); } if (stateInput.playerControls.InGame.SwitchRight.WasPressedThisFrame()) { stateInput.playerController.switchGun(1); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); return; } if ((stateInput.rb.velocity.y < 0) && !stateInput.playerController.isGrounded) { character.ChangeState <PlayerFallingState>(); return; } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.anim.SetFloat("speed", Mathf.Abs(horizontalMovement)); stateInput.lastXDir = horizontalMovement; if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame() && stateInput.playerController.canFire && horizontalMovement != 0) { stateInput.anim.Play("Player_Fire_Moving"); stateInput.playerController.Shoot(); Vector2 launchDirection = stateInput.playerController.getRecoilVector(); if (stateInput.player.transform.rotation.y == 0) { launchDirection.x = -launchDirection.x; } character.ChangeState <PlayerLaunchState>(new LaunchStateTransitionInfo(launchDirection, 0.1f, false)); } else if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame() && stateInput.playerController.canFire && horizontalMovement == 0) { stateInput.anim.Play("Player_Fire_Idle"); stateInput.playerController.Shoot(); Vector2 launchDirection = stateInput.playerController.getRecoilVector(); if (stateInput.player.transform.rotation.y == 0) { launchDirection.x = -launchDirection.x; } character.ChangeState <PlayerLaunchState>(new LaunchStateTransitionInfo(launchDirection, 0.1f, false)); } }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { stateInput.anim.Play("Player_Fall"); }
public override void Update(PlayerStateInput stateInput) { stateInput.playerController.isGrounded = stateInput.playerController.isGrounded = stateInput.playerController.checkIfGrounded(); if (stateInput.playerController.dashAble() && stateInput.playerControls.InGame.Dash.WasPressedThisFrame()) { character.ChangeState <PlayerDashState>(); return; } if (stateInput.playerController.tookDamage()) { stateInput.playerController.setDamaged(false); Vector2 launchDirection = stateInput.playerController.launchVelocity; if (stateInput.player.transform.rotation.y == 0) { launchDirection.x = -launchDirection.x; } character.ChangeState <PlayerLaunchState>(new LaunchStateTransitionInfo(launchDirection, stateInput.playerController.moveAfterLaunchTime, true)); return; } if (stateInput.playerControls.InGame.SwitchLeft.WasPressedThisFrame()) { stateInput.playerController.switchGun(-1); } if (stateInput.playerControls.InGame.SwitchRight.WasPressedThisFrame()) { stateInput.playerController.switchGun(1); } if (stateInput.playerControls.InGame.Shoot.WasPressedThisFrame()) { stateInput.playerController.Shoot(); } if (stateInput.playerControls.InGame.Jump.WasPressedThisFrame() && stateInput.playerController.canJump()) { stateInput.playerController.hasJumpedOnce = true; stateInput.playerController.Jump(); character.ChangeState <PlayerJumpingState>(); return; } if (stateInput.playerController.isGrounded) { character.ChangeState <PlayerIdleState>(); return; } // Movement animations and saving previous input int horizontalMovement = (int)Mathf.Sign(stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x); if (stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x > -0.1f && stateInput.playerControls.InGame.Move.ReadValue <Vector2>().x < 0.1f) { horizontalMovement = 0; } if (horizontalMovement != 0 && stateInput.lastXDir != horizontalMovement) { stateInput.player.transform.rotation = Quaternion.Euler(0, horizontalMovement == -1 ? 180 : 0, 0); // stateInput.spriteRenderer.flipX = horizontalMovement == -1; } stateInput.lastXDir = horizontalMovement; }
public override void Enter(PlayerStateInput stateInput, CharacterStateTransitionInfo transitionInfo = null) { dashTimer = stateInput.playerController.dashTime; stateInput.anim.Play("Player_Dash"); }
public override void ForceCleanUp(PlayerStateInput stateInput) { stateInput.rb.velocity = Vector2.zero; }