/// <summary> /// Can the ability be started? /// </summary> /// <returns>True if the ability can be started.</returns> public override bool CanStartAbility() { if (m_RequireAim && !m_Controller.Aiming) { return(false); } // Start the ability if the left, right, or back buttons are double pressed. if (m_StartOnDoublePress) { for (int i = 0; i < 2; ++i) { var input = i == 0 ? m_Controller.InputVector.x : m_Controller.InputVector.z; if (Mathf.Abs(input) > 0) { // The character can dodge left or right so check the sign value. DodgeType dodgeType; if (i == 0) { dodgeType = input > 0 ? DodgeType.Right : DodgeType.Left; } else { dodgeType = input > 0 ? DodgeType.None : DodgeType.Back; } // There is no foward dodge. if (dodgeType == DodgeType.None) { return(false); } if (m_DodgeType == dodgeType && m_MovementRelease[i] && m_InitialMovementTime[i] + 0.2f > Time.time) { m_MovementRelease[i] = false; return(true); } m_DodgeType = dodgeType; m_InitialMovementTime[i] = Time.time; m_MovementRelease[i] = false; } else if (m_InitialMovementTime[i] != -1 && input == 0) { m_MovementRelease[i] = true; } } return(false); } // If the ability isn't being started with a double press then use the regular start methods. return(base.CanStartAbility()); }
private void InitiateDodge(int amount,DodgeType type){ dodgeLimit = amount; dodgeType = type; state = State.Dodge; }
private void AttackDodge( DodgeType type){ dodgeTime += Time.deltaTime; // Goes in once to get the random direction ONCE until Dodging is false again. if (!isDodging) { switch (type) { case DodgeType.Randomize: dodgeDir = directions [Random.Range (0, directions.Length)]; break; case DodgeType.Aggression: dodgeDir = player.transform.position - transform.position + new Vector3 (0, 0, 3); break; case DodgeType.Evasive: dodgeDir = transform.position - player.transform.position; break; } dodgePos = transform.position + dodgeDir; // if(CheckObstacle(dodgePos,wallLayer)){ // if(attempt < 15){ // AttackDodge(type); // attempt++; // return; // } // } isDodging = true; } /* Timer ------------------- */ if (dodgeTime < dodgeDelay) { transform.position = Vector3.Lerp (transform.position, dodgePos, 7f * Time.deltaTime); } else { dodgeTime = 0f; isDodging = false; dodgeCount++; } if (dodgeCount >= dodgeLimit) { ResetDodge(); //agent.Stop(); } }