예제 #1
0
 public BulbColor(BulbColor bulbColor)
 {
     Red       = bulbColor.Red;
     Green     = bulbColor.Green;
     Blue      = bulbColor.Blue;
     WarmWhite = bulbColor.WarmWhite;
     ColdWhite = bulbColor.ColdWhite;
 }
예제 #2
0
        public ColoredGarland(int garlandLength) : base(garlandLength)
        {
            int bulbColors = Enum.GetValues(typeof(BulbColor)).Length;

            for (int i = 0; i < garlandLength; i++)
            {
                BulbColor color = (BulbColor)(i % bulbColors);
                _garland.Add(new ColoredBulb(color));
            }
        }
예제 #3
0
        public void DeviceActivate(BulbColor color, int channel)
        {
            purifier.Power();

            bulb.SetColor(color);

            plug.TurnOn();

            sensor.GetTemperature();
            sensor.GetHumiditye();

            tv.PlayChannel(channel);
        }
예제 #4
0
    void Start()
    {
        _moduleId = _moduleIdCounter++;
        _isSolved = false;

        if (Rnd.Range(0, 2) == 0)
        {
            // Swap the buttons! Fun fun
            var p = IFace.localPosition;
            IFace.localPosition = OFace.localPosition;
            OFace.localPosition = p;
            var t = ButtonO;
            ButtonO = ButtonI;
            ButtonI = t;
        }

        var colorIndex = Rnd.Range(0, _bulbColors.Length);

        _bulbColor = (BulbColor)colorIndex;
        _opaque    = Rnd.Range(0, 2) == 0;
        Filament.SetActive(!_opaque);
        _initiallyOn         = Rnd.Range(0, 2) == 0;
        Glass.material.color = _bulbColors[colorIndex].WithAlpha(_opaque ? 1f : .55f);
        Light1.color         = Light2.color = _haloColors[colorIndex].WithAlpha(_opaque ? 1f : .55f);
        _stage                = -1;
        _isBulbUnscrewed      = false;
        _correctButtonPresses = "";

        Debug.LogFormat("[The Bulb #{3}] Bulb is {0}, {1} and {2}.", _bulbColor, _opaque ? "opaque" : "see-through", _initiallyOn ? "on" : "off", _moduleId);

        ButtonO.OnInteract += delegate { ButtonO.AddInteractionPunch(); HandleButtonPress(o: true); return(false); };
        ButtonI.OnInteract += delegate { ButtonI.AddInteractionPunch(); HandleButtonPress(o: false); return(false); };
        Bulb.OnInteract    += delegate { HandleBulb(); return(false); };

        Module.OnActivate += delegate
        {
            if (_isBulbUnscrewed || _isScrewing)
            {
                _wasOnAtUnscrew = _initiallyOn;
            }
            else
            {
                TurnLights(on: _initiallyOn);
            }
            _stage = 1;
        };
    }
예제 #5
0
    public async Task GetState()
    {
        try
        {
            byte[] getStatusMessage = new byte[] {
                0x81,
                0x8A,
                0x8B,
                0x96
            };

            byte[] response = Transmit.SendMessage(IpAddress, getStatusMessage, false, true);


            byte persistance   = response[0];
            byte bulbType      = response[1];
            byte powerState    = response[2];
            byte mode          = response[3];
            byte presetDelay   = response[5];
            byte red           = response[6];
            byte green         = response[7];
            byte blue          = response[8];
            byte warmWhite     = response[9];
            byte versionNumber = response[10];
            byte coldWhite     = response[11];

            bulbColor = new BulbColor(red, green, blue, warmWhite, coldWhite);
            bool isOn         = (powerState == 0x24 ? true : false);
            bool isRGBWW      = (bulbType == 0x35 ? true : false);
            bool isPersistant = (persistance == 0x31 ? true : false);

            IsOn         = isOn;
            IsRGBWW      = isRGBWW;
            IsPersistant = isPersistant;
        }
        catch
        {
        }
    }
예제 #6
0
 public void TurnOn(BulbColor color = BulbColor.Cold, int channel = 0)
 {
     facade.DeviceActivate(color, 0);
 }
예제 #7
0
 public ColoredBulb(BulbColor color)
 {
     BulbColor = color;
 }
예제 #8
0
 public void SetColor(BulbColor color)
 {
     this.color = color;
 }
예제 #9
0
    public BulbColor GetBulbColor()
    {
        BulbColor bulbColors = this.bulbColor;

        return(bulbColors);
    }
예제 #10
0
 protected abstract void DeviceActivate(BulbColor color, int channel);