private void UpgradeCarWithEquippedItems(
            IUpgradable upgradable,
            IReadOnlyList <IItem> items,
            IReadOnlyDictionary <int, IUpgradeHandler> upgradeHandlers,
            IReadOnlyDictionary <int, IUpgradeHandler> defaultHandlers)
        {
            if (items.Count == 0)
            {
                _upgradable.Restore();
            }

            Debug.Log(items.Count);
            foreach (var item in items)
            {
                if (item.IsSelected)
                {
                    if (upgradeHandlers.TryGetValue(item.Id, out var handler))
                    {
                        handler.Upgrade(upgradable);
                    }
                }
                else
                {
                    if (defaultHandlers.TryGetValue(item.Id, out var defaultHandler))
                    {
                        defaultHandler.Upgrade(upgradable);
                    }
                }
            }
        }
Esempio n. 2
0
        private void UpgradeCarWithEquippedItems(IUpgradable upgradable, IReadOnlyList <IItem> equippedItems,
                                                 IReadOnlyDictionary <int, IUpgradeHandler> upgradeHandlers)
        {
            upgradable.Restore();

            foreach (var equippedItem in equippedItems)
            {
                if (upgradeHandlers.TryGetValue(equippedItem.ID, out var handler))
                {
                    handler.Upgrade(upgradable);
                }
            }
        }