public bool GetAttackDataOrUseNonAttackSkill(bool isLeftHand, out float attackDistance, out float attackFov) { attackDistance = PlayerCharacterEntity.GetAttackDistance(isLeftHand); attackFov = PlayerCharacterEntity.GetAttackFov(isLeftHand); if (queueUsingSkill.HasValue) { Skill skill = null; if (GameInstance.Skills.TryGetValue(queueUsingSkill.Value.dataId, out skill) && skill != null) { if (skill.IsAttack()) { attackDistance = PlayerCharacterEntity.GetSkillAttackDistance(skill, isLeftHand); attackFov = PlayerCharacterEntity.GetSkillAttackFov(skill, isLeftHand); } else { // Stop movement to use non attack skill PlayerCharacterEntity.StopMove(); RequestUsePendingSkill(false, null); return(false); } } else { queueUsingSkill = null; } } // Return true if going to attack return(true); }
public bool GetAttackDistanceAndFov(out float attackDistance, out float attackFov) { attackDistance = PlayerCharacterEntity.GetAttackDistance(); attackFov = PlayerCharacterEntity.GetAttackFov(); if (queueUsingSkill.HasValue) { var queueUsingSkillValue = queueUsingSkill.Value; Skill skill = null; if (GameInstance.Skills.TryGetValue(queueUsingSkillValue.dataId, out skill) && skill != null) { if (skill.IsAttack()) { attackDistance = PlayerCharacterEntity.GetSkillAttackDistance(skill); attackFov = PlayerCharacterEntity.GetSkillAttackFov(skill); } else { // Stop movement to use non attack skill PlayerCharacterEntity.StopMove(); RequestUsePendingSkill(); return(false); } } else { queueUsingSkill = null; } } return(true); }
protected virtual void UpdateWASDInput() { if (controllerMode != PlayerCharacterControllerMode.WASD && controllerMode != PlayerCharacterControllerMode.Both) { return; } // If mobile platforms, don't receive input raw to make it smooth bool raw = !InputManager.useMobileInputOnNonMobile && !Application.isMobilePlatform; Vector3 moveDirection = GetMoveDirection(InputManager.GetAxis("Horizontal", raw), InputManager.GetAxis("Vertical", raw)); if (moveDirection.magnitude != 0f) { HideNpcDialogs(); queueUsingSkill = null; FindAndSetBuildingAreaFromCharacterDirection(); } // For WASD mode, Using skill when player pressed hotkey if (queueUsingSkill.HasValue) { UsingSkillData queueUsingSkillValue = queueUsingSkill.Value; destination = null; PlayerCharacterEntity.StopMove(); Skill skill = null; if (GameInstance.Skills.TryGetValue(queueUsingSkillValue.dataId, out skill) && skill != null) { if (skill.IsAttack()) { BaseCharacterEntity targetEntity; if (TryGetSelectedTargetAsAttackingCharacter(out targetEntity)) { SetTarget(targetEntity); } if (wasdLockAttackTarget && !TryGetAttackingCharacter(out targetEntity)) { BaseCharacterEntity nearestTarget = PlayerCharacterEntity.FindNearestAliveCharacter <BaseCharacterEntity>(PlayerCharacterEntity.GetSkillAttackDistance(skill, isLeftHandAttacking) + lockAttackTargetDistance, false, true, false); if (nearestTarget != null) { // Set target, then use skill later when moved nearby target PlayerCharacterEntity.SetTargetEntity(nearestTarget); } else { // No nearby target, so use skill immediately if (RequestUsePendingSkill(isLeftHandAttacking, null)) { isLeftHandAttacking = !isLeftHandAttacking; } } } else if (!wasdLockAttackTarget) { // Not lock target, so not finding target and use skill immediately if (RequestUsePendingSkill(isLeftHandAttacking, null)) { isLeftHandAttacking = !isLeftHandAttacking; } } } else { // Not attack skill, so use skill immediately RequestUsePendingSkill(isLeftHandAttacking, null); } } else { queueUsingSkill = null; } } // Attack when player pressed attack button else if (InputManager.GetButton("Attack")) { destination = null; PlayerCharacterEntity.StopMove(); BaseCharacterEntity targetEntity; if (TryGetSelectedTargetAsAttackingCharacter(out targetEntity)) { SetTarget(targetEntity); } if (wasdLockAttackTarget && !TryGetAttackingCharacter(out targetEntity)) { // Find nearest target and move to the target BaseCharacterEntity nearestTarget = PlayerCharacterEntity .FindNearestAliveCharacter <BaseCharacterEntity>( PlayerCharacterEntity.GetAttackDistance(isLeftHandAttacking) + lockAttackTargetDistance, false, true, false); SelectedEntity = nearestTarget; if (nearestTarget != null) { // Set target, then attack later when moved nearby target PlayerCharacterEntity.SetTargetEntity(nearestTarget); } else { // No nearby target, so attack immediately if (PlayerCharacterEntity.RequestAttack(isLeftHandAttacking)) { isLeftHandAttacking = !isLeftHandAttacking; } } } else if (!wasdLockAttackTarget) { // Find nearest target and set selected target to show character hp/mp UIs BaseCharacterEntity nearestTarget = PlayerCharacterEntity .FindNearestAliveCharacter <BaseCharacterEntity>( PlayerCharacterEntity.GetAttackDistance(isLeftHandAttacking), false, true, false, true, PlayerCharacterEntity.GetAttackFov(isLeftHandAttacking)); SelectedEntity = nearestTarget; // Not lock target, so not finding target and attack immediately if (PlayerCharacterEntity.RequestAttack(isLeftHandAttacking)) { isLeftHandAttacking = !isLeftHandAttacking; } } } // Move if (moveDirection.magnitude != 0f) { PlayerCharacterEntity.StopMove(); destination = null; ClearTarget(); targetLookDirection = moveDirection.normalized; } // Always forward MovementState movementState = MovementState.Forward; if (InputManager.GetButtonDown("Jump")) { movementState |= MovementState.IsJump; } PlayerCharacterEntity.KeyMovement(moveDirection, movementState); }