Quellcode durchsuchen

调整弓箭手获得漂浮能力的概率

SZAND\msx_2 vor 1 Jahr
Ursprung
Commit
fb524f95c3

+ 5 - 21
ActionTowerDefense/Assets/Resources/Prefab/Transfiguration/Trans_Float.prefab

@@ -1033,27 +1033,9 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   controller: {fileID: 0}
   UIoffset: {x: 0, y: 0, z: 0}
-  floatProbability: 5
-  mpJ: 10
-  mpK: 10
-  mpL: 150
-  CDJ: 0.5
-  CDK: 2
-  CDL: 5
-  intervalTimeJ: 0
-  intervalTimeK: 0
-  intervalTimeL: 0
-  minTime: 7
-  maxTime: 9
-  toFloat: 0
-  lockeffect: {fileID: 2633192158325483446, guid: c51a663ee138c374f8e9fc17c05c1df9, type: 3}
-  fe: {fileID: 417478504669294145, guid: 243eb0eff66414445990654286d861d1, type: 3}
-  moveSpeed: 0.05
-  keepFloatTime: 3
-  minRange: 5
-  maxRange: 20
-  maxKMp: 150
-  LAttackDamage: 100
+  floatProbability: 0.05
+  gainAbilityProbability: 5
+  abilityTimes: 1
 --- !u!114 &3290368322717680010
 MonoBehaviour:
   m_ObjectHideFlags: 0
@@ -1152,6 +1134,8 @@ MonoBehaviour:
   canHitFloat: 0
   floatProbability: 0
   attackToFloat: 0
+  floatTimes: 0
+  hasFloatTimes: 0
   isSoulUnstable: 0
   soulUnstableTime: 0
   criticalChance: 0

+ 1 - 0
ActionTowerDefense/Assets/Scripts/Bullet.cs

