diff --git a/client/Assets/AddressableAssetsData/OSX.meta b/client/Assets/AddressableAssetsData/OSX.meta new file mode 100644 index 00000000..d1a66ce8 --- /dev/null +++ b/client/Assets/AddressableAssetsData/OSX.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58847661d284d4a10b0d6308bcd46a96 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/client/Assets/Scripts/BackendConnection/SocketConnection.cs b/client/Assets/Scripts/BackendConnection/SocketConnection.cs index c2bdadb3..29f6283f 100644 --- a/client/Assets/Scripts/BackendConnection/SocketConnection.cs +++ b/client/Assets/Scripts/BackendConnection/SocketConnection.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using UnityEditor.Build.Utilities; using UnityEngine; public class SocketConnection : MonoBehaviour @@ -1004,7 +1005,7 @@ private void AwaitLevelUpDungeonSettlementResponse(byte[] data, Action onL } } - public void GetDungeonUpgrades(string userId, Action onLeveledUpUserReceived, Action onError = null) + public void GetDungeonUpgrades(string userId, Action> onUpgradesDataReceived, Action onError = null) { GetDungeonUpgrades getDungeonUpgrades = new GetDungeonUpgrades { @@ -1014,13 +1015,13 @@ public void GetDungeonUpgrades(string userId, Action onLeveledUpUserReceiv { GetDungeonUpgrades = getDungeonUpgrades }; - currentMessageHandler = (data) => AwaitGetDungeonUpgradesResponse(data, onLeveledUpUserReceived, onError); + currentMessageHandler = (data) => AwaitGetDungeonUpgradesResponse(data, onUpgradesDataReceived, onError); ws.OnMessage += currentMessageHandler; ws.OnMessage -= OnWebSocketMessage; SendWebSocketMessage(request); } - private void AwaitGetDungeonUpgradesResponse(byte[] data, Action onLeveledUpUserReceived, Action onError = null) + private void AwaitGetDungeonUpgradesResponse(byte[] data, Action> onUpgradesDataReceived, Action onError = null) { try { @@ -1029,16 +1030,29 @@ private void AwaitGetDungeonUpgradesResponse(byte[] data, Action onLeveled WebSocketResponse webSocketResponse = WebSocketResponse.Parser.ParseFrom(data); if (webSocketResponse.ResponseTypeCase == WebSocketResponse.ResponseTypeOneofCase.Upgrades) { - GlobalUserData.Instance.AvailableUpgrades = webSocketResponse.Upgrades.Upgrades_.Select(upgrade => new Upgrade - { - id = upgrade.Id, - name = upgrade.Name, - description = upgrade.Description, - cost = upgrade.Cost.ToDictionary(cost => cost.Currency.Name, cost => (int)cost.Amount), - level = (int)upgrade.Level, - maxLevel = (int)upgrade.MaxLevel, - type = upgrade.Type, - value = upgrade.Value - }).ToList(); - + List upgrades = ParseUpgradesFromResponse(webSocketResponse.Upgrades); + onUpgradesDataReceived?.Invoke(upgrades); } + } + catch (Exception e) + { + Debug.LogError(e.Message); + } + } + + private List ParseUpgradesFromResponse(Upgrades upgradesMessage) + { + return upgradesMessage.Upgrades_.Select(upgrade => + { + return new Upgrade + { + name = upgrade.Name, + description = upgrade.Description, + costs = upgrade.Cost.Select(cost => new CurrencyCost { currency = new Currency { name = cost.Currency.Name }, amount = (int)cost.Amount }).ToList(), + buffs = upgrade.Buffs.Select(buff => new Buff { attribute = buff.Attribute, value = buff.Value, operation = buff.Operation }).ToList() + }; + }).ToList(); + } +} + + diff --git a/client/Assets/Scripts/Buff.cs b/client/Assets/Scripts/Buff.cs index 7e0f223d..1f1783c8 100644 --- a/client/Assets/Scripts/Buff.cs +++ b/client/Assets/Scripts/Buff.cs @@ -1,7 +1,7 @@ public class Buff { - string attribute; - float value; - string operation; + public string attribute; + public float value; + public string operation; } diff --git a/client/Assets/Scripts/Buff.cs.meta b/client/Assets/Scripts/Buff.cs.meta new file mode 100644 index 00000000..b58e7ac4 --- /dev/null +++ b/client/Assets/Scripts/Buff.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cdff913d473b043c88535a32624b4da7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/client/Assets/Scripts/Dungeon/DungeonUpgradesManager.cs b/client/Assets/Scripts/Dungeon/DungeonUpgradesManager.cs index 13df9615..c8849fc5 100644 --- a/client/Assets/Scripts/Dungeon/DungeonUpgradesManager.cs +++ b/client/Assets/Scripts/Dungeon/DungeonUpgradesManager.cs @@ -19,13 +19,7 @@ void Start() SocketConnection.Instance.GetDungeonUpgrades(user.id, (upgrades) => { - foreach (var group in upgrades.GroupBy(upgrade => upgrade.template.name)) - { - GameObject upgradeUIObject = Instantiate(upgradePrefab, upgradesContainer.transform); - upgradeUIObject.GetComponent().SetUpUpgrade(group.First(), group.Count()); - Button unitUpgradeButton = upgradeUIObject.GetComponent