Browse Source

敌方法师可选定玩家1进行攻击

SZAND\msx_2 1 year ago
parent
commit
5bafd39c97

+ 6 - 4
ActionTowerDefense/Assets/Resources/Prefab/ESpirits_Float.prefab

@@ -280,8 +280,8 @@ MeshRenderer:
   m_AutoUVMaxDistance: 0.5
   m_AutoUVMaxAngle: 89
   m_LightmapParameters: {fileID: 0}
-  m_SortingLayerID: -690842069
-  m_SortingLayer: 4
+  m_SortingLayerID: 341237651
+  m_SortingLayer: 3
   m_SortingOrder: 0
   m_AdditionalVertexStreams: {fileID: 0}
 --- !u!95 &5978259926173120695
@@ -317,7 +317,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   skeletonDataAsset: {fileID: 11400000, guid: d7932227b52429643b6e52fed924a907, type: 2}
-  initialSkinName: summon
+  initialSkinName: enermy
   fixPrefabOverrideViaMeshFilter: 2
   initialFlipX: 0
   initialFlipY: 0
@@ -1079,7 +1079,9 @@ MonoBehaviour:
   minRotateSpeed: 5
   floatTime: 20
   outlineMats:
-  - {fileID: 0}
+  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
+  - {fileID: 2100000, guid: 0d24ea357a09df448b788aed95b96541, type: 2}
+  - {fileID: 2100000, guid: b89f4b5b01e92784ab27611e2b014a10, type: 2}
   id: 0
   jumpSpeed: 10
   searchState: 0

+ 1 - 14
ActionTowerDefense/Assets/Resources/Prefab/FX/FloatEffectRange.prefab

@@ -10,7 +10,6 @@ GameObject:
   m_Component:
   - component: {fileID: 6831563428749086452}
   - component: {fileID: 8409860499344876540}
-  - component: {fileID: 3655836912165546929}
   - component: {fileID: 8741738695297186910}
   m_Layer: 0
   m_Name: FloatEffectRange
@@ -50,19 +49,6 @@ BoxCollider:
   serializedVersion: 2
   m_Size: {x: 22, y: 100, z: 1}
   m_Center: {x: 0, y: 0, z: 0}
---- !u!114 &3655836912165546929
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 417478504669294145}
-  m_Enabled: 0
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: e4ee37ae96a7315419ecbfe1bb3c43e9, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  height: 7
 --- !u!114 &8741738695297186910
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -75,6 +61,7 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: 0a7f6757c5f16cf47bf010e81452e6b7, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  isEnemy: 0
 --- !u!1 &746774320722880007
 GameObject:
   m_ObjectHideFlags: 0

+ 44 - 31
ActionTowerDefense/Assets/Resources/Prefab/FX/FloatLockEffect.prefab

@@ -1,6 +1,6 @@
 %YAML 1.1
 %TAG !u! tag:unity3d.com,2011:
---- !u!1 &7278278633902667471
+--- !u!1 &3419775066332298335
 GameObject:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
@@ -8,51 +8,61 @@ GameObject:
   m_PrefabAsset: {fileID: 0}
   serializedVersion: 6
   m_Component:
-  - component: {fileID: 7570041883238409514}
-  - component: {fileID: 4699018727746232645}
+  - component: {fileID: 4149265334792540602}
+  - component: {fileID: 1408921898561401514}
+  - component: {fileID: 1168217818856750935}
+  - component: {fileID: 5310275093011257521}
   m_Layer: 0
-  m_Name: Circle
+  m_Name: Sphere
   m_TagString: Untagged
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
   m_IsActive: 1
---- !u!4 &7570041883238409514
+--- !u!4 &4149265334792540602
 Transform:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 7278278633902667471}
-  m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
+  m_GameObject: {fileID: 3419775066332298335}
+  m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
   m_LocalPosition: {x: 0, y: 0, z: 0}
   m_LocalScale: {x: 10, y: 10, z: 10}
   m_ConstrainProportionsScale: 1
   m_Children: []
   m_Father: {fileID: 1824078659768498534}
   m_RootOrder: 0
-  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!212 &4699018727746232645
-SpriteRenderer:
+  m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
+--- !u!33 &1408921898561401514
+MeshFilter:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3419775066332298335}
+  m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
+--- !u!23 &1168217818856750935
+MeshRenderer:
   m_ObjectHideFlags: 0
   m_CorrespondingSourceObject: {fileID: 0}
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 7278278633902667471}
+  m_GameObject: {fileID: 3419775066332298335}
   m_Enabled: 1
-  m_CastShadows: 0
-  m_ReceiveShadows: 0
+  m_CastShadows: 1
+  m_ReceiveShadows: 1
   m_DynamicOccludee: 1
   m_StaticShadowCaster: 0
   m_MotionVectors: 1
   m_LightProbeUsage: 1
   m_ReflectionProbeUsage: 1
-  m_RayTracingMode: 0
+  m_RayTracingMode: 2
   m_RayTraceProcedural: 0
   m_RenderingLayerMask: 1
   m_RendererPriority: 0
   m_Materials:
-  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 2100000, guid: 774d3eac0093d1049a171c7ea1aca258, type: 2}
   m_StaticBatchInfo:
     firstSubMesh: 0
     subMeshCount: 0
@@ -65,7 +75,7 @@ SpriteRenderer:
   m_IgnoreNormalsForChartDetection: 0
   m_ImportantGI: 0
   m_StitchLightmapSeams: 1
-  m_SelectedEditorRenderState: 0
+  m_SelectedEditorRenderState: 3
   m_MinimumChartSize: 4
   m_AutoUVMaxDistance: 0.5
   m_AutoUVMaxAngle: 89
@@ -73,17 +83,20 @@ SpriteRenderer:
   m_SortingLayerID: 0
   m_SortingLayer: 0
   m_SortingOrder: 0
-  m_Sprite: {fileID: -2413806693520163455, guid: a86470a33a6bf42c4b3595704624658b, type: 3}
-  m_Color: {r: 1, g: 1, b: 1, a: 0.27058825}
-  m_FlipX: 0
-  m_FlipY: 0
-  m_DrawMode: 0
-  m_Size: {x: 1, y: 1}
-  m_AdaptiveModeThreshold: 0.5
-  m_SpriteTileMode: 0
-  m_WasSpriteAssigned: 1
-  m_MaskInteraction: 0
-  m_SpriteSortPoint: 0
+  m_AdditionalVertexStreams: {fileID: 0}
+--- !u!135 &5310275093011257521
+SphereCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3419775066332298335}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 0
+  m_Enabled: 0
+  serializedVersion: 2
+  m_Radius: 0.5
+  m_Center: {x: 0, y: 0, z: 0}
 --- !u!1 &7959709114612421421
 GameObject:
   m_ObjectHideFlags: 0
@@ -99,7 +112,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 0
+  m_IsActive: 1
 --- !u!4 &1824078659768498534
 Transform:
   m_ObjectHideFlags: 0
@@ -109,10 +122,10 @@ Transform:
   m_GameObject: {fileID: 7959709114612421421}
   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_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
+  m_ConstrainProportionsScale: 1
   m_Children:
-  - {fileID: 7570041883238409514}
+  - {fileID: 4149265334792540602}
   m_Father: {fileID: 0}
   m_RootOrder: 0
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

+ 2 - 2
ActionTowerDefense/Assets/Resources/Spine/spirits_float/Spirits_Float_Material-Additive.mat

@@ -37,7 +37,7 @@ Material:
     - _OutlineOpaqueAlpha: 1
     - _OutlineReferenceTexWidth: 1024
     - _OutlineSmoothness: 1
-    - _OutlineWidth: 3
+    - _OutlineWidth: 8
     - _StencilComp: 8
     - _StencilRef: 1
     - _StraightAlphaInput: 0
@@ -46,5 +46,5 @@ Material:
     m_Colors:
     - <noninit>: {r: 0, g: 2.018574, b: 1e-45, a: 0.000007110106}
     - _Color: {r: 1, g: 1, b: 1, a: 1}
-    - _OutlineColor: {r: 1, g: 1, b: 0, a: 1}
+    - _OutlineColor: {r: 0, g: 1, b: 1, a: 1}
   m_BuildTextureStacks: []

+ 50 - 0
ActionTowerDefense/Assets/Resources/Spine/spirits_float/Spirits_Float_Material-Additive_Outline.mat

@@ -0,0 +1,50 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+  serializedVersion: 8
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: Spirits_Float_Material-Additive_Outline
+  m_Shader: {fileID: 4800000, guid: 0299ffae826705448b6c80ccc6a53b75, type: 3}
+  m_ValidKeywords:
+  - _USE8NEIGHBOURHOOD_ON
+  m_InvalidKeywords: []
+  m_LightmapFlags: 4
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: -1
+  stringTagMap: {}
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - <noninit>:
+        m_Texture: {fileID: 0}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    - _MainTex:
+        m_Texture: {fileID: 2800000, guid: 4971322ce8b44f446ae52d6d43704eb8, type: 3}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Ints: []
+    m_Floats:
+    - <noninit>: 0
+    - _Cutoff: 0.1
+    - _OutlineMipLevel: 0
+    - _OutlineOpaqueAlpha: 1
+    - _OutlineReferenceTexWidth: 1024
+    - _OutlineSmoothness: 1
+    - _OutlineWidth: 8
+    - _StencilComp: 8
+    - _StencilRef: 1
+    - _StraightAlphaInput: 0
+    - _ThresholdEnd: 0.25
+    - _Use8Neighbourhood: 1
+    m_Colors:
+    - <noninit>: {r: 0, g: 2.018574, b: 1e-45, a: 0.000007110106}
+    - _Color: {r: 1, g: 1, b: 1, a: 1}
+    - _OutlineColor: {r: 0, g: 1, b: 1, a: 1}
+  m_BuildTextureStacks: []

+ 8 - 0
ActionTowerDefense/Assets/Resources/Spine/spirits_float/Spirits_Float_Material-Additive_Outline.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 0d24ea357a09df448b788aed95b96541
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 2100000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 43 - 0
ActionTowerDefense/Assets/Resources/Spine/spirits_float/Spirits_Float_Material_Outline.mat

@@ -0,0 +1,43 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+  serializedVersion: 8
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_Name: Spirits_Float_Material_Outline
+  m_Shader: {fileID: 4800000, guid: 28b5cf4804845fe4b868531fd0bb81d5, type: 3}
+  m_ValidKeywords:
+  - _USE8NEIGHBOURHOOD_ON
+  m_InvalidKeywords: []
+  m_LightmapFlags: 4
+  m_EnableInstancingVariants: 0
+  m_DoubleSidedGI: 0
+  m_CustomRenderQueue: -1
+  stringTagMap: {}
+  disabledShaderPasses: []
+  m_SavedProperties:
+    serializedVersion: 3
+    m_TexEnvs:
+    - _MainTex:
+        m_Texture: {fileID: 2800000, guid: 4971322ce8b44f446ae52d6d43704eb8, type: 3}
+        m_Scale: {x: 1, y: 1}
+        m_Offset: {x: 0, y: 0}
+    m_Ints: []
+    m_Floats:
+    - _Cutoff: 0.1
+    - _OutlineMipLevel: 0
+    - _OutlineOpaqueAlpha: 1
+    - _OutlineReferenceTexWidth: 1024
+    - _OutlineSmoothness: 1
+    - _OutlineWidth: 8
+    - _StencilComp: 8
+    - _StencilRef: 1
+    - _StraightAlphaInput: 0
+    - _ThresholdEnd: 0.25
+    - _Use8Neighbourhood: 1
+    m_Colors:
+    - _OutlineColor: {r: 0, g: 1, b: 0.97059774, a: 1}
+  m_BuildTextureStacks: []

+ 8 - 0
ActionTowerDefense/Assets/Resources/Spine/spirits_float/Spirits_Float_Material_Outline.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b89f4b5b01e92784ab27611e2b014a10
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 2100000
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 76 - 10
ActionTowerDefense/Assets/Scripts/Spirits/ESpirits_Float.cs

@@ -14,27 +14,36 @@ public class ESpirits_Float : MonoBehaviour
     [Header("漂浮锁定玩家")]
     public float intervalTime = 10f;  //漂浮间隔时间
     private Vector3 attackPos;        //漂浮中心
-    public float lockTime = 3;        //跟随玩家时间
-    public float waitTime = 1.5f;     //锁定等待时间
-    public float lastTime = 10f;      //漂浮持续时间
-    public GameObject fe;            //漂浮脚本
+    public float followTime = 3;        //跟随玩家时间
+    public float lockTime = 1.5f;     //锁定等待时间
+    //public float attackTime = 10f;      //漂浮持续时间
+    public GameObject fe;             //漂浮脚本
     public GameObject lockEffect;     //锁定特效
     private GameObject curFe;
     private GameObject curLock;
+    private float pastTime;           //已经经过的时间
 
     private GameObject player1;
     private GameObject player2;
 
     private GameObject target;
+    private bool isDoing = false;
+    private bool isFollow = false;
+    private bool isLock = false;
+    private bool isAttack = false;
+
+    private Enemy ene;
 
     private void Awake()
     {
-        curFe = Instantiate(fe, transform.position, new Quaternion(0, 0, 0, 0), transform);
+        ene = GetComponent<Enemy>();
+        curLock = Instantiate(lockEffect, new Vector3(0, -50, 0), new Quaternion(0, 0, 0, 0), null);
+        curFe = Instantiate(fe, curLock.transform.position, new Quaternion(0, 0, 0, 0), null);
         curFe.GetComponent<FloatEffect>().isEnemy = true;
-        curLock = Instantiate(lockEffect, new Vector3(0, -50, 0), new Quaternion(0, 0, 0, 0), transform);
-        lockEffect.SetActive(false);
+        curFe.SetActive(false);
+        curLock.SetActive(false);
         player1 = PlayersInput.instance[0].gameObject;
-        player2 = PlayersInput.instance[1].gameObject;
+        //player2 = PlayersInput.instance[1].gameObject;
     }
 
     private void Start()
@@ -43,6 +52,12 @@ public class ESpirits_Float : MonoBehaviour
         curHeight = origPos.y;
     }
 
+    private void OnDisable()
+    {
+        curFe.SetActive(false);
+        curLock.SetActive(false);
+    }
+
     private void MoveToHeight()
     {
         curHeight = Mathf.SmoothDamp(curHeight, height, ref speed, 0.02f);
@@ -51,6 +66,7 @@ public class ESpirits_Float : MonoBehaviour
 
     private void ChoosePlayer()
     {
+        /*
         float dis1 = Vector2.Distance(player1.transform.position, transform.position);
         float dis2 = Vector2.Distance(player2.transform.position, transform.position);
         if (dis1 < dis2)
@@ -60,7 +76,8 @@ public class ESpirits_Float : MonoBehaviour
         else
         {
             target = player2;
-        }
+        }*/
+        target = player1;
     }
 
     private void FollowPlayer()
@@ -68,9 +85,14 @@ public class ESpirits_Float : MonoBehaviour
         curLock.transform.position = target.transform.position;
     }
 
+    private void LockPlayer()
+    {
+
+    }
+
     public void FloatAttack()
     {
-        curFe.transform.position = lockEffect.transform.position;
+        curFe.transform.position = curLock.transform.position;
         curLock.SetActive(false);
         curFe.SetActive(true);
     }
@@ -88,5 +110,49 @@ public class ESpirits_Float : MonoBehaviour
                 transform.position = new Vector3(origPos.x, height, origPos.z);
             }
         }
+        //隔一段时间发动一次锁定攻击
+        if (!isRise && !isDoing && (ene.state == CharacterState.Idle || ene.state == CharacterState.Run || ene.state == CharacterState.Attack))
+        {
+            pastTime += Time.deltaTime;
+            if (pastTime >= intervalTime)
+            {
+                ChoosePlayer();
+                isDoing = true;
+                isFollow = true;
+                pastTime = 0;
+                curLock.SetActive(true);
+            }
+        }
+        //跟随玩家
+        if (isFollow)
+        {
+            pastTime += Time.deltaTime;
+            FollowPlayer();
+            if (pastTime >= followTime)
+            {
+                isFollow = false;
+                isLock = true;
+                pastTime = 0;
+            }
+        }
+        //锁定范围
+        if (isLock)
+        {
+            pastTime += Time.deltaTime;
+            LockPlayer();
+            if (pastTime >= lockTime)
+            {
+                isLock = false;
+                isAttack = true;
+                pastTime = 0;
+            }
+        }
+        //攻击
+        if (isAttack)
+        {
+            FloatAttack();
+            isAttack = false;
+            isDoing = false;
+        }
     }
 }

+ 13 - 1
ActionTowerDefense/Assets/Scripts/Spirits/FloatEffect.cs

@@ -5,10 +5,14 @@ using UnityEngine;
 public class FloatEffect : MonoBehaviour
 {
     public bool isEnemy = false;
+    private GameObject effect;
+    private ParticleSystem ps;
 
     private void Start()
     {
-        Invoke("disappear", 0.2f);
+        //Invoke("disappear", 0.2f);
+        effect = transform.GetChild(1).gameObject;
+        ps = effect.GetComponent<ParticleSystem>();
     }
 
     private void disappear()
@@ -33,4 +37,12 @@ public class FloatEffect : MonoBehaviour
 
         }
     }
+
+    private void Update()
+    {
+        if (ps.isStopped)
+        {
+            gameObject.SetActive(false);
+        }
+    }
 }