Bläddra i källkod

推塔后没杀完的小怪掉落金币,修复经验和金币掉落出错的问题

WGL 1 månad sedan
förälder
incheckning
2b1f4d38f7

+ 7 - 3
ActionTowerDefense/Assets/Scripts/GameManager.cs

@@ -40,6 +40,7 @@ public class GameManager : MonoBehaviour
     [FoldoutGroup("金币结算")][LabelText("额外金币奖励")] public int extraMoney;
     [FoldoutGroup("金币结算")][LabelText("惩罚时间间隔")] public int deductMoneyTime;
     [FoldoutGroup("金币结算")][LabelText("每次惩罚扣除金币数量")] public int deductMoney;
+    [FoldoutGroup("金币结算")][LabelText("怪物掉落金币数量")] public int enemyGoldDrop;
 
     [FoldoutGroup("Rogue数值")] [LabelText("伤害")] public int damage;
     [FoldoutGroup("Rogue数值")] [LabelText("暴击率")] public int criticalChance;
@@ -134,6 +135,7 @@ public class GameManager : MonoBehaviour
     public void GameEnd()
     {
         gameType = GameType.GameEnd;
+        int dropGold = 0;
         foreach (List<Enemy> objs in EnemyCreater.instance.enemyDic.Values)
         {
             for (int i = 0; i < objs.Count; i++)
@@ -142,6 +144,7 @@ public class GameManager : MonoBehaviour
                 {
                     objs[i].killer = null;
                     objs[i].ChangeState(CharacterState.Die);
+                    dropGold += enemyGoldDrop;
                 }
             }
         }
@@ -149,11 +152,11 @@ public class GameManager : MonoBehaviour
         {
             return;
         }
-        AddMoney();
+        AddMoney(dropGold);
         shopButton.SetActive(true);
     }
     
-    public void AddMoney()
+    public void AddMoney(int enemyDrop)
     {
         int addMoney;
         if(gameTime < rewardTime)
@@ -165,7 +168,8 @@ public class GameManager : MonoBehaviour
             int extraTime = (int)gameTime - rewardTime;
             addMoney = Mathf.Clamp(totalMoney - (extraTime / deductMoneyTime) * deductMoney, 0, totalMoney);
         }
-        money += Mathf.RoundToInt(addMoney * increasedGoldGain / 100f);
+        addMoney += enemyDrop;
+        money += Mathf.RoundToInt(addMoney * (1 + increasedGoldGain / 100f));
         moneyText.text = $"{money}";
     }
 

+ 1 - 1
ActionTowerDefense/Assets/Scripts/Rougue/SoldierEXP.cs

@@ -65,7 +65,7 @@ public class SoldierEXP : MonoBehaviour
                 {
                     return;
                 }
-                ssexp[i].curEXP += Mathf.RoundToInt(exp * GameManager.instance.increasedEXPGain/100f);
+                ssexp[i].curEXP += Mathf.RoundToInt(exp * (1 + GameManager.instance.increasedEXPGain/100f));
                 JudgeEXP(st);
                 break;
             }