@@ -156,6 +156,7 @@ public class Bullet : MonoBehaviour
                     if (toFloat)
                     {
                         owner.attackToFloat = false;
+                        owner.floatTimes += 1;
                         toFloat = false;
                         if (hitTrigger.tag != "EnemyTower")
                         {

+ 4 - 2
ActionTowerDefense/Assets/Scripts/Character.cs

@@ -111,6 +111,8 @@ public class Character : MonoBehaviour
     public bool canHitFloat;                //是否概率使敌方漂浮
     public float floatProbability;          //漂浮概率
     public bool attackToFloat = false;      //攻击使敌方漂浮
+    public int floatTimes;                  //漂浮次数
+    public int hasFloatTimes;
     public bool isSoulUnstable;             //灵魂不稳定状态
     public float soulUnstableTime;          //灵魂不稳定状态时间
     public float criticalChance;            //暴击率
@@ -211,7 +213,7 @@ public class Character : MonoBehaviour
         }
         GameObject bulletObj = PoolManager.Instantiate(bulletPrefab);
         Bullet bullet = bulletObj.GetComponent<Bullet>();
-        if (attackToFloat)
+        if (attackToFloat && hasFloatTimes < floatTimes)
         {
             bullet.toFloat = true;
         }
@@ -267,7 +269,7 @@ public class Character : MonoBehaviour
     {
         if (canHitFloat)
         {
-            int k = Random.Range(0, 101);
+            float k = Random.Range(0, 100);
             if (k <= floatProbability)
             {
                 attackToFloat = true;

+ 10 - 3
ActionTowerDefense/Assets/Scripts/PlayerController.cs

@@ -1567,6 +1567,8 @@ public class PlayerController : MoveCharacter
 
     public bool canArrowHitFloat;   //可以让弓箭手攻击概率漂浮
     public float probability;       //攻击的漂浮概率
+    public float gainAbilityProbability;    //弓箭手获得漂浮能力的概率
+    public int abilityTimes;        //弓箭手释放漂浮能力的次数
 
     public void Summon(int id)
     {
@@ -1597,10 +1599,15 @@ public class PlayerController : MoveCharacter
         uiMp.Show(mp, totalMp);
         GameObject demonicObj = PoolManager.Instantiate(prefab);
         Demonic demonic = demonicObj.GetComponent<Demonic>();
-        if (canArrowHitFloat)
+        if (canArrowHitFloat && id == 0)
         {
-            demonic.attackToFloat = true;
-            demonic.floatProbability = probability;
+            float k = UnityEngine.Random.Range(0, 100);
+            if (k <= gainAbilityProbability)
+            {
+                demonic.attackToFloat = true;
+                demonic.floatProbability = probability;
+                demonic.floatTimes = abilityTimes;
+            }
         }
         if (id == 2)
         {

+ 4 - 76
ActionTowerDefense/Assets/Scripts/Spirits/Trans_Float.cs

@@ -5,71 +5,20 @@ using UnityEngine;
 public class Trans_Float : MonoBehaviour
 {
     public PlayerController controller;
-    //public float changeTime;
     public Vector3 UIoffset;                //UI调整值
 
     public float floatProbability;          //漂浮概率
-
-    public int mpJ;
-    public int mpK;
-    public int mpL;
-
-    public float CDJ;
-    public float CDK;
-    public float CDL;
-    private float pastCDJ;
-    private float pastCDK;
-    private float pastCDL;
-    private bool isCDJ;
-    private bool isCDK;
-    private bool isCDL;
-
-    public float intervalTimeJ;              //攻击硬直
-    public float intervalTimeK;              //攻击硬直
-    public float intervalTimeL;              //攻击硬直
-    private float intervalTime;
-    private float pastAttackTime;
-    private bool canAttack = true;
-
-    private bool isFirst = true;            //第一次攻击
-    private int times;                      //攻击次数
-    public int minTime, maxTime;            //保底范围
-
-    public bool toFloat = false;            //攻击触发漂浮
-
-    private bool isK = false;
-    private Demonic dem;
-
-    public GameObject lockeffect;           //漂浮特效
-    private GameObject curlock;             //当前漂浮特效
-    public GameObject fe;
-    private GameObject curFe;
-    public float moveSpeed;                 //特效移动速度
-
-    private bool once = false;
-
-    public float keepFloatTime;             //K键最大持续时间
-    public float minRange, maxRange;        //K键浮空场范围
-    public int maxKMp;                      //K键最大耗蓝
-    private float pastTime;
-    private float continueMp;               //mp持续减少程度
-    private float isLosingMp;
-    private float continueRange;            //浮空场持续变宽程度
-
-    public int LAttackDamage;               //L键摔落伤害
+    public float gainAbilityProbability;    //获得漂浮特性的概率
+    public int abilityTimes;                //攻击使漂浮的次数
 
     private void Start()
     {
         controller = GetComponentInParent<PlayerController>();
         controller.canArrowHitFloat = true;
         controller.probability = floatProbability;
-        //controller.changeTime = changeTime;
-        dem = GetComponent<Demonic>();
+        controller.gainAbilityProbability = gainAbilityProbability;
+        controller.abilityTimes = abilityTimes;
         controller.canMove = true;
-        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);
-        curlock.SetActive(false);
-        curFe.SetActive(false);
     }
 
     private void OnDisable()
@@ -83,27 +32,6 @@ public class Trans_Float : MonoBehaviour
         controller.uiMp.Show(controller.mp, controller.totalMp);
     }
 
-    private void ToInterval(int deMP)
-    {
-        DeMp(deMP);
-        if (intervalTime != 0)
-        {
-            controller.canMove = false;
-            canAttack = false;
-            controller.ChangeState(CharacterState.Idle);
-        }
-        else
-        {
-            controller.canMove = true;
-        }
-    }
-
-    private void KContinueValue()
-    {
-        continueMp = (maxKMp - mpK) / keepFloatTime;
-        continueRange = (maxRange - minRange) / keepFloatTime;
-    }
-
     /*
     private void Update()
     {