Browse Source

气功波补传+墙反弹参数可调+墙反弹有向下的力

SZAND\msx_2 10 months ago
parent
commit
75c6654702

+ 118 - 0
ActionTowerDefense/Assets/Resources/Prefab/Conduct/WavePower.prefab

@@ -0,0 +1,118 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!1 &8625694250200680089
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1606292805419130208}
+  - component: {fileID: 2294170143768085763}
+  - component: {fileID: 244052354518820451}
+  - component: {fileID: 337167225160774390}
+  m_Layer: 0
+  m_Name: WavePower
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 1
+--- !u!4 &1606292805419130208
+Transform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8625694250200680089}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 3.24, y: 4.06, z: 3.3000002}
+  m_ConstrainProportionsScale: 0
+  m_Children: []
+  m_Father: {fileID: 0}
+  m_RootOrder: 0
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!212 &2294170143768085763
+SpriteRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8625694250200680089}
+  m_Enabled: 1
+  m_CastShadows: 0
+  m_ReceiveShadows: 0
+  m_DynamicOccludee: 1
+  m_StaticShadowCaster: 0
+  m_MotionVectors: 1
+  m_LightProbeUsage: 1
+  m_ReflectionProbeUsage: 1
+  m_RayTracingMode: 0
+  m_RayTraceProcedural: 0
+  m_RenderingLayerMask: 1
+  m_RendererPriority: 0
+  m_Materials:
+  - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
+  m_StaticBatchInfo:
+    firstSubMesh: 0
+    subMeshCount: 0
+  m_StaticBatchRoot: {fileID: 0}
+  m_ProbeAnchor: {fileID: 0}
+  m_LightProbeVolumeOverride: {fileID: 0}
+  m_ScaleInLightmap: 1
+  m_ReceiveGI: 1
+  m_PreserveUVs: 0
+  m_IgnoreNormalsForChartDetection: 0
+  m_ImportantGI: 0
+  m_StitchLightmapSeams: 1
+  m_SelectedEditorRenderState: 0
+  m_MinimumChartSize: 4
+  m_AutoUVMaxDistance: 0.5
+  m_AutoUVMaxAngle: 89
+  m_LightmapParameters: {fileID: 0}
+  m_SortingLayerID: 0
+  m_SortingLayer: 0
+  m_SortingOrder: 0
+  m_Sprite: {fileID: 21300000, guid: 4a176e29c99575247b703302c7f64bb5, type: 3}
+  m_Color: {r: 1, g: 0.9792701, b: 0, a: 1}
+  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
+--- !u!65 &244052354518820451
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8625694250200680089}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 1
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 2.4124382, y: 2.5599997, z: 0.19999999}
+  m_Center: {x: 0.031620264, y: 0, z: 0}
+--- !u!114 &337167225160774390
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 8625694250200680089}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: c5f09e346a819ab44a5addd5c5c5281f, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  force: {x: 20000, y: 5000, z: 0}
+  damage: 0
+  continueTime: 3
+  cacheID: 0
+  pc: {fileID: 0}

+ 7 - 0
ActionTowerDefense/Assets/Resources/Prefab/Conduct/WavePower.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 2ee85ceccd170b94b8ba929f3b58af5f
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 0
ActionTowerDefense/Assets/Resources/Prefab/Player.prefab

@@ -1013,6 +1013,7 @@ MonoBehaviour:
   mountain: {fileID: 8587706472837483213, guid: d966b0d5004eaad49b37c963f1aaa584, type: 3}
   offset: {x: 0, y: 7, z: 0}
   mountainTime: 5
+  wavePowerObj: {fileID: 8625694250200680089, guid: 2ee85ceccd170b94b8ba929f3b58af5f, type: 3}
   flyingSwordsObj: {fileID: 256012001268456902, guid: 28fffa39583087344b7b2620e7284dd5, type: 3}
   isClickBtnJump: 0
   isClickBtnRush: 0

+ 2 - 2
ActionTowerDefense/Assets/Scenes/SampleScene.unity

@@ -411,8 +411,8 @@ MonoBehaviour:
   down: {fileID: 363224843}
   left: {fileID: 1131594848}
   right: {fileID: 1543654651}
-  reboundXSpeed: 0.2
-  reboundYSpeed: 1
+  forceX: {x: 10, y: -1, z: 0}
+  forceY: {x: 0, y: 0, z: 0}
 --- !u!1 &306030530
 GameObject:
   m_ObjectHideFlags: 0

+ 44 - 0
ActionTowerDefense/Assets/Scripts/Conduct/WavePowerSkill.cs

@@ -0,0 +1,44 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class WavePowerSkill : MonoBehaviour
+{
+    public Vector3 force;
+    private int fx = 1;
+    private Vector3 curForce;
+    public int damage;
+    public float continueTime;
+    public int cacheID;
+    public PlayerController pc;
+
+    private void Update()
+    {
+        continueTime -= Time.deltaTime;
+        if (continueTime <= 0)
+        {
+            pc.conductCanRelease[cacheID] = true;
+            gameObject.SetActive(false);
+        }
+    }
+
+    private void OnTriggerEnter(Collider other)
+    {
+        if (other.gameObject.layer == 8)
+        {
+            if (other.gameObject.transform.position.x >= transform.position.x)
+            {
+                fx = 1;
+            }
+            else
+            {
+                fx = -1;
+            }
+            curForce = force;
+            curForce.x = curForce.x * fx;
+            other.GetComponentInParent<Enemy>().ChangeState(CharacterState.Weak);
+            other.GetComponentInParent<Enemy>().wallDamage = damage;
+            other.GetComponentInParent<Rigidbody>().AddForce(curForce);
+        }
+    }
+}

