|
|
@@ -55,6 +55,11 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
private bool hasBackAni;
|
|
|
[LabelText("黑伞消失时长")]
|
|
|
public float disappearTime;
|
|
|
+ [LabelText("黑伞位置提示特效")]
|
|
|
+ public GameObject effect;
|
|
|
+ private GameObject effectIns;
|
|
|
+ //提示X坐标
|
|
|
+ public float leftX, rightX;
|
|
|
|
|
|
//是第一次攻击,则无需索敌
|
|
|
private bool isFirst;
|
|
|
@@ -80,7 +85,7 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
ChangeUmbrellaState(UmbrellaState.appear);
|
|
|
}
|
|
|
|
|
|
- private void ChangeUmbrellaState(UmbrellaState us)
|
|
|
+ public void ChangeUmbrellaState(UmbrellaState us)
|
|
|
{
|
|
|
if (umbrellaState == us)
|
|
|
{
|
|
|
@@ -194,8 +199,55 @@ public class BlackUmbrella : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private bool IsTargetVisible(GameObject target)
|
|
|
+ {
|
|
|
+ Camera camera = Camera.main;
|
|
|
+ // 获取物体在视口中的位置(归一化坐标)
|
|
|
+ Vector3 viewportPoint = camera.WorldToViewportPoint(target.transform.position);
|
|
|
+
|
|
|
+ // 检查坐标是否在屏幕范围内(0-1之间)
|
|
|
+ bool inCameraView = viewportPoint.x >= 0 && viewportPoint.x <= 1 &&
|
|
|
+ viewportPoint.y >= 0 && viewportPoint.y <= 1 &&
|
|
|
+ viewportPoint.z > 0; // z>0 表示在相机前方
|
|
|
+
|
|
|
+ return inCameraView;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ShowTip()
|
|
|
+ {
|
|
|
+ if (!effectIns)
|
|
|
+ {
|
|
|
+ effectIns = PoolManager.Instantiate(effect, Camera.main.transform);
|
|
|
+ }
|
|
|
+ if (!IsTargetVisible(gameObject))
|
|
|
+ {
|
|
|
+ if (gameObject.transform.position.x > pc.transform.position.x)
|
|
|
+ {
|
|
|
+ effectIns.transform.localPosition = new Vector3(rightX, 0, 16);
|
|
|
+ Vector3 pos = effectIns.transform.position;
|
|
|
+ pos.y = gameObject.transform.position.y;
|
|
|
+ effectIns.transform.position = pos;
|
|
|
+ effectIns.transform.localEulerAngles = new Vector3(0.8f, 0.1f, 1);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ effectIns.transform.localPosition = new Vector3(leftX, 0, 16);
|
|
|
+ Vector3 pos = effectIns.transform.position;
|
|
|
+ pos.y = gameObject.transform.position.y;
|
|
|
+ effectIns.transform.position = pos;
|
|
|
+ effectIns.transform.localEulerAngles = new Vector3(-0.8f, 0.1f, 1);
|
|
|
+ }
|
|
|
+ effectIns.SetActive(true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ effectIns.SetActive(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void Update()
|
|
|
{
|
|
|
OnUmbrellaState();
|
|
|
+ ShowTip();
|
|
|
}
|
|
|
}
|