|
|
@@ -6,17 +6,56 @@ using DG.Tweening;
|
|
|
public class ArrowCamera : MonoBehaviour
|
|
|
{
|
|
|
public Arrow arrow;
|
|
|
+ ArrowCameraTemplate arrowCameraTemplate;
|
|
|
|
|
|
void Start()
|
|
|
{
|
|
|
-
|
|
|
+ if (Random.value < 0.5) arrowCameraTemplate = new ArrowCameraTemplate1(this);
|
|
|
+ else arrowCameraTemplate = new ArrowCameraTemplate2(this);
|
|
|
+ // arrowCameraTemplate = new ArrowCameraTemplate2(this);
|
|
|
}
|
|
|
|
|
|
void FixedUpdate()
|
|
|
{
|
|
|
- updateMoveCamera();
|
|
|
+ arrowCameraTemplate.Update();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class ArrowCameraTemplate2 : ArrowCameraTemplate
|
|
|
+{
|
|
|
+ public ArrowCameraTemplate2(ArrowCamera arrowCamera) : base(arrowCamera) {
|
|
|
+ this.arrowCamera.transform.parent = null;
|
|
|
+ arrowCamera.transform.localPosition = new Vector3(9.94f, 2.24f, 1.74f);
|
|
|
+ arrowCamera.transform.localEulerAngles = new Vector3(0, -52.32f, 0);
|
|
|
}
|
|
|
|
|
|
+ bool isHit = false;
|
|
|
+ public override void Update() {
|
|
|
+ if (!isHit) {
|
|
|
+ isHit = arrowCamera.arrow.isHit;
|
|
|
+ if (isHit) {
|
|
|
+ this.arrowCamera.transform.SetParent(this.arrowCamera.arrow.transform);
|
|
|
+ arrowCamera.transform.localPosition = new Vector3(-0.6f, 0.1f, -0.8f);
|
|
|
+ arrowCamera.transform.LookAt(this.arrowCamera.arrow.transform.Find("Head"));
|
|
|
+ Sequence seq = DOTween.Sequence();
|
|
|
+ seq.PrependInterval(1f);
|
|
|
+ seq.AppendCallback(delegate() {
|
|
|
+ this.arrowCamera.arrow.nextShoot();
|
|
|
+ this.arrowCamera.arrow.enabled = false;
|
|
|
+ GameObject.Destroy(this.arrowCamera.gameObject);
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!arrowCamera.arrow) {
|
|
|
+ GameObject.Destroy(this.arrowCamera.gameObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+class ArrowCameraTemplate1 : ArrowCameraTemplate
|
|
|
+{
|
|
|
+ public ArrowCameraTemplate1(ArrowCamera arrowCamera) : base(arrowCamera) {}
|
|
|
+
|
|
|
/**相机移动 */
|
|
|
private bool cameraMoveFinish = false;
|
|
|
//相机的位置xyz变化 【每秒变化量,最小值,最大值】
|
|
|
@@ -31,13 +70,13 @@ public class ArrowCamera : MonoBehaviour
|
|
|
30, -1 - Mathf.Clamp(Arrow.speed / 20 * 6, 0, 6), -0.8f
|
|
|
};
|
|
|
|
|
|
- private void updateMoveCamera() {
|
|
|
+ public override void Update() {
|
|
|
if (cameraMoveFinish) {
|
|
|
return;
|
|
|
}
|
|
|
- Transform cameraT = this.transform;
|
|
|
+ Transform cameraT = this.arrowCamera.transform;
|
|
|
Vector3 cameraPosition = cameraT.localPosition;
|
|
|
- if (arrow.isHit) {
|
|
|
+ if (this.arrowCamera.arrow.isHit) {
|
|
|
cameraPosition.x = Mathf.Clamp(cameraPosition.x + this.cpcs[9] * Time.deltaTime, this.cpcs[10], this.cpcs[11]);
|
|
|
cameraPosition.y = Mathf.Clamp(cameraPosition.y + this.cpcs[12] * Time.deltaTime, this.cpcs[13], this.cpcs[14]);
|
|
|
cameraPosition.z = Mathf.Clamp(cameraPosition.z + this.cpcs[15] * Time.deltaTime, this.cpcs[16], this.cpcs[17]);
|
|
|
@@ -51,9 +90,9 @@ public class ArrowCamera : MonoBehaviour
|
|
|
Sequence seq = DOTween.Sequence();
|
|
|
seq.AppendInterval(1.0f);
|
|
|
seq.AppendCallback(delegate() {
|
|
|
- arrow.nextShoot();
|
|
|
- Destroy(cameraT.gameObject);
|
|
|
- this.enabled = false;
|
|
|
+ this.arrowCamera.arrow.nextShoot();
|
|
|
+ this.arrowCamera.arrow.enabled = false;
|
|
|
+ GameObject.Destroy(this.arrowCamera.gameObject);
|
|
|
});
|
|
|
}
|
|
|
} else {
|
|
|
@@ -62,8 +101,16 @@ public class ArrowCamera : MonoBehaviour
|
|
|
cameraPosition.z = Mathf.Clamp(cameraPosition.z + this.cpcs[6] * Time.deltaTime, this.cpcs[7], this.cpcs[8]);
|
|
|
}
|
|
|
cameraT.localPosition = cameraPosition;
|
|
|
- cameraT.LookAt(arrow.transform.Find("Head"));
|
|
|
+ cameraT.LookAt(this.arrowCamera.arrow.transform.Find("Head"));
|
|
|
+ }
|
|
|
+}
|
|
|
+class ArrowCameraTemplate {
|
|
|
+ public ArrowCamera arrowCamera;
|
|
|
+ public ArrowCameraTemplate(ArrowCamera arrowCamera)
|
|
|
+ {
|
|
|
+ this.arrowCamera = arrowCamera;
|
|
|
}
|
|
|
+ public virtual void Update() {}
|
|
|
}
|
|
|
|
|
|
// public class ArrowCamera : MonoBehaviour
|