Переглянути джерело

御剑术开关,选择增强攻击/增加范围/两个都加

LAPTOP-OM1V99U2\永远de小亡灵 10 місяців тому
батько
коміт
550b4e3adb

+ 32 - 25
ActionTowerDefense/Assets/Resources/Prefab/Conduct/SwordsControl.prefab

@@ -129,8 +129,8 @@ GameObject:
   serializedVersion: 6
   m_Component:
   - component: {fileID: 6527116474255812546}
-  - component: {fileID: 6336452897766439345}
   - component: {fileID: 7067166650331371016}
+  - component: {fileID: 9157563607941819719}
   m_Layer: 20
   m_Name: Trigger
   m_TagString: Untagged
@@ -153,29 +153,6 @@ Transform:
   m_Children: []
   m_Father: {fileID: 7905728122997361441}
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!136 &6336452897766439345
-CapsuleCollider:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 5080240558872983884}
-  m_Material: {fileID: 0}
-  m_IncludeLayers:
-    serializedVersion: 2
-    m_Bits: 0
-  m_ExcludeLayers:
-    serializedVersion: 2
-    m_Bits: 0
-  m_LayerOverridePriority: 0
-  m_IsTrigger: 1
-  m_ProvidesContacts: 0
-  m_Enabled: 1
-  serializedVersion: 2
-  m_Radius: 1.5
-  m_Height: 20
-  m_Direction: 2
-  m_Center: {x: 0, y: 0, z: 0}
 --- !u!114 &7067166650331371016
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -189,13 +166,43 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   intervalTime: 0.2
-  damage: 300
+  boostNum: 0
   moveCharacrters: []
   totalTime: 10
   time: 0
   parent: {fileID: 256012001268456902}
   owner: {fileID: 0}
   conductId: 0
+  damage: 100
+  scale: 1
+  swordsControl: 2
+  stageSize:
+  - 1.5
+  - 2
+  - 3
+  - 4
+  demonicDieNum: 0200000004000000080000000f000000
+--- !u!65 &9157563607941819719
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 5080240558872983884}
+  m_Material: {fileID: 0}
+  m_IncludeLayers:
+    serializedVersion: 2
+    m_Bits: 0
+  m_ExcludeLayers:
+    serializedVersion: 2
+    m_Bits: 0
+  m_LayerOverridePriority: 0
+  m_IsTrigger: 0
+  m_ProvidesContacts: 0
+  m_Enabled: 1
+  serializedVersion: 3
+  m_Size: {x: 3, y: 3, z: 20}
+  m_Center: {x: 0, y: 0, z: 0}
 --- !u!1 &8828199222583713393
 GameObject:
   m_ObjectHideFlags: 0

+ 44 - 3
ActionTowerDefense/Assets/Scripts/Conduct/SwordsControl.cs

@@ -1,18 +1,39 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.TextCore.Text;
 
 public class SwordsControl : MonoBehaviour
 {
+    public enum SwordsControlState
+    {
+        Damage,
+        Scale,
+        All
+    }
     public float intervalTime;                                              //造成伤害的间隔时间
-    public int damage;                                                      //造成的伤害
+    public int boostNum;                                             
     public List<MoveCharacter> moveCharacrters = new List<MoveCharacter>(); //被造成伤害的角色
     public float totalTime;                                                 //多少时间后消失
     [HideInInspector] public float time;                                    //经过的时间
     public GameObject parent;
     public PlayerController owner;
     public int conductId;
-
+    [Header("伤害基数")]
+    public int damage;
+    [Header("范围基数")]
+    public float scale;
+    public SwordsControlState swordsControl;
+    public float[] stageSize;
+    public int[] demonicDieNum;
+    private void Start()
+    {
+        if (swordsControl != SwordsControlState.Damage)
+        {
+            print(111111);
+            transform.parent.parent.localScale = Vector3.one * scale * TranSize(boostNum);
+        }
+    }
     private void Update()
     {
         time += Time.deltaTime;
@@ -34,7 +55,10 @@ public class SwordsControl : MonoBehaviour
                 moveCharacrters.Add(character);
                 character.sustainedInjuryTime = intervalTime;
                 character.sustainedInjury_IntervalTime = intervalTime;
-                character.sustainedInjury_damage = damage;
+                if(swordsControl != SwordsControlState.Scale)
+                {
+                    character.sustainedInjury_damage = damage * boostNum;
+                }
                 character.isSustainedInjury = true;
             }
         }
@@ -64,4 +88,21 @@ public class SwordsControl : MonoBehaviour
             moveCharacrters[i].isSustainedInjury = false;
         }
     }
+
+    private float TranSize(int dieNum)
+    {
+        for (int i = stageSize.Length - 1; i >= 0; i--)
+        {
+            if (dieNum >= demonicDieNum[i])
+            {
+                if (i == stageSize.Length - 1)
+                {
+                    return stageSize[i];
+                }
+                float size = stageSize[i] + (stageSize[i + 1] - stageSize[i]) / (demonicDieNum[i + 1] - demonicDieNum[i]) * (dieNum - demonicDieNum[i]);
+                return size;
+            }
+        }
+        return 1;
+    }
 }

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

@@ -188,7 +188,6 @@ public class PlayerController : MoveCharacter
     [Header("气功波伤害基数")]public int wavePowerDamage;
     //御剑术
     public GameObject flyingSwordsObj;
-    [Header("御剑术伤害")] public int swordsDamage;
     //怨气弹
     public GameObject angryBulletObj;
     [Header("怨气弹数量基数")] public int angryBulletNum;
@@ -904,7 +903,7 @@ public class PlayerController : MoveCharacter
                     SwordsControl swordsControl = obj.GetComponentInChildren<SwordsControl>();
                     swordsControl.owner = this;
                     swordsControl.conductId = cacheConductId;
-                    swordsControl.damage = swordsDamage * boostNum;
+                    swordsControl.boostNum = boostNum;
                     break;
                 //弓箭手
                 case ConductSkills.AngryBullet: