private void JumpAction() { if (character.InAir == false) { doubleJump = false; if (Input.GetAxis(controllerLeftHorizontal) > 0.2f) { character.Direction = 1; crouchTime = crouchJumpTime; character.Action(crouchController); } else if (Input.GetAxis(controllerLeftHorizontal) < -0.2f) { character.Direction = -1; crouchTime = crouchJumpTime; character.Action(crouchController); } else { character.SetSpeed(0, 0); character.JumpDefault(); } } StopBuffer(); }
// ========================================================================================= protected virtual void InputMovement(Character character, CharacterState state) { if (state != CharacterState.Idle && state != CharacterState.Moving || character.InAir != false) { return; } if (Mathf.Abs(Input.GetAxis(controllerLeftVertical)) > 0.2f) { stickY = Input.GetAxis(controllerLeftVertical); } else { stickY = 0; } if (Input.GetAxis(controllerLeftHorizontal) > 0.2f) { stickX = Input.GetAxis(controllerLeftHorizontal); character.Direction = 1; } else if (Input.GetAxis(controllerLeftHorizontal) < -0.2f) { stickX = Input.GetAxis(controllerLeftHorizontal); character.Direction = -1; } else { stickX = 0; } Vector2 move = new Vector2(stickX, stickY); move.Normalize(); character.SetSpeed(move.x * character.CharacterStat.GetSpeed(), move.y * character.CharacterStat.GetSpeed()); }
// ========================================================================================= /*private void InputDash() { if ((Input.GetButtonDown("ControllerB") || bufferDashActive == true) && state == CharacterState.Acting && canMoveCancel == true && currentAttack != null) { if (currentAttack.AttackBehavior.DashCancel == true) CancelAction(); } else if (Input.GetButtonDown("ControllerB") && state == CharacterState.Acting) { bufferDashActive = true; StartBuffer(); } if (state != CharacterState.Idle && state != CharacterState.Moving || inAir != false) { return; } if(bufferDashActive == true) { DashAction(); } else if (Input.GetButtonDown("ControllerB")) { DashAction(); } } private void DashAction() { if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f) { Action(dashForward); } else { Action(dashBack); } StopBuffer(); }*/ // ========================================================================================= private void InputJump(Character character, CharacterState state) { if (crouchTime > 0 && character.State != CharacterState.Acting) { crouchTime = 0; } if (crouchTime > 0) { crouchTime -= Time.deltaTime;// * characterMotionSpeed; if (crouchTime <= 0) { character.SetSpeed(character.CharacterStat.GetSpeed() * character.Direction, 0); character.CancelAct(); character.JumpDefault(); return; } } if(bufferJumpActive == true) { if(state == CharacterState.Idle || state == CharacterState.Moving) { JumpAction(); } else if (state == CharacterState.Acting && character.CanMoveCancel == true && character.CurrentAttack != null) { if (character.CurrentAttack.AttackBehavior.JumpCancel == true) { character.CancelAction(); JumpAction(); } } } if (Input.GetButtonDown(controllerA)) { bufferJumpActive = true; StartBuffer(); if (state == CharacterState.Idle || state == CharacterState.Moving) { JumpAction(); } else if (state == CharacterState.Acting && character.CanMoveCancel == true && character.CurrentAttack != null) { if (character.CurrentAttack.AttackBehavior.JumpCancel == true) { character.CancelAction(); JumpAction(); } } } }
public void HasHit(Character target) { target.PlaySound(attackBehavior.OnHitSound); //user.SetTarget(target); user.HitConfirm(); if (attackBehavior.OnHitCombo != null) user.Action(attackBehavior.OnHitCombo); if (attackBehavior.UserKnockbackX != 0 || attackBehavior.UserKnockbackZ != 0) { user.SetSpeed(attackBehavior.UserKnockbackX * -direction, 0); user.Jump(attackBehavior.UserKnockbackZ); } //Feedback if (attackBehavior.OnHitAnimation != null) Instantiate(attackBehavior.OnHitAnimation, target.ParticlePoint.position, Quaternion.identity); if (attackBehavior.HitStopGlobal == false && attackBehavior.HitStop > 0) { target.SetCharacterMotionSpeed(0, attackBehavior.HitStop); if(attackBehavior.HitStopUser == true) user.SetCharacterMotionSpeed(0, attackBehavior.HitStop); else if (attackBehavior.HitStopProjectile == true) { AttackMotionSpeed(0); StartCoroutine(MotionSpeedCoroutine(attackBehavior.HitStop)); } } if (attackBehavior.ThrowState == true) { target.Throw(user.ThrowPoint, direction, user.SpriteRenderer.transform.localScale.x); user.SetCharacterToThrow(target); } if (attackBehavior.IsMultiHit == false) { ActionEnd(); } else { ActionUnactive(); } }
public override float StartBehavior(EnemyController enemyController, Character character) { character.SetSpeed(0, 0); return(base.StartBehavior(enemyController, character)); }