Explorar o código

敌方隐身英灵招魂

LAPTOP-OM1V99U2\永远de小亡灵 hai 1 ano
pai
achega
239944646a

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

@@ -298,8 +298,8 @@ MonoBehaviour:
   minMoveSpeed: 15
   dropSoul: 3
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 30
-  dropSoulAngle: 0
+  soulStartSpeed: 1
+  dropSoulAngle: 90
   noOnSearchState: 0
   isFindingPlayer: 0
   isFindPlayer: 0

+ 18 - 3
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Float.prefab

@@ -1096,7 +1096,22 @@ MonoBehaviour:
   minMoveSpeed: 8
   dropSoul: 3
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 100
+  soulStartSpeed: 1
   dropSoulAngle: 90
-  isSpiritsAttack: 0
-  isDash: 0
+  noOnSearchState: 0
+  isFindingPlayer: 0
+  isFindPlayer: 0
+  hateDistance: 0
+  distance: 0
+  rushEndPos: {x: 0, y: 0, z: 0}
+  aimEffect: {fileID: 0}
+  aimDistance: 0
+  rushTime: 0
+  rushSpeed: 0
+  time: 0
+  readyCD: 0
+  dashEffect: {fileID: 0}
+  targetDir: {x: 0, y: 0, z: 0}
+  haveDownRush: 0
+  downRushTime: 0
+  finishRushTime: 0

+ 1 - 1
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Invisible.prefab

@@ -299,7 +299,7 @@ MonoBehaviour:
   minMoveSpeed: 8
   dropSoul: 3
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 100
+  soulStartSpeed: 1
   dropSoulAngle: 90
   noOnSearchState: 1
   isFindingPlayer: 0

+ 26 - 1
ActionTowerDefense/Assets/Resources/Prefab/Enemy_Arrow.prefab

@@ -971,6 +971,8 @@ MonoBehaviour:
   attackTime: 0
   totalAttack1Time: 1.8
   totalAttack2Time: 1.3
+  isNonAttack: 0
+  hptp: 0
   isDie: 0
   totalHp: 100
   hp: 0
@@ -1016,6 +1018,9 @@ MonoBehaviour:
   linked: 0
   joint: {fileID: 0}
   rope: {fileID: 0}
+  hasHpUp: 0
+  beLarger: 0
+  canMove: 1
   foot: {fileID: 8639832132450015562}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
@@ -1036,6 +1041,7 @@ MonoBehaviour:
   maxRotateSpeed: 20
   minRotateSpeed: 5
   floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: b634d447d9a02a14abc964532eedfc35, type: 2}
   id: 0
@@ -1043,13 +1049,32 @@ MonoBehaviour:
   searchState: 0
   attackDistance: 10
   canFly: 1
+  flyHeight: 0
+  flyUpSpeed: 10
   attackRatio: 0
   maxMoveSpeed: 12
   minMoveSpeed: 8
   dropSoul: 3
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 100
+  soulStartSpeed: 1
   dropSoulAngle: 90
+  noOnSearchState: 0
+  isFindingPlayer: 0
+  isFindPlayer: 0
+  hateDistance: 0
+  distance: 0
+  rushEndPos: {x: 0, y: 0, z: 0}
+  aimEffect: {fileID: 0}
+  aimDistance: 0
+  rushTime: 0
+  rushSpeed: 0
+  time: 0
+  readyCD: 0
+  dashEffect: {fileID: 0}
+  targetDir: {x: 0, y: 0, z: 0}
+  haveDownRush: 0
+  downRushTime: 0
+  finishRushTime: 0
 --- !u!54 &8639832132491289349
 Rigidbody:
   m_ObjectHideFlags: 0

+ 29 - 2
ActionTowerDefense/Assets/Resources/Prefab/Enemy_Giant.prefab

@@ -97,6 +97,8 @@ MonoBehaviour:
   force: {x: 0, y: 0, z: 0}
   changeHurt: 0
   repelValue: 0
+  spiritsAttackEffect: {fileID: 0}
+  offsetY: 1
 --- !u!1 &2460330936527559963
 GameObject:
   m_ObjectHideFlags: 0
@@ -436,6 +438,8 @@ MonoBehaviour:
   attackTime: 0
   totalAttack1Time: 3.6
   totalAttack2Time: 4
