<repo_name>anacat/Electronics-Super-Shop<file_sep>/Assets/Scripts/Devices/DeviceClick.cs
﻿using UnityEngine;
using System.Collections;

public class DeviceClick : MonoBehaviour {

    void OnMouseDown()
    {
        SpriteRenderer sr = GetComponent<SpriteRenderer>();

        GameManager.AddDeviceSelection(GetComponent<DeviceComponent>());
        transform.GetChild(0).gameObject.SetActive(true);
        sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 0.5f);
    }
}
<file_sep>/Assets/Scripts/DeviceSpawn.cs
﻿using UnityEngine;
using System.Collections;

public class DeviceSpawn : MonoBehaviour {

    void Awake()
    {
        if (GameManager.GetSelectedDevices() != null)
        {
            foreach (GameObject g in GameManager.GetSelectedDevices())
            {
                Instantiate(g);
            }
        }
    }
}
<file_sep>/Assets/Scripts/Briefing/BriefingManager.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public static class BriefingManager
{
    private static List<Briefing> _briefingList = new List<Briefing>();
    private static List<GameObject> _prefabList = new List<GameObject>();
    
    public static List<Briefing> GetAllBriefings()
    {
        _prefabList = new List<GameObject>();
        _prefabList.AddRange(Resources.LoadAll<GameObject>("Briefings"));

        foreach (GameObject g in _prefabList)
        {
            _briefingList.Add(g.GetComponentInChildren<BriefingInfo>(true).GetBriefing());
        }

        return _briefingList;
    }

    public static Briefing GetRandomBriefing()
    {
        int random = Random.Range(0, _briefingList.Count-1);

        return _briefingList[random];
    }
}
<file_sep>/Assets/Scripts/Store/ShopManager.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ShopManager : MonoBehaviour
{
    public GameObject storeItemPrefab;
    public Transform storeContainer;

    void Awake()
    {
        List<GameObject> cables = GameManager.GetAllCablesGameObjects();
        List<GameObject> devices = GameManager.GetAllDeviceGameObjects();

        foreach (GameObject g in cables)
        {
            GameObject obj = (GameObject)Instantiate(storeItemPrefab);
            ShopItem shopItem = obj.GetComponent<ShopItem>();

            obj.transform.SetParent(storeContainer);
            shopItem.SetCable(g.GetComponentInChildren<CableComponent>(true));
        }

        foreach (GameObject g in devices)
        {
            GameObject obj = (GameObject)Instantiate(storeItemPrefab);
            ShopItem shopItem = obj.GetComponent<ShopItem>();

            obj.transform.SetParent(storeContainer);
            shopItem.SetDevice(g.GetComponentInChildren<DeviceComponent>(true));
        }
    }
}
<file_sep>/Assets/Scripts/DeviceManager.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class DeviceManager : MonoBehaviour {

    public DeviceComponent[] allDevices;
    public Dictionary<string, DeviceComponent> availableComponents;

    void Start()
    {
        availableComponents = GameManager.GetAllDevices();

        SetAvailableDevices();
    }

    private void SetAvailableDevices()
    {
        for (int i = 0; i < allDevices.Length; i++)
        {
            if (!availableComponents[DeviceComponentHelper.DeviceName(allDevices[i].deviceType)].IsAvailabe)
            {
                allDevices[i].gameObject.SetActive(false);
            }
        }
    }

    void Update()
    {

    }
}
<file_sep>/Assets/Scripts/Game/DeviceComponentHelper.cs
﻿using UnityEngine;
using System.Collections;

public class DeviceComponentHelper : MonoBehaviour
{
    public enum ComponentType
    {
        dvi,
        hdmi,
        midi,
        mini_dvi,
        rca,
        s_video,
        scart,
        thunderbolt,
        trs,
        trs35mm,
        vga,
        xlr
    }

    public enum DeviceType
    {
        camCorder,
        cassete,
        computer_crt,
        crt,
        crt_plus,
        dibox,
        dreamweaver,
        dvd1,
        dvd2,
        dvd3,
        funstation,
        handycam,
        hi8,
        minidisc,
        minidisc_player,
        minidv,
        tv_4k,
        tv_lcd,
        tv_plasma,
        tv_tft,
        vhs1,
        vhs2,
        vhs3,
        vhs_camera,
        vhs_tape,
        walkman,
        wiird,
        zbox
    }

    public static string ComponentName(ComponentType component)
    {
        switch (component)
        {
            case ComponentType.dvi:
                return "dvi";
            case ComponentType.hdmi:
                return "hdmi";
            case ComponentType.midi:
                return "midi";
            case ComponentType.mini_dvi:
                return "mini-dvi";
            case ComponentType.rca:
                return "rca";
            case ComponentType.s_video:
                return "s-video";
            case ComponentType.scart:
                return "scart";
            case ComponentType.thunderbolt:
                return "thunderbolt";
            case ComponentType.trs:
                return "trs";
            case ComponentType.trs35mm:
                return "trs-35mm";
            case ComponentType.vga:
                return "vga";
            case ComponentType.xlr:
                return "xlr";
            default:
                return "";
        }
    }

    public static string DeviceName(DeviceType device)
    {
        switch(device)
        {
            case DeviceType.camCorder:
                return "cam recorder";
            case DeviceType.cassete:
                return "cassete";
            case DeviceType.computer_crt:
                return "computer crt";
            case DeviceType.crt:
                return "crt";
            case DeviceType.crt_plus:
                return "crt plus";
            case DeviceType.dibox:
                return "di box";
            case DeviceType.dreamweaver:
                return "dreamweaver";
            case DeviceType.dvd1:
                return "dvd 1";
            case DeviceType.dvd2:
                return "dvd 2";
            case DeviceType.dvd3:
                return "dvd 3";
            case DeviceType.funstation:
                return "funstation";
            case DeviceType.handycam:
                return "handycam";
            case DeviceType.hi8:
                return "hi8";
            case DeviceType.minidisc:
                return "minidisc";
            case DeviceType.minidisc_player:
                return "minisc player";
            case DeviceType.minidv:
                return "minidv";
            case DeviceType.tv_4k:
                return "tv 4k";
            case DeviceType.tv_lcd:
                return "tv lcd";
            case DeviceType.tv_plasma:
                return "tv plasma";
            case DeviceType.tv_tft:
                return "tv tft";
            case DeviceType.vhs1:
                return "vhs 1";
            case DeviceType.vhs2:
                return "vhs 2";
            case DeviceType.vhs3:
                return "vhs 3";
            case DeviceType.vhs_camera:
                return "vhs camera";
            case DeviceType.vhs_tape:
                return "vhs tape";
            case DeviceType.walkman:
                return "walkman";
            case DeviceType.wiird:
                return "wiird";
            case DeviceType.zbox:
                return "zbox";
            default:
                return "";
        }
    }

}
<file_sep>/Assets/Scripts/Game/MontageManager.cs
﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
using UnityEngine.SceneManagement;

//TODO: take care of game logic and money being made (get thumbs up from cable entrance.cs
public class MontageManager : MonoBehaviour
{
    [Header("Timer")]
    public Text timer;
    [Tooltip("in seconds")]
    private float _timeInterval;

    [Header("Pop-Ups")]
    public GameObject popUpBackground;
    public CanvasGroup endGamePopUp;

    private float _moneyMade = 0;

    void Start()
    {
        _timeInterval = GameManager.TimerState;
        StartCoroutine(Timer());
    }

    private IEnumerator Timer()
    {
        while (_timeInterval >= 0)
        {
            _timeInterval -= Time.deltaTime;
            timer.text = Mathf.Floor(_timeInterval / 60).ToString("00") + (_timeInterval % 60).ToString(":00");
            yield return null;
        }

        ShowEndGame();
    }

    private void ShowEndGame()
    {
        if (popUpBackground != null)
        {
            StopAllCoroutines();
            popUpBackground.SetActive(true);

            endGamePopUp.alpha = 1;
            endGamePopUp.interactable = true;
            endGamePopUp.blocksRaycasts = true;

            _moneyMade = GameManager.numberOfConections * 10;

            endGamePopUp.transform.GetChild(1).GetComponent<Text>().text = "You made like " + _moneyMade + "$";

            timer.enabled = false;


            GameManager.SetMoney(_moneyMade);
            GameManager.ResetSelectedItens();

            GameManager.numberOfConections = 0;
        }
    }

    public void GoToMarket()
    {
        SceneManager.LoadScene("market");
    }

    public void GoToStoreFront()
    {
        StopAllCoroutines();
        GameManager.TimerState = _timeInterval;

        SceneManager.LoadScene("store-front");
    }

    public void GoToDevicePickUp()
    {
        StopAllCoroutines();
        GameManager.TimerState = _timeInterval;
        SceneManager.LoadScene("store-back-devices");
    }

    public void GoToAssembly()
    {
        StopAllCoroutines();
        GameManager.TimerState = _timeInterval;
        SceneManager.LoadScene("store-back-building");
    }
}
<file_sep>/Assets/Scripts/Cables/UI/ShopUIManager.cs
﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class ShopUIManager : MonoBehaviour {

    public Text moneyText;
    public float money;

	void Start () {
        moneyText.text = GameManager.GetTotalMoney().ToString();
        money = GameManager.GetTotalMoney();
	}

    public void UpdateMoney(float price)
    {
        money -= price;
        moneyText.text = money.ToString();

        GameManager.SetMoney(money);
    }

    public void GoBack()
    {
        SceneManager.LoadScene("store-front");
        GameManager.GetAllCables();
    }
}
<file_sep>/Assets/Scripts/Cables/UI/FrontStoreUIManager.cs
﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class FrontStoreUIManager : MonoBehaviour {

    public GameObject briefingUI;
    public Image firstDevice;
    public Image secondDevice;
    public Image entrance;
    public Text price;
    public Text totalTime;
    
    private Image _popUpBackground;
    private Briefing _briefing;

	void Start () {

        _briefing = GameManager.GetRandomBriefing();

        _popUpBackground = GameObject.Find("PopUpBackground").GetComponent<Image>();

        GameManager.GetSetBriefing = _briefing;
        SetBriefingUI();
	}

    private void SetBriefingUI()
    {
        firstDevice.sprite = _briefing.firstDevice;
        secondDevice.sprite = _briefing.secondDevice;
        entrance.sprite = _briefing.entrance;
        price.text = _briefing.price.ToString();
        totalTime.text = Mathf.Floor(_briefing.totalTime / 60).ToString("00") + (_briefing.totalTime % 60).ToString(":00");
    }
	
    public void GotItBtn()
    {
        GameManager.TimerState = _briefing.totalTime;

        StartCoroutine(WaitForAnimation(briefingUI.GetComponent<CanvasGroup>()));
        StartCoroutine(Fade(_popUpBackground));
    }

    private IEnumerator WaitForAnimation(CanvasGroup cg)
    {
        Animation anim = cg.gameObject.GetComponent<Animation>();

        anim.Play();
        cg.interactable = false;
        cg.blocksRaycasts = false;

        while (anim.isPlaying)
        {
            yield return null;
        }

        SceneManager.LoadScene("store-back-cables");
        DestroyObject(cg.gameObject);
    }

    private IEnumerator Fade(Image background)
    {
        while(background.color.a > 0)
        {
            background.color = new Color(background.color.r, background.color.g, background.color.b, background.color.a - Time.deltaTime*0.5f);
            yield return null;
        }
    }
}
<file_sep>/Assets/Scripts/Cables/CableEntrance.cs
﻿using UnityEngine;
using System.Collections;

public class CableEntrance : MonoBehaviour
{
    public DeviceComponentHelper.ComponentType componentType;
    public Entrance entranceType;
    public enum Entrance
    {
        inEntrance,
        outEntrance,
    }

    private string _componentName;

    void Awake()
    {
        _componentName = DeviceComponentHelper.ComponentName(componentType);
    }

    void Update()
    {

    }

    void OnTriggerEnter2D(Collider2D col)
    {
        GameObject colliderObj = col.gameObject;

        if (colliderObj.tag == EntranceType())
        {
            if (colliderObj.GetComponent<DragCable>().canDrag && colliderObj.GetComponent<CableComponent>() != null && DeviceComponentHelper.ComponentName(colliderObj.GetComponent<CableComponent>().componentType) == _componentName)
            {
                //TODO: something saying good job
                //TODO: something about the game logic that is missing... oh ya send info to montage manager
                GameManager.numberOfConections += 1;
                colliderObj.GetComponent<DragCable>().HasConnection();
            }

            else
            {
                //TODO: something happens
            }
        }
    }

    private string EntranceType()
    {
        switch (entranceType)
        {
            case Entrance.inEntrance:
                return "cable-in";

            case Entrance.outEntrance:
                return "cable-out";

            default:
                return "";
        }
    }

}
<file_sep>/Assets/Scripts/Game/GameManager.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public static class GameManager
{
    private static Dictionary<string, CableComponent> _cableList = new Dictionary<string, CableComponent>();
    private static Dictionary<string, DeviceComponent> _deviceList = new Dictionary<string, DeviceComponent>();
    
    private static List<GameObject> _cablePrefabs;
    private static List<GameObject> _devicePrefabs;

    private static Briefing _briefing;

    private static GameObject _firsDevicePrefab;
    private static GameObject _secondDevicePrefab;

    private static List<GameObject> _selectedCables;
    private static List<GameObject> _selectedDevices;

    private static float _totalMoney = 10;
    private static float _timerState = 30;

    public static int numberOfConections = 0;

    static GameManager()
    {
        GetAllCables();
        BriefingManager.GetAllBriefings();
    }

    public static void SetMoney(float value)
    {
        _totalMoney = value;
    }

    public static float GetTotalMoney()
    {
        return _totalMoney;
    }

    public static List<GameObject> GetSelectedCables()
    {
        return _selectedCables;
    }

    public static List<GameObject> GetSelectedDevices()
    {
        return _selectedDevices;
    }

    public static void AddCableSelection(CableComponent component)
    {
        if (_selectedCables == null || _selectedCables.Count == 0)
        {
            _selectedCables = new List<GameObject>();
        }

        foreach (GameObject g in _cablePrefabs)
        {
            if ((DeviceComponentHelper.ComponentName(g.GetComponentInChildren<CableComponent>(true).componentType) ==
                DeviceComponentHelper.ComponentName(component.componentType)) && !_selectedCables.Contains(g))
            {
                _selectedCables.Add(g);
                break;
            }
        }
    }

    public static void AddDeviceSelection(DeviceComponent component)
    {
        if (_selectedDevices == null || _selectedDevices.Count == 0)
        {
            _selectedDevices = new List<GameObject>();
        }

        foreach (GameObject g in _devicePrefabs)
        {
            if ((DeviceComponentHelper.DeviceName(g.GetComponentInChildren<DeviceComponent>(true).deviceType) ==
                DeviceComponentHelper.DeviceName(component.deviceType)) && !_selectedDevices.Contains(g))
            {
                _selectedDevices.Add(g);
                break;
            }
        }
    }

    private static void SetCablePrefabList()
    {
        _cablePrefabs = new List<GameObject>();
        _cablePrefabs.AddRange(Resources.LoadAll<GameObject>("Components/Cables"));
    }

    private static void SetDevicePrefabList()
    {
        _devicePrefabs = new List<GameObject>();
        _devicePrefabs.AddRange(Resources.LoadAll<GameObject>("Components/Devices"));
    }

    public static Dictionary<string, CableComponent> GetAllCables()
    {
        SetCablePrefabList();

        foreach (GameObject g in _cablePrefabs)
        {
            CableComponent componentComponent = g.GetComponentInChildren<CableComponent>(true);
            if (!_cableList.ContainsKey(DeviceComponentHelper.ComponentName(componentComponent.componentType)))
            {
                _cableList.Add(DeviceComponentHelper.ComponentName(componentComponent.componentType), componentComponent);
            }
        }

        return _cableList;
    }

    public static Dictionary<string, DeviceComponent> GetAllDevices()
    {
        SetDevicePrefabList();

        foreach (GameObject g in _devicePrefabs)
        {
            DeviceComponent componentComponent = g.GetComponentInChildren<DeviceComponent>(true);
            if (!_deviceList.ContainsKey(DeviceComponentHelper.DeviceName(componentComponent.deviceType)))
            {
                _deviceList.Add(DeviceComponentHelper.DeviceName(componentComponent.deviceType), componentComponent);
            }
        }

        return _deviceList;
    }

    public static void ResetSelectedItens()
    {
        _selectedCables = new List<GameObject>();
        _selectedDevices = new List<GameObject>();
    }

    public static List<GameObject> GetAllCablesGameObjects()
    {
        SetCablePrefabList();

        return _cablePrefabs;
    }

    public static List<GameObject> GetAllDeviceGameObjects()
    {
        SetDevicePrefabList();

        return _devicePrefabs;
    }

    public static List<GameObject> GetAllAvailableCables()
    {
        List<GameObject> list = new List<GameObject>();

        foreach (CableComponent c in _cableList.Values)
        {
            if (c.IsAvailabe)
            {
                list.Add(c.gameObject);
            }
        }

        return list;
    }

    public static List<GameObject> GetAllAvailableDevices()
    {
        List<GameObject> list = new List<GameObject>();

        foreach (DeviceComponent c in _deviceList.Values)
        {
            if (c.IsAvailabe)
            {
                list.Add(c.gameObject);
            }
        }

        return list;
    }

    public static CableComponent GetCableComponent(string key)
    {
        return _cableList[key];
    }

    public static DeviceComponent GetDeviceComponent(string key)
    {
        return _deviceList[key];
    }

    public static void UpdateCableAvailability(string key, bool available)
    {
        _cableList[key].IsAvailabe = available;
    }

    public static void UpdateDeviceAvailability(string key, bool available)
    {
        _deviceList[key].IsAvailabe = available;
    }

    public static Briefing GetSetBriefing
    {
        get { return _briefing; }
        set { _briefing = value; }
    }

    public static Briefing GetRandomBriefing()
    {
        return BriefingManager.GetRandomBriefing();
    }

    public static float TimerState
    {
        get { return _timerState; }
        set { _timerState = value; }
    }
}
<file_sep>/Assets/Scripts/Briefing/BriefingInfo.cs
﻿using UnityEngine;
using System.Collections;

public class BriefingInfo : MonoBehaviour {

    public Sprite firstDevice;
    public Sprite secondDevice;
    public Sprite entrance;
    public float price;
    public float totalTime;

    [Header("Prefabs")]
    public GameObject firstDevicePrefab;
    public GameObject secondDevicePrefab;

    private Briefing _briefing;
    
    public Briefing GetBriefing()
    {
        _briefing = new Briefing(firstDevice, secondDevice, entrance, price, totalTime, firstDevicePrefab, secondDevicePrefab);
        return _briefing;
    }
}

public class Briefing
{
    public Sprite firstDevice;
    public Sprite secondDevice;
    public Sprite entrance;
    public float price;
    public float totalTime;

    public GameObject firstDevicePrefab;
    public GameObject secondDevicePrefab;

    public Briefing(Sprite firstDevice, Sprite secondDevice, Sprite entrance, float price, float totalTime, GameObject firstDevicePrefab, GameObject secondDevicePrefab)
    {
        this.firstDevice = firstDevice;
        this.secondDevice = secondDevice;
        this.entrance = entrance;
        this.price = price;
        this.totalTime = totalTime;

        this.firstDevicePrefab = firstDevicePrefab;
        this.secondDevicePrefab = secondDevicePrefab;
    }
}
<file_sep>/Assets/Scripts/Cables/DragCable.cs
﻿using UnityEngine;
using System.Collections;
using System;

[RequireComponent(typeof(CableComponent))]
public class DragCable : MonoBehaviour
{
    public GameObject childJoint;
    public DragCable otherEnd;
    public float endDistances = 3;
    [HideInInspector]
    public bool canDrag = true;

    private bool _drag;
    private Rigidbody2D _myRigidbody;
    private bool _wasKinematic;

    void Start()
    {
        _myRigidbody = GetComponent<Rigidbody2D>();
        _wasKinematic = _myRigidbody.isKinematic;
    }

    void OnMouseDrag()
    {
        if (canDrag && otherEnd.canDrag)
        {
            DragFunction();
        }

        else if (!otherEnd.canDrag && canDrag && Vector2.Distance(transform.position, otherEnd.transform.position) < endDistances)
        {
            DragFunction();
        }
    }

    void FixedUpdate()
    {
        if (_drag)
        {
            transform.rotation = childJoint.transform.rotation;
        }
    }

    public void HasConnection()
    {
        canDrag = false;
    }

    void OnMouseDown()
    {
        _drag = true;
        _myRigidbody.isKinematic = true;

        if (otherEnd != null && otherEnd.canDrag)
            otherEnd.DisableKinemactic(_drag);
    }

    void OnMouseUp()
    {
        if (_drag == true)
        {
            _myRigidbody.isKinematic = _wasKinematic;
        }

        if (otherEnd != null && !otherEnd.canDrag && Vector2.Distance(transform.position, otherEnd.transform.position) >= endDistances)
        {
            _myRigidbody.isKinematic = false;
        }

        _drag = false;
    }

    void DragFunction()
    {
        // We are converting a 2D mouse coordinate to 3D
        float distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
        Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));

        _myRigidbody.position = new Vector3(pos_move.x, pos_move.y, pos_move.z);
        transform.rotation = childJoint.transform.rotation;
    }

    public void DisableKinemactic(bool isDragging)
    {
        _myRigidbody.isKinematic = !isDragging;
    }
}<file_sep>/Assets/Splash.cs
﻿using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class Splash : MonoBehaviour {
    
    void Start()
    {
        StartCoroutine(FadeAndLoad());
    }

    private IEnumerator FadeAndLoad()
    {
        float timer = 2f;

        while(timer > 0)
        {
            timer -= Time.deltaTime;
            yield return null;
        }

        SceneManager.LoadScene(1);
    }
	
}
<file_sep>/Assets/Scripts/Devices/DeviceComponent.cs
﻿using UnityEngine;
using System.Collections;

public class DeviceComponent : MonoBehaviour {

    public DeviceComponentHelper.DeviceType deviceType;
    public string deviceName;
    public Sprite image;
    public float price;
    public Sprite firstEntrance;
    public Sprite secondEntrance;

    public bool _isAvailable;

    public bool IsAvailabe
    {
        get { return _isAvailable; }
        set { _isAvailable = value; }
    }

    public float GetPrice()
    {
        return price;
    }
}
<file_sep>/Assets/Scripts/Store/ShopItem.cs
﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

//THIS WHOLE THING IS A MESS
public class ShopItem : MonoBehaviour
{
    [Header("Children")]
    public Text nameObject;
    public Image imageObject;
    public Image firstEntrance;
    public Image secondEntrance;
    public Text priceObject;
    public Button buyButton;

    public GameObject itemPrefab;
    private CableComponent cableComponent;
    private DeviceComponent deviceComponent;

    private ShopUIManager _uiManager;

    private bool _isCable;

    void Awake()
    {
        _uiManager = GameObject.Find("Canvas").GetComponent<ShopUIManager>();
    }

    public void SetCable(CableComponent itemComponent)
    {
        _isCable = true;
        cableComponent = itemComponent;

        nameObject.text = cableComponent.cableName;
        priceObject.text = cableComponent.price.ToString() + " $";

        imageObject.sprite = cableComponent.image;
        firstEntrance.sprite = cableComponent.firstEntrance;

        if (cableComponent.secondEntrance != null)
        {
            secondEntrance.sprite = cableComponent.secondEntrance;
        }
        else
        {
            secondEntrance.gameObject.SetActive(false);
        }

        if (cableComponent.IsAvailabe)
        {
            buyButton.interactable = false;
        }
    }

    public void SetDevice(DeviceComponent itemComponent)
    {
        _isCable = false;

        deviceComponent = itemComponent;

        nameObject.text = deviceComponent.deviceName;
        priceObject.text = deviceComponent.price.ToString() + " $";

        imageObject.sprite = deviceComponent.image;
        firstEntrance.sprite = deviceComponent.firstEntrance;

        if (deviceComponent.secondEntrance != null)
        {
            secondEntrance.sprite = deviceComponent.secondEntrance;
        }
        else
        {
            secondEntrance.gameObject.SetActive(false);
        }

        if (deviceComponent.IsAvailabe)
        {
            buyButton.interactable = false;
        }
    }

    public void OnBuy()
    {
        if (_isCable)
        {
            if (_uiManager.money >= cableComponent.price)
            {
                if (cableComponent != null)
                {
                    cableComponent.IsAvailabe = true;
                }

                buyButton.interactable = false;
                _uiManager.UpdateMoney(cableComponent.price);

                GameManager.UpdateCableAvailability(DeviceComponentHelper.ComponentName(cableComponent.componentType), true);
            }
        }

        else
        {
            if (_uiManager.money >= deviceComponent.price)
            {
                if (deviceComponent != null)
                {
                    deviceComponent.IsAvailabe = true;
                }

                buyButton.interactable = false;
                _uiManager.UpdateMoney(deviceComponent.price);

                GameManager.UpdateCableAvailability(DeviceComponentHelper.DeviceName(deviceComponent.deviceType), true);
            }
        }
    }
}
<file_sep>/Assets/Scripts/Cables/CableManager.cs
﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;

public class CableManager : MonoBehaviour
{
    public CableComponent[] allCables;
    public Dictionary<string, CableComponent> availableComponents;

    void Start()
    {
        availableComponents = GameManager.GetAllCables();

        SetAvailableCables();
    }

    private void SetAvailableCables()
    {
        for (int i = 0; i < allCables.Length; i++)
        {
            if (!availableComponents[DeviceComponentHelper.ComponentName(allCables[i].componentType)].IsAvailabe)
            {
                allCables[i].gameObject.SetActive(false);
            }
        }
    }

    void Update()
    {

    }
}
