public void StartBlocking() { if (canBlocking && !forceAiming) { if (weapon != null) { if (weapon.blockPower > 0) { blocking = false; parry = true; canAiming = false; if (aiming) { EndAiming(); } canAttack = false; if (movementController != null) { movementController.ResetArmsPosition(); movementController.UnlockAnimations(); movementController.PlayAnimation(SNMovementController.AnimationsStates.Parry, true); movementController.canMove = false; movementController.canDash = false; movementController.canJump = false; } if (weapon.weaponAnimator != null) { weapon.weaponAnimator.Play("Parry"); } if (parryDelayCo != null) { StopCoroutine(parryDelayCo); } parryDelayCo = StartCoroutine(EndParryDelayed(weapon.parryKnockbackDelay)); } } } }
// Update is called once per frame void Update() { if (!character.dead) { if (target != null && target.targetObject != null) { CheckSight(target); float targetDistance = Vector2.Distance(this.transform.position, target.targetObject.transform.position); target.distance = targetDistance; inputMove = Vector2.zero; if (AIState != AIStates.Melee && AIState != AIStates.Shooting && AIState != AIStates.Wait) { HandleMove(targetDistance, target); } if (AIState == AIStates.Melee) { HandleMelee(); } if (AIState == AIStates.Shooting) { HandleShooting(); } if (currentTimeBetweenAttacks <= 0) { if (target.lineOfSight) { if (canMelee && (targetDistance <= meleeRange)) { if (AIState != AIStates.Melee) { currentAttackLoadTime = attackLoadTime; targetPosition = target.targetObject.transform.position; movementController.lastInputMove = (targetPosition - this.transform.position).normalized; movementController.PlayAnimation( SNMovementController.AnimationsStates.Prepare, true); character.immune = true; AIState = AIStates.Melee; } } else if (canShoot && (targetDistance <= shotRange)) { if (AIState != AIStates.Melee) { currentAttackLoadTime = attackLoadTime; targetPosition = target.targetObject.transform.position; movementController.PlayAnimation( SNMovementController.AnimationsStates.Prepare, true); AIState = AIStates.Shooting; } } } } else { currentTimeBetweenAttacks -= Time.deltaTime; } if (target.targetCharacter.dead) { AITargets.Remove(target); target = null; } } else { FindTargets(); } movementController.MoveUpdate(inputMove); target = ChooseTarget(AggroBase); } }