// 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); } }
// Update is called once per frame void Update() { if (controllable && Input != null) { inputMove.x = Input.GetAxis("MoveHorizontal"); inputMove.y = Input.GetAxis("MoveVertical"); inputAim.x = Input.GetAxis("AimHorizontal"); inputAim.y = Input.GetAxis("AimVertical"); movementController.MoveUpdate(inputMove, inputAim); if (Input.GetButtonDown("Attack")) { if (character != null) { character.Attack(); } } if (Input.GetButtonDown("Jump")) { if (movementController != null) { movementController.Jump(); } } if (Input.GetButtonDown("Shot")) { if (character != null) { character.StartShoting(); } } if (Input.GetButtonUp("Shot")) { if (character != null) { character.StopShoting(); } } if (Input.GetButtonDown("Defence")) { if (movementController != null) { movementController.StartBlocking(); } } if (Input.GetButtonUp("Defence")) { if (movementController != null) { movementController.StopBlocking(); } } if (Input.GetButtonDown("Dash")) { if (movementController != null) { movementController.Dash(); } } } }