summaryrefslogtreecommitdiff
path: root/AlienSurvival/Assets/Test/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'AlienSurvival/Assets/Test/Scripts')
-rw-r--r--AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs29
-rw-r--r--AlienSurvival/Assets/Test/Scripts/TestPeaceMakerGrenade.cs10
2 files changed, 22 insertions, 17 deletions
diff --git a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs b/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
index e427e20..4cc13d1 100644
--- a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
+++ b/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
@@ -5,12 +5,23 @@ using UnityEngine;
using UnityEditor;
#endif
-[ExecuteInEditMode]
+//[ExecuteInEditMode]
public class TestFakeHeight : MonoBehaviour
{
[SerializeField] private Transform m_Shadow;
+ [SerializeField] private Vector3 m_Coord;
- public float height { get { return m_Height; } set { m_Height = value; } }
+
+ public float height {
+ get
+ {
+ return m_Height;
+ }
+ set
+ {
+ m_Height = value;
+ }
+ }
[SerializeField] private float m_Height; // current fake height
public float x
@@ -49,6 +60,12 @@ public class TestFakeHeight : MonoBehaviour
Vector3 pos = new Vector3(x, y, height);
return pos;
}
+ set
+ {
+ height = value.z; // height先设置
+ x = value.x;
+ y = value.y;
+ }
}
public Vector2 positionOnGround
@@ -65,8 +82,6 @@ public class TestFakeHeight : MonoBehaviour
}
}
- private float m_PreHeight;
-
private SpriteRenderer m_SpriteRenderer;
private void OnEnable()
@@ -76,15 +91,13 @@ public class TestFakeHeight : MonoBehaviour
private void Start()
{
- m_PreHeight = 0;
Project();
}
void Project()
{
Vector3 pos = transform.position;
-
- pos.y = pos.y - m_PreHeight + m_Height;
+ pos.y = y + height;
transform.position = pos;
if (m_Shadow != null)
@@ -92,8 +105,6 @@ public class TestFakeHeight : MonoBehaviour
m_Shadow.position = new Vector3(transform.position.x, transform.position.y - m_Height, transform.position.z);
}
- m_PreHeight = m_Height;
-
// 根据y设置sortOrder
m_SpriteRenderer.sortingOrder = (int)(-y * 100);
}
diff --git a/AlienSurvival/Assets/Test/Scripts/TestPeaceMakerGrenade.cs b/AlienSurvival/Assets/Test/Scripts/TestPeaceMakerGrenade.cs
index 109e47b..cd12c1e 100644
--- a/AlienSurvival/Assets/Test/Scripts/TestPeaceMakerGrenade.cs
+++ b/AlienSurvival/Assets/Test/Scripts/TestPeaceMakerGrenade.cs
@@ -15,7 +15,6 @@ public class TestPeaceMakerGrenade : MonoBehaviour
private Vector3 m_Velocity; // x, y, fakeHeight
-
/// <summary>
/// 设置初始参数,都在fake空间下
/// </summary>
@@ -25,10 +24,7 @@ public class TestPeaceMakerGrenade : MonoBehaviour
public void Set(Vector3 initPosition, Vector3 initDirection, float initSpeed)
{
m_Coords = GetComponent<TestFakeHeight>();
-
- m_Coords.x = initPosition.x;
- m_Coords.y = initPosition.y;
- m_Coords.height = initPosition.z;
+ m_Coords.position = initPosition;
m_Velocity = initDirection * initSpeed;
}
@@ -61,9 +57,7 @@ public class TestPeaceMakerGrenade : MonoBehaviour
GameObject exp = Instantiate<GameObject>(m_ExplosionEffect);
TestFakeHeight coord = exp.GetComponent<TestFakeHeight>();
- coord.x = m_Coords.x;
- coord.y = m_Coords.y;
- coord.height = m_Coords.height;
+ coord.position = m_Coords.position;
exp.SetActive(true);
}