+  isNonAttack: 0
+  hptp: 0
   isDie: 0
   totalHp: 100
   hp: 0
@@ -469,6 +473,9 @@ MonoBehaviour:
   linked: 0
   joint: {fileID: 0}
   rope: {fileID: 0}
+  hasHpUp: 0
+  beLarger: 0
+  canMove: 1
   foot: {fileID: 5440846222604650418}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
@@ -489,6 +496,7 @@ MonoBehaviour:
   maxRotateSpeed: 20
   minRotateSpeed: 5
   floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: a30e0c3d2b8bf4e43a76fc2d5b3884cd, type: 2}
   id: 0
@@ -496,13 +504,32 @@ MonoBehaviour:
   searchState: 0
   attackDistance: 3
   canFly: 0
+  flyHeight: 0
+  flyUpSpeed: 10
   attackRatio: 0
   maxMoveSpeed: 2
   minMoveSpeed: 1
   dropSoul: 6
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 50
-  dropSoulAngle: 1
+  soulStartSpeed: 1
+  dropSoulAngle: 90
+  noOnSearchState: 0
+  isFindingPlayer: 0
+  isFindPlayer: 0
+  hateDistance: 0
+  distance: 0
+  rushEndPos: {x: 0, y: 0, z: 0}
+  aimEffect: {fileID: 0}
+  aimDistance: 0
+  rushTime: 0
+  rushSpeed: 0
+  time: 0
+  readyCD: 0
+  dashEffect: {fileID: 0}
+  targetDir: {x: 0, y: 0, z: 0}
+  haveDownRush: 0
+  downRushTime: 0
+  finishRushTime: 0
 --- !u!54 &5440846222648032765
 Rigidbody:
   m_ObjectHideFlags: 0

+ 29 - 2
ActionTowerDefense/Assets/Resources/Prefab/Enemy_Sword.prefab

@@ -171,6 +171,8 @@ MonoBehaviour:
   force: {x: 0, y: 0, z: 0}
   changeHurt: 0
   repelValue: 0
+  spiritsAttackEffect: {fileID: 0}
+  offsetY: 1
 --- !u!1 &2437299196472462361
 GameObject:
   m_ObjectHideFlags: 0
@@ -231,6 +233,8 @@ MonoBehaviour:
   attackTime: 0
   totalAttack1Time: 1.25
   totalAttack2Time: 1.8
+  isNonAttack: 0
+  hptp: 0
   isDie: 0
   totalHp: 100
   hp: 0
@@ -264,6 +268,9 @@ MonoBehaviour:
   linked: 0
   joint: {fileID: 0}
   rope: {fileID: 0}
+  hasHpUp: 0
+  beLarger: 0
+  canMove: 1
   foot: {fileID: 2437299196663985756}
   extraRiseGravity: -28.8
   extraFallGravity: -14.4
@@ -284,6 +291,7 @@ MonoBehaviour:
   maxRotateSpeed: 20
   minRotateSpeed: 5
   floatTime: 20
+  floatState: 0
   outlineMats:
   - {fileID: 2100000, guid: 7d50f910288e95b4285a5fb549c94fe6, type: 2}
   id: 0
@@ -291,13 +299,32 @@ MonoBehaviour:
   searchState: 0
   attackDistance: 1.5
   canFly: 0
+  flyHeight: 0
+  flyUpSpeed: 10
   attackRatio: 0
   maxMoveSpeed: 6
   minMoveSpeed: 5
   dropSoul: 3
   soulPrefab: {fileID: 1723151111827507807, guid: e2b65aa482f2f1447a4074208d72b778, type: 3}
-  soulStartSpeed: 30
-  dropSoulAngle: 0
+  soulStartSpeed: 1
+  dropSoulAngle: 90
+  noOnSearchState: 0
+  isFindingPlayer: 0
+  isFindPlayer: 0
+  hateDistance: 0
+  distance: 0
+  rushEndPos: {x: 0, y: 0, z: 0}
+  aimEffect: {fileID: 0}
+  aimDistance: 0
+  rushTime: 0
+  rushSpeed: 0
+  time: 0
+  readyCD: 0
+  dashEffect: {fileID: 0}
+  targetDir: {x: 0, y: 0, z: 0}
+  haveDownRush: 0
+  downRushTime: 0
+  finishRushTime: 0
 --- !u!54 &2437299196472462355
 Rigidbody:
   m_ObjectHideFlags: 0

+ 7 - 6
ActionTowerDefense/Assets/Resources/Prefab/soul.prefab

@@ -4861,7 +4861,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 1
   m_RenderMode: 0
   m_MeshDistribution: 0
@@ -9749,7 +9749,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 2
   m_RenderMode: 0
   m_MeshDistribution: 0
@@ -9837,6 +9837,7 @@ MonoBehaviour:
   tweenPos: {fileID: -7697323034879839750}
   flySpeed: 20
   upSpeed: 1
+  altitude: 30
 --- !u!54 &1723151111827507801
 Rigidbody:
   m_ObjectHideFlags: 0
@@ -14784,7 +14785,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 1
   m_RenderMode: 1
   m_MeshDistribution: 0
@@ -19672,7 +19673,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 0
   m_RenderMode: 0
   m_MeshDistribution: 0
@@ -24560,7 +24561,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 2
   m_RenderMode: 0
   m_MeshDistribution: 0
@@ -29448,7 +29449,7 @@ ParticleSystemRenderer:
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
   m_SortingLayerID: 21624701
-  m_SortingLayer: 0
+  m_SortingLayer: 6
   m_SortingOrder: 1
   m_RenderMode: 0
   m_MeshDistribution: 0

+ 18 - 3
ActionTowerDefense/Assets/Scripts/Soul.cs

@@ -13,7 +13,12 @@ public class Soul : MonoBehaviour
     public uTweenPositionTarget tweenPos;
     public float flySpeed = 10f;
     public float upSpeed = 1;
+    public float altitude;
 
+    private void Awake()
+    {
+        SoulInMap.souls.Add(this);
+    }
     public void Burst(Vector3 velocity)
     {
         rb.isKinematic = false;
@@ -32,6 +37,7 @@ public class Soul : MonoBehaviour
         tweenPos.PlayForward();
         await Task.Delay((int)(tweenPos.duration * 1000));
         BeGet(id);
+        SoulInMap.souls.Remove(this);
         gameObject.SetActive(false);
     }
 
@@ -42,8 +48,17 @@ public class Soul : MonoBehaviour
 
     private void FixedUpdate()
     {
-        Vector3 velocity = rb.velocity;
-        velocity.y = upSpeed;
-        rb.velocity = velocity;
+        
+        if(transform.position.y>= altitude)
+        {
+            rb.velocity = Vector3.zero;
+        }
+        else
+        {
+            Vector3 velocity = rb.velocity;
+            velocity.y = upSpeed;
+            rb.velocity = velocity;
+
+        }
     }
 }

+ 8 - 0
ActionTowerDefense/Assets/Scripts/SoulInMap.cs

@@ -0,0 +1,8 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class SoulInMap : MonoBehaviour
+{
+    static public List<Soul> souls = new List<Soul>();
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/SoulInMap.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: db8480d7ee241654b99f9548640fa30b
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 4 - 0
ActionTowerDefense/Assets/Scripts/Spirits/DashEffect.cs

@@ -81,6 +81,10 @@ public class DashEffect : MonoBehaviour
     }
     public void DashAttack(Character character)
     {
+        if(character.state == CharacterState.Die)
+        {
+            return;
+        }
         character.BeHit(attackInfo.damage,attackInfo.force * attackInfo.attackDir * offset, 
             attackInfo.changeHurt,attackInfo.repelValue);
         GameObject effect = Instantiate(rushEffect);

+ 95 - 14
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Invisible.cs

@@ -6,6 +6,7 @@ public enum InvisibleState
     None = -1,
     Normal = 0, //Õý³£×´Ì¬
     Hurt = 1,   //±»´ò״̬
+    FindSoul = 2,   //ÕÒ»ê״̬
 }
 public class ESpirits_Invisible : MonoBehaviour
 {
@@ -33,6 +34,8 @@ public class ESpirits_Invisible : MonoBehaviour
     public Enemy enemy;
     [HideInInspector]
     public float posx;
+    [HideInInspector]
+    public Soul targetSoul;
     private void Awake()
     {
         hp = enemy.hp;
@@ -40,6 +43,7 @@ public class ESpirits_Invisible : MonoBehaviour
     private void Update()
     {
         OnState();
+        //print(SoulInMap.souls.Count);
     }
     void OnState()
     {
@@ -47,15 +51,17 @@ public class ESpirits_Invisible : MonoBehaviour
         switch (state)
         {
             case InvisibleState.Normal:
+                if (SoulInMap.souls.Count != 0)
+                {
+                    ChangeState(InvisibleState.FindSoul);
+                }
                 if (hp != enemy.hp)
                 {
-                    posx = transform.position.x;
-                    state = InvisibleState.Hurt;
+                    ChangeState(InvisibleState.Hurt);
                 }
-                posx = Mathf.Min(PlayersInput.instance[0].transform.position.x,
-                    PlayersInput.instance[1].transform.position.x);
-                
-
+                //posx = Mathf.Min(PlayersInput.instance[0].transform.position.x,
+                //    PlayersInput.instance[1].transform.position.x);
+                posx = PlayersInput.instance[nowPlayer].transform.position.x;
                 targetPos = new Vector3(posx + offsetX,altitude + offsetY, 0);
                 Goto(targetPos,moveSpeed);
                 if (Vector3.Distance(targetPos, transform.position) < 1)
@@ -72,26 +78,101 @@ public class ESpirits_Invisible : MonoBehaviour
                 }
                 break;
             case InvisibleState.Hurt:
-                targetPos = new Vector3(posx + offsetX - back,
-                    altitude + offsetY, 0);
-                Goto(targetPos, moveSpeed);
+                if (SoulInMap.souls.Count != 0)
+                {
+                    ChangeState(InvisibleState.FindSoul);
+                }
                 if (Vector3.Distance(targetPos, transform.position) < 1)
                 {
-
-                    offsetY = Random.Range(-randomRageY, randomRageY);
-                    offsetX = Random.Range(-randomRageX, randomRageX);
-                    hp = enemy.hp;
-                    state = InvisibleState.Normal;
+                    ChangeState(InvisibleState.Normal);
                 }
+                
+                Goto(targetPos, moveSpeed);
+                break;
+            case InvisibleState.FindSoul:
+                if (targetSoul.gameObject.activeSelf)
+                {
+                    if(Vector3.Distance(transform.position, targetSoul.transform.position) <= 1)
+                    {
+                        SoulInMap.souls.Remove(targetSoul);
+                        //targetSoul.gameObject.SetActive(false);
+                        FindSoul();
+                    }
+                }
+                else
+                {
+                    FindSoul();
+                }
+                if(targetSoul == null)
+                {
+                    ChangeState(InvisibleState.Normal);
+                    break;
+                }
+                targetPos = targetSoul.transform.position;
+                Goto(targetPos, upMoveSpeed);
+                
                 break;
             default:
                 break;
         }
 
     }
+    public void ChangeState(InvisibleState newState)
+    {
+        switch (state)
+        {
+            case InvisibleState.Normal:
+                break;
+            case InvisibleState.Hurt:
+                break;
+            case InvisibleState.FindSoul:
+                break;
+            default:
+                break;
+        }
+        switch (newState)
+        {
+            case InvisibleState.Normal:
+                hp = enemy.hp;
+                offsetY = Random.Range(-randomRageY, randomRageY);
+                offsetX = Random.Range(-randomRageX, randomRageX);
+                break;
+            case InvisibleState.Hurt:
+                targetPos = new Vector3(posx + offsetX - back, altitude + offsetY, 0);
+                posx = transform.position.x;
+                break;
+            case InvisibleState.FindSoul:
+                FindSoul();
+                break;
+            default:
+                break;
+        }
+        state = newState;
+    }
     public void Goto(Vector3 pos,float speed)
     {
         Vector3 target = (pos - transform.position).normalized;
         rb.velocity = target * speed;
     }
+    public void FindSoul()
+    {
+        List<Soul> souls = SoulInMap.souls;
+        if(souls.Count == 0)
+        {
+            targetSoul = null;
+            return;
+        }
+        float minDistance = Vector3.Distance(souls[0].transform.position, transform.position);
+        int targetSoulId = 0;
+        for(int i = 1; i < souls.Count; i++)
+        {
+            float distance = Vector3.Distance(souls[i].transform.position, transform.position);
+            if (distance < minDistance)
+            {
+                minDistance = distance;
+                targetSoulId = i;
+            }
+        }
+        targetSoul = souls[targetSoulId];
+    }
 }