|
|
@@ -139,33 +139,35 @@ public class ArmBow : MonoBehaviour
|
|
|
|
|
|
void shoot() {
|
|
|
// 筛选出一个稳定的发射角度
|
|
|
+ #region
|
|
|
Quaternion absolute_rotation = this.bowCamera.transform.rotation;
|
|
|
Quaternion final_rotation = this.bowCamera.transform.rotation;
|
|
|
if (recordCount >= recordRotations.Length) {
|
|
|
- int single_check_count = 6;
|
|
|
+ for (int i = 0; i < recordRotationVars.Length; i++) {
|
|
|
+ recordRotationVars[i] = Quaternion.Angle(recordRotations[i], recordRotations[i + 1]);
|
|
|
+ }
|
|
|
+ int startCheckIndex = 5;
|
|
|
+ int checkAfterCount = 5;
|
|
|
float min_wave = float.MaxValue;
|
|
|
- for (int i = 0; i < recordRotationVars.Length; i++)
|
|
|
+ for (int i = startCheckIndex; i < recordRotationVars.Length - checkAfterCount; i++)
|
|
|
{
|
|
|
- recordRotationVars[i] = Quaternion.Angle(recordRotations[i], recordRotations[i + 1]);
|
|
|
- if (i >= single_check_count - 1)
|
|
|
+ float wave = 0;
|
|
|
+ for (int j = i; j <= i + checkAfterCount; j++)
|
|
|
+ {
|
|
|
+ wave += recordRotationVars[j];
|
|
|
+ }
|
|
|
+ if (wave < min_wave)
|
|
|
{
|
|
|
- float wave = 0;
|
|
|
- for (int j = i; j > i - single_check_count; j--)
|
|
|
- {
|
|
|
- wave += recordRotationVars[j];
|
|
|
- }
|
|
|
- if (wave < min_wave)
|
|
|
- {
|
|
|
- min_wave = wave;
|
|
|
- int best_rotation_index = i - single_check_count + 1;
|
|
|
- absolute_rotation = recordRotations[best_rotation_index];
|
|
|
- best_rotation_index -= this.shootBackTime;
|
|
|
- if (best_rotation_index < 0) best_rotation_index = 0;
|
|
|
- final_rotation = recordRotations[best_rotation_index];
|
|
|
- }
|
|
|
+ min_wave = wave;
|
|
|
+ int best_rotation_index = i;
|
|
|
+ absolute_rotation = recordRotations[best_rotation_index];
|
|
|
+ best_rotation_index -= this.shootBackTime;
|
|
|
+ if (best_rotation_index < 0) best_rotation_index = 0;
|
|
|
+ final_rotation = recordRotations[best_rotation_index];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ #endregion
|
|
|
|
|
|
Quaternion oldCameraRotation = Camera.main.transform.rotation;
|
|
|
Camera.main.transform.rotation = absolute_rotation;
|
|
|
@@ -187,7 +189,7 @@ public class ArmBow : MonoBehaviour
|
|
|
arrowComp.absoluteRay = absoluteRay;
|
|
|
arrowComp.offsetAngle = GameDebug.ins ?
|
|
|
GameDebug.ins.GetOffsetAngle() :
|
|
|
- FormatAngle(final_rotation.eulerAngles.x) - FormatAngle(absolute_rotation.eulerAngles.x);
|
|
|
+ FormatAngle(Quaternion.Angle(absolute_rotation, final_rotation));
|
|
|
|
|
|
if (ShootCheck.ins && !GameMgr.debugInEditor)
|
|
|
{
|