+ 11 - 0
ActionTowerDefense/Assets/Scripts/Conduct/WavePowerSkill.cs.meta

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

+ 5 - 12
ActionTowerDefense/Assets/Scripts/Enemy.cs

@@ -47,6 +47,7 @@ public class Enemy : MoveCharacter
     private bool hasBeReboundedY;
     public float reboundXSpeed;
     public float reboundYSpeed;
+    public int wallDamage;
 
     [Header("ÂäµØÑ£ÔÎ")]
     public bool willBeComa;
@@ -485,30 +486,22 @@ public class Enemy : MoveCharacter
                     }
                     else
                     {
-                        if (hasBeReboundedX)
-                        {
-                            vel.x -= vel.x * decelerationRatio * Time.deltaTime * reboundXSpeed;
-                        }
-                        else
+                        if (!hasBeReboundedX)
                         {
                             vel.x -= vel.x * decelerationRatio * Time.deltaTime;
                             if (!hasBeReboundedX && isBeReboundedX)
                             {
                                 hasBeReboundedX = true;
-                                vel.x = -vel.x;
+                                vel.x = 0;
                             }
                         }
-                        if (hasBeReboundedY)
-                        {
-                            vel.y += extraFallGravity * Time.deltaTime * reboundYSpeed;
-                        }
-                        else
+                        if (!hasBeReboundedY)
                         {
                             vel.y += extraFallGravity * Time.deltaTime;
                             if (!hasBeReboundedY && isBeReboundedY)
                             {
                                 hasBeReboundedY = true;
-                                vel.y = -vel.y;
+                                vel.y = 0;
                             }
                         }
                     }

+ 21 - 1
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -181,6 +181,8 @@ public class PlayerController : MoveCharacter
     public Vector3 offset;
     private GameObject curMountain;
     public float mountainTime;
+    //气功波
+    public GameObject wavePowerObj;
     //御剑术
     public GameObject flyingSwordsObj;
 
@@ -191,7 +193,9 @@ public class PlayerController : MoveCharacter
         AddAttack,          //胖子:增加攻击力
 
         Mountain,           //气功师:泰山压顶
+        WavePower,          //气功师:气功波
         SwordsControl,      //气功师:御剑术
+
     }
 
 
@@ -806,8 +810,24 @@ public class PlayerController : MoveCharacter
                         costMp = false;
                     }
                     break;
+                case ConductSkills.WavePower:
+                    if (demonicDic[2].Count > 0)
+                    {
+                        conductCanRelease[cacheConductId] = false;
+                        GameObject obj = Instantiate(wavePowerObj, transform);
+                        obj.transform.position = transform.position + Vector3.up;
+                        WavePowerSkill wps = obj.GetComponent<WavePowerSkill>();
+                        wps.damage = 100 * demonicDic[2].Count;
+                        wps.cacheID = cacheConductId;
+                        wps.pc = this;
+                    }
+                    else
+                    {
+                        costMp = false;
+                    }
+                    break;
                 case ConductSkills.SwordsControl:
-                    if (demonicDic[1].Count > 0)
+                    if (demonicDic[2].Count > 0)
                     {
                         conductCanRelease[cacheConductId] = false;
                         GameObject obj = Instantiate(flyingSwordsObj, transform);

+ 2 - 2
ActionTowerDefense/Assets/Scripts/SystemReflect/ScreenCrash.cs

@@ -17,8 +17,8 @@ public class ScreenCrash : MonoBehaviour
     public SingleScreenBorder right;
 
     [Header("反弹的力的大小")]
-    [Tooltip("撞到左右墙后反弹的速度")] public float reboundXSpeed;
-    [Tooltip("撞到上下墙后反弹的速度")] public float reboundYSpeed;
+    [Tooltip("撞到左右墙后反弹的速度")] public Vector3 forceX;
+    [Tooltip("撞到上下墙后反弹的速度")] public Vector3 forceY;
 
     private void Start()
     {

+ 7 - 2
ActionTowerDefense/Assets/Scripts/SystemReflect/SingleScreenBorder.cs

@@ -24,14 +24,19 @@ public class SingleScreenBorder : MonoBehaviour
         Vector3 vel = ene.rb.velocity;
         if (isLeft && vel.x < 0 || isRight && vel.x > 0)
         {
-            ene.reboundXSpeed = sc.reboundXSpeed * (vel.x / Mathf.Abs(vel.x));
+            Vector3 force = sc.forceX;
+            if (!isLeft)
+            {
+                force.x = -force.x;
+            }
             ene.isBeReboundedX = true;
+            ene.BeHit(ene.wallDamage, force, false, 0);
             return;
         }
         if (isUp && vel.y > 0 || isDown && vel.y < 0)
         {
-            ene.reboundYSpeed = sc.reboundYSpeed;
             ene.isBeReboundedY = true;
+            ene.BeHit(ene.wallDamage, sc.forceY, false, 0);
             return;
         }
         return;