Sfoglia il codice sorgente

漂浮英灵修改

SZAND\msx_2 1 anno fa
parent
commit
2ce1d82d94

+ 2 - 2
ActionTowerDefense/Assets/Resources/Prefab/Player.prefab

@@ -831,8 +831,8 @@ MonoBehaviour:
   minHurtKeepTime: 0.2
   hurtKeepTime: 0
   hurtChangeVelocity: 1
-  maxSpeed: 10
-  minSpeed: 2
+  maxTime: 15
+  minTime: 6
   maxHeight: 10
   minHeight: 6
   maxRotateSpeed: 10

+ 61 - 2
ActionTowerDefense/Assets/Resources/Prefab/Spirits_Float.prefab

@@ -197,6 +197,64 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   imgHp: {fileID: 3266580543050502037}
+--- !u!1 &2221043710688135367
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 5032495223408797810}
+  - component: {fileID: 8046884224131155322}
+  - component: {fileID: 3000999671257713975}
+  m_Layer: 7
+  m_Name: EffectCollider
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &5032495223408797810
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2221043710688135367}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 6561999689701501378}
+  m_RootOrder: 7
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!65 &8046884224131155322
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2221043710688135367}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 1
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 10, y: 100, z: 1}
+  m_Center: {x: 0, y: 0, z: 0}
+--- !u!114 &3000999671257713975
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2221043710688135367}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: e4ee37ae96a7315419ecbfe1bb3c43e9, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1 &2234394376273647362
 GameObject:
   m_ObjectHideFlags: 0
@@ -686,6 +744,7 @@ Transform:
   - {fileID: 8482269351142858204}
   - {fileID: 776105162125788029}
   - {fileID: 6220414675483084992}
+  - {fileID: 5032495223408797810}
   m_Father: {fileID: 5769591908339262981}
   m_RootOrder: 1
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1031,8 +1090,8 @@ MonoBehaviour:
   minHurtKeepTime: 0.2
   hurtKeepTime: 0
   hurtChangeVelocity: 1
-  maxSpeed: 10
-  minSpeed: 2
+  maxTime: 15
+  minTime: 6
   maxHeight: 12
   minHeight: 7
   maxRotateSpeed: 10

+ 10 - 8
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -23,8 +23,8 @@ public class MoveCharacter : Character
     public float hurtChangeVelocity = 1;
 
     [Header("新增漂浮效果参数")]
-    public float maxSpeed = 15; //上升最大速度
-    public float minSpeed = 6;  //上升最小速度
+    public float maxTime = 15; //上升最大耗时
+    public float minTime = 6;  //上升最小耗时
     public float maxHeight = 12;    //最大上升高度
     public float minHeight = 7;    //最小上升高度
 
@@ -35,12 +35,14 @@ public class MoveCharacter : Character
 
     private float curTime;      //漂浮已进行时长
     private float height;       //漂浮高度
-    private float floatSpeed;   //漂浮速度
+    private float riseTime;   //上升时间
     private float curHeight;    //当前所在高度
     private float rotateSpeed;  //旋转速度
     private float rotateDir;    //旋转方向
 
     private Vector3 origPos;     //初始位置
+    private float rise = 1;
+    private float down = -1;
     private Vector3 oneClockwise = new Vector3(0, 0, 1);
     private Vector3 oneCounterClockwise = new Vector3(0, 0, -1);
 
@@ -50,15 +52,15 @@ public class MoveCharacter : Character
 
     public void FloatStateOn()
     {
-        maxSpeed = 15; 
-        minSpeed = 2;
+        maxTime = 1.5f; 
+        minTime = 0.1f;
         maxHeight = 9;
         minHeight = 4;
 
         floatTime = 20;     
         ChangeState(CharacterState.Rise);
         floatState = 1;
-        floatSpeed = Random.Range(minSpeed, maxSpeed);
+        riseTime = Random.Range(minTime, maxTime);
         origPos = transform.position;
         curHeight = origPos.y;
         curTime = 0;
@@ -80,9 +82,9 @@ public class MoveCharacter : Character
             RotateSelf();
             curTime += Time.deltaTime;
             aniCollider.Play("Rise", 0, 0);
-            curHeight += floatSpeed * Time.deltaTime;
+            curHeight = Mathf.SmoothDamp(curHeight, height, ref rise, riseTime);
             transform.position = new Vector3(origPos.x, curHeight, origPos.z);
-            if (curHeight >= height)
+            if (curHeight >= height - 0.02f)
             {
                 floatState = 2;
                 ChangeState(CharacterState.Float);

+ 0 - 22
ActionTowerDefense/Assets/Scripts/Spirits/Spirits.cs

@@ -11,36 +11,15 @@ public class Spirits : MonoBehaviour
         Kebab = 2,      //¿¾´®
         Invisible = 3,  //ÒþÉí
     }
-    
-    private GameObject floatSpirit;
 
     public SpiritType currentSpirit;
 
-    private void disappear()
-    {
-        floatSpirit.SetActive(false);
-    }
 
     public void SummonSpirit(SpiritType st)
     {
         switch (st)
         {
             case SpiritType.Float:
-                if (floatSpirit == null)
-                {
-                    floatSpirit = GameObject.Find("Capsule").gameObject;
-                }
-                if (floatSpirit.activeSelf)
-                {
-                    floatSpirit.SetActive(false);
-                }
-                else
-                {
-                    float z = floatSpirit.transform.position.z;
-                    floatSpirit.transform.position = new Vector3(transform.position.x, transform.position.y, z);
-                    floatSpirit.SetActive(true);
-                    Invoke("disappear", 0.05f);
-                }
                 break;
             case SpiritType.Dash:
                 break;
@@ -49,7 +28,6 @@ public class Spirits : MonoBehaviour
             case SpiritType.Kebab:
                 break;
         }
-
     }
 
     

+ 2 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Float.cs

@@ -4,6 +4,8 @@ using UnityEngine;
 
 public class Spirits_Float : MonoBehaviour
 {
+    private bool once = true;  //½öÒ»´Î³ö³¡Ð§¹û
+
     private void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.layer == 8)