|
|
@@ -2,49 +2,75 @@ using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.UI;
|
|
|
+using DG.Tweening;
|
|
|
|
|
|
/**瞄准器负载检测 */
|
|
|
public class AimLoadChecker : MonoBehaviour
|
|
|
{
|
|
|
[SerializeField] GameObject outTip;
|
|
|
|
|
|
- void Update()
|
|
|
- {
|
|
|
- bool needActiveOutTip = false;
|
|
|
- if (ArmBow.ins && ArmBow.ins.IsCanShoot() && TargetBody.ins) {
|
|
|
- RaycastHit ray = CrossHair.ins.GetRaycastHit();
|
|
|
- if (ray.transform && ray.transform.gameObject.name == "TargetBody") {
|
|
|
- float mySpeed = Arrow.speed;
|
|
|
- if (GameAssistUI.ins) {
|
|
|
- mySpeed *= GameAssistUI.ins.shootScaleValue;
|
|
|
- }
|
|
|
- Vector3 destination = ray.point;
|
|
|
- Vector3 startPoint = BowCamera.ins.transform.position;
|
|
|
- float deltaX = Mathf.Sqrt(
|
|
|
- Mathf.Pow(destination.x - startPoint.x, 2) +
|
|
|
- Mathf.Pow(destination.z - startPoint.z,2)
|
|
|
- );
|
|
|
- float deltaY = destination.y - startPoint.y;
|
|
|
- float a = 0.5f * Physics.gravity.y * Mathf.Pow(deltaX, 2) / Mathf.Pow(mySpeed, 2);
|
|
|
- float b = deltaX;
|
|
|
- float c = a - deltaY;
|
|
|
- bool hasParabolaAngle = Mathf.Pow(b, 2) - 4 * a * c >= 0;
|
|
|
- if (hasParabolaAngle) {
|
|
|
- float res1 = (-b + Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
|
|
|
- float res2 = (-b - Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
|
|
|
- float parabolaAngle = Mathf.Min(Mathf.Atan(res1), Mathf.Atan(res2)) / Mathf.PI * 180;
|
|
|
+ // void Update()
|
|
|
+ // {
|
|
|
+ // bool needActiveOutTip = false;
|
|
|
+ // if (ArmBow.ins && ArmBow.ins.IsCanShoot() && TargetBody.ins) {
|
|
|
+ // RaycastHit ray = CrossHair.ins.GetRaycastHit();
|
|
|
+ // if (ray.transform && ray.transform.gameObject.name == "TargetBody") {
|
|
|
+ // float mySpeed = Arrow.speed;
|
|
|
+ // if (GameAssistUI.ins) {
|
|
|
+ // mySpeed *= GameAssistUI.ins.shootScaleValue;
|
|
|
+ // }
|
|
|
+ // Vector3 destination = ray.point;
|
|
|
+ // Vector3 startPoint = BowCamera.ins.transform.position;
|
|
|
+ // float deltaX = Mathf.Sqrt(
|
|
|
+ // Mathf.Pow(destination.x - startPoint.x, 2) +
|
|
|
+ // Mathf.Pow(destination.z - startPoint.z,2)
|
|
|
+ // );
|
|
|
+ // float deltaY = destination.y - startPoint.y;
|
|
|
+ // float a = 0.5f * Physics.gravity.y * Mathf.Pow(deltaX, 2) / Mathf.Pow(mySpeed, 2);
|
|
|
+ // float b = deltaX;
|
|
|
+ // float c = a - deltaY;
|
|
|
+ // bool hasParabolaAngle = Mathf.Pow(b, 2) - 4 * a * c >= 0;
|
|
|
+ // if (hasParabolaAngle) {
|
|
|
+ // float res1 = (-b + Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
|
|
|
+ // float res2 = (-b - Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
|
|
|
+ // float parabolaAngle = Mathf.Min(Mathf.Atan(res1), Mathf.Atan(res2)) / Mathf.PI * 180;
|
|
|
|
|
|
- needActiveOutTip = parabolaAngle > 5;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- ActiveOutTip(needActiveOutTip);
|
|
|
+ // needActiveOutTip = parabolaAngle > 5;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // ActiveOutTip(needActiveOutTip);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // public void ActiveOutTip(bool value)
|
|
|
+ // {
|
|
|
+ // if (outTip.activeSelf != value) {
|
|
|
+ // outTip.SetActive(value);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ public static AimLoadChecker ins;
|
|
|
+
|
|
|
+ void Awake() {
|
|
|
+ ins = this;
|
|
|
}
|
|
|
|
|
|
- public void ActiveOutTip(bool value)
|
|
|
- {
|
|
|
- if (outTip.activeSelf != value) {
|
|
|
- outTip.SetActive(value);
|
|
|
+ Sequence outTipSeq;
|
|
|
+ public void ShowOutTip() {
|
|
|
+ if (outTipSeq != null) {
|
|
|
+ outTipSeq.Kill(true);
|
|
|
}
|
|
|
+ outTip.SetActive(true);
|
|
|
+ Text text = outTip.GetComponent<Text>();
|
|
|
+ Sequence seq = DOTween.Sequence();
|
|
|
+ seq.Append(text.DOFade(1, 0f));
|
|
|
+ seq.AppendInterval(3f);
|
|
|
+ seq.Append(text.DOFade(0, 1f));
|
|
|
+ seq.AppendCallback(delegate() {
|
|
|
+ outTip.SetActive(false);
|
|
|
+ outTipSeq = null;
|
|
|
+ });
|
|
|
+ seq.SetUpdate(true);
|
|
|
+ outTipSeq = seq;
|
|
|
}
|
|
|
}
|