public override void UpdateAbility() { //Important !! Reset the bow state if is holding but is not aiming if (!RC.IsAiming && isHolding) { isHolding = false; HoldTime = 0; RC.Anim.SetFloat(Hash.IDFloat, 0); //Reset Hold Animator Values Bow.BendBow(0); } BowKnotInHand(); //Update the BowKnot in the Hand if is not Firing }
/// <summary> /// Bow Attack Mode /// </summary> protected virtual void BowAttack(IBow Bow) { if (RC.IsAiming) //Shoot arrows only when is aiming { bool isInRange = RC.Active_IMWeapon.RightHand ? RC.HorizontalAngle <0.5f : RC.HorizontalAngle> -0.5f; //Calculate the Imposible range to shoot if (!isInRange) { isHolding = false; HoldTime = 0; return; } if (RC.InputAttack1.GetInput && !isHolding) //If Attack is pressed Start Bending for more Strength the Bow { RC.SetAction(WeaponActions.Hold); isHolding = true; HoldTime = 0; } if (RC.InputAttack1.GetInput && isHolding) // //If Attack is pressed Continue Bending the Bow for more Strength the Bow { HoldTime += Time.deltaTime; if (HoldTime <= Bow.HoldTime + Time.deltaTime) { Bow.BendBow(HoldTime / Bow.HoldTime); //Bend the Bow } RC.Anim.SetFloat(Hash.IDFloat, HoldTime / Bow.HoldTime); } if (!RC.InputAttack1.GetInput && isHolding) //If Attack is Release Go to next Action and release the Proyectile { var Knot = Bow.KNot; Knot.rotation = Quaternion.LookRotation(RC.AimDirection); //Alingns the Knot and Arrow to the AIM DIRECTION before Releasing the Arrow RC.SetAction(WeaponActions.Fire_Proyectile); //Go to Action FireProyectile isHolding = false; HoldTime = 0; RC.Anim.SetFloat(Hash.IDFloat, 0); //Reset Hold Animator Values Bow.ReleaseArrow(RC.AimDirection); Bow.BendBow(0); RC.OnAttack.Invoke(RC.Active_IMWeapon); //Invoke the On Attack Event } } }
/// <summary> If Attack is Released Go to next Action and release the Proyectile</summary> private void ReleaseArrow() { if (RC.Aim && RC.WeaponAction != WA.Fire_Proyectile && isHolding) //If we are not firing any arrow then try to Attack with the bow { Bow = RC.ActiveWeapon as IBow; //Store the Bow var Knot = Bow.KNot; Knot.rotation = Quaternion.LookRotation(RC.AimDirection); //Aligns the Knot and Arrow to the AIM DIRECTION before Releasing the Arrow RC.WeaponAction = WA.Fire_Proyectile; //Go to Action FireProyectile isHolding = false; HoldTime = 0; Bow.ReleaseArrow(RC.AimDirection); Bow.BendBow(0); Anim.SetFloat(RC.Hash_WHold, 0); //Reset Hold Animator Values RC.OnAttack.Invoke(RC.ActiveWeapon); //Invoke the On Attack Event } }
/// <summary>Bow Attack Mode</summary> protected virtual void BowHold() { if (RC.Aim && RC.WeaponAction != WA.Fire_Proyectile) //Shoot arrows only when is aiming and If we are notalready firing any arrow { Bow = RC.ActiveWeapon as IBow; //Store the Bow bool isInRange = RC.Weapon_is_RightHand ? RC.HorizontalAngle <0.5f : RC.HorizontalAngle> -0.5f; //Calculate the Imposible range to shoot if (!isInRange) { isHolding = false; HoldTime = 0; return; } if (!isHolding) //If Attack is pressed Start Bending for more Strength the Bow { RC.WeaponAction = WA.Hold; isHolding = true; HoldTime = 0; } else // //If Attack is pressed Continue Bending the Bow for more Strength the Bow { HoldTime += Time.deltaTime; var NormalizedTensionBow = TensionCurve.Evaluate(HoldTime / Bow.HoldTime); var NormalizedTensionArm = Mathf.Clamp(NormalizedTensionBow, 0, MaxArmTension); if (HoldTime <= Bow.HoldTime + Time.deltaTime) { Bow.BendBow(NormalizedTensionBow); //Bend the Bow } Anim.SetFloat(RC.Hash_WHold, NormalizedTensionArm); } } }