狗屎Minimax坏我代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Cielonos.MainGame.UI;
|
||||
using SLSUtilities.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters
|
||||
@@ -12,7 +13,7 @@ namespace Cielonos.MainGame.Characters
|
||||
{
|
||||
private void Regeneration()
|
||||
{
|
||||
float healthRegenRate = attributeSm["HealthRegen"] * deltaTime;
|
||||
float healthRegenRate = attributeSm["HealthRegeneration"] * deltaTime;
|
||||
|
||||
if (healthRegenRate != 0)
|
||||
{
|
||||
@@ -21,13 +22,87 @@ namespace Cielonos.MainGame.Characters
|
||||
PlayerCanvas.Instance.playerInfoUIArea.UpdateHealth(true);
|
||||
}
|
||||
|
||||
float energyRegenRate = attributeSm["EnergyRegen"] * deltaTime;
|
||||
|
||||
float energyRegenRate = attributeSm["EnergyRegeneration"] * deltaTime;
|
||||
if (energyRegenRate != 0)
|
||||
{
|
||||
attributeSm["Energy"] += energyRegenRate;
|
||||
attributeSm["Energy"] = Mathf.Min(attributeSm["Energy"], attributeSm["MaximumEnergy"]);
|
||||
PlayerCanvas.Instance.playerInfoUIArea.UpdateEnergy(true);
|
||||
AddEnergy(energyRegenRate);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddEnergy(float amount)
|
||||
{
|
||||
if (amount == 0) return;
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
float current = attributeSm["Energy"];
|
||||
float max = attributeSm["MaximumEnergy"];
|
||||
float availableSpace = max - current;
|
||||
|
||||
if (amount > availableSpace)
|
||||
{
|
||||
attributeSm["Energy"] = max;
|
||||
|
||||
float conversionRate = attributeSm.Has("OverloadConversionRate") ? attributeSm["OverloadConversionRate"] : 1f;
|
||||
float overflowEnergy = (amount - availableSpace) * conversionRate;
|
||||
DistributeOverloadEnergy(overflowEnergy);
|
||||
}
|
||||
else
|
||||
{
|
||||
attributeSm["Energy"] += amount;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attributeSm["Energy"] += amount;
|
||||
attributeSm["Energy"] = Mathf.Max(0, attributeSm["Energy"]);
|
||||
}
|
||||
|
||||
PlayerCanvas.Instance.playerInfoUIArea.UpdateEnergy(true);
|
||||
eventSm.onEnergyChanged.Invoke(amount);
|
||||
}
|
||||
|
||||
private void DistributeOverloadEnergy(float totalOverflowAmount)
|
||||
{
|
||||
if (totalOverflowAmount <= 0) return;
|
||||
|
||||
var overloadSubmodules = new System.Collections.Generic.List<Inventory.OverloadSubmodule>();
|
||||
|
||||
if (inventorySc.equipmentSm.currentMainWeapon?.overloadSm != null)
|
||||
{
|
||||
overloadSubmodules.Add(inventorySc.equipmentSm.currentMainWeapon.overloadSm);
|
||||
}
|
||||
|
||||
foreach (var equip in inventorySc.equipmentSm.currentSupportEquipments)
|
||||
{
|
||||
if (equip?.overloadSm != null)
|
||||
{
|
||||
overloadSubmodules.Add(equip.overloadSm);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var equip in inventorySc.backpack.passiveEquipments)
|
||||
{
|
||||
if (equip?.overloadSm != null)
|
||||
{
|
||||
overloadSubmodules.Add(equip.overloadSm);
|
||||
}
|
||||
}
|
||||
|
||||
if (overloadSubmodules.Count == 0) return;
|
||||
|
||||
float totalWeight = 0;
|
||||
foreach (var sm in overloadSubmodules)
|
||||
{
|
||||
totalWeight += sm.currentWeight;
|
||||
}
|
||||
|
||||
if (totalWeight <= 0) return;
|
||||
|
||||
foreach (var sm in overloadSubmodules)
|
||||
{
|
||||
float assignedAmount = totalOverflowAmount * (sm.currentWeight / totalWeight);
|
||||
sm.ReceiveEnergy(assignedAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user