Beispiel #1
0
    public void OnClickComponentSlot(ComponentHolder.ComponentSlot _slot)
    {
        // float _efficiency = 0;
        // ComponentObject _pickedUpComponent = null;
        // if (ObjectPlacing.GetObjectToPlace() != null) {
        //  _pickedUpComponent = ObjectPlacing.GetObjectToPlace().GetComponent<ComponentObject> ();
        //  if (_pickedUpComponent == null) {
        //      return;
        //  }
        //  if (!ComponentHolder.DoesComponentFitInSlot(_slot, _pickedUpComponent, out _efficiency)) {
        //      return;
        //  }
        // }

        // detach component from slot
        CanInspect _fromSlot = null;

        if (_slot.HeldComponent != null)
        {
            _fromSlot               = _slot.HeldComponent.GetComponent <CanInspect>();
            _slot.HeldComponent     = null;
            _slot.CurrentEfficiency = 0;
        }

        // pick up component and put the former PickedUpObject in the slot
        // CanInspect _formerPickedUpObject;
        // if (ObjectPlacing.TrySwitchComponents(_fromSlot, _slot.Owner.MyTileObject, true, /*true, */out _formerPickedUpObject)) {
        //  if (_formerPickedUpObject == null)
        //      return;

        //  _slot.HeldComponent = _formerPickedUpObject.GetComponent<ComponentObject>();
        //  _slot.CurrentEfficiency = _efficiency;
        // }
    }
Beispiel #2
0
    public void UpdateButtonGraphics(CanInspect _io)
    {
        int _index = currentInfoWindows.FindIndex(x => x.User == _io);

        if (_index == -1 || currentInfoWindows[_index].Window.UI_ComponentSlots.Length == 0)
        {
            return;
        }

        UIInfoWindow _window = currentInfoWindows[_index].Window;
        Button       _button = null;

        ComponentHolder.ComponentSlot _slot = null;
        for (int i = 0; i < _window.UI_ComponentSlots.Length; i++)
        {
            _button = _window.UI_ComponentSlots[i];
            _slot   = currentComponentHolder.ComponentSlots[i];

            if (_slot.HeldComponent == null)
            {
                _button.GetComponent <Image>().color = Color.black;
                continue;
            }
            if (_slot.HeldComponent._Current_ == 0)
            {
                _button.GetComponent <Image>().color = Color.red;
                continue;
            }
            if (_slot.HeldComponent.TypeID != _slot.SlotTypeID)
            {
                _button.GetComponent <Image>().color = Color.yellow;
                continue;
            }

            // everything's fine
            _button.GetComponent <Image>().color = Color.green;
        }
    }