예제 #1
0
    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);
            }
        }
    }
 private void SetAvailableDevices()
 {
     for (int i = 0; i < allDevices.Length; i++)
     {
         if (!availableComponents[DeviceComponentHelper.DeviceName(allDevices[i].deviceType)].IsAvailabe)
         {
             allDevices[i].gameObject.SetActive(false);
         }
     }
 }
예제 #3
0
    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);
    }
예제 #4
0
    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);
    }
예제 #5
0
    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;
            }
        }
    }
    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
            }
        }
    }
 void Awake()
 {
     _componentName = DeviceComponentHelper.ComponentName(componentType);
 }