Esempio n. 1
0
        void ReleaseDesignerOutlets()
        {
            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (OnSwitch != null)
            {
                OnSwitch.Dispose();
                OnSwitch = null;
            }

            if (TimeLabel != null)
            {
                TimeLabel.Dispose();
                TimeLabel = null;
            }

            if (RepeatLabel != null)
            {
                RepeatLabel.Dispose();
                RepeatLabel = null;
            }
        }
Esempio n. 2
0
 void onSwitchEvent(CurvySplineMoveEventArgs e)
 {
     OnSwitch.Invoke(e);
     if (e.Cancel)
     {
         mSwitchEventArgs = null;
     }
 }
Esempio n. 3
0
 public void Switch()
 {
     Value ^= true;
     if (Value)
     {
         bgColor = new Color(200, 255, 200);
     }
     else
     {
         bgColor = new Color(255, 200, 200);
     }
     Recalculate();
     OnSwitch?.Invoke(this, Value);
 }
Esempio n. 4
0
        private void Update()
        {
            Horizontal = Input.GetAxis("Horizontal");

            if (Input.GetButtonDown("Jump"))
            {
                OnJump?.Invoke();
            }

            if (Input.GetButtonDown("Switch"))
            {
                OnSwitch?.Invoke();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Refresh the controller and advance position
        /// </summary>
        public override void Refresh()
        {
            if (IsSwitching)
            {
                mSwitchEventArgs.Delta = Mathf.Clamp01((Time.time - mSwitchStartTime) / mSwitchDuration);
                if (OnSwitch.HasListeners())
                {
                    onSwitchEvent(mSwitchEventArgs);
                }
                else
                {
                    mSwitchEventArgs.Data = mSwitchEventArgs.Delta;
                }
            }
            base.Refresh();

            if (IsSwitching)
            {
                Vector3 targetPos;
                Vector3 targetTan;
                Vector3 targetUp;
                getInterpolatedSourcePosition(mSwitchEventArgs.Spline, mSwitchEventArgs.TF, out targetPos, out targetTan, out targetUp);

                if (Space == Space.Self)
                {
                    Transform.localPosition = Vector3.Lerp(Transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);
                }
                else
                {
                    Transform.position = Vector3.Lerp(Transform.localPosition, targetPos, (float)mSwitchEventArgs.Data);
                }

                if (OrientationMode != OrientationModeEnum.None)
                {
                    //transform.localRotation = Quaternion.Lerp(transform.localRotation, GetRotation(tan, up), 1 - OrientationDamping);
                }

                if (mSwitchEventArgs.Delta == 1)
                {
                    Spline           = mSwitchEventArgs.Spline;
                    RelativePosition = mSwitchEventArgs.TF;
                    mSwitchEventArgs = null;
                }
            }
        }
Esempio n. 6
0
        public MiHome(string gatewayPassword = null, string gatewaySid = null)
        {
            _gatewaySid = gatewaySid;

            _commandsToActions = new Dictionary <ResponseCommandType, Action <ResponseCommand> >
            {
                { ResponseCommandType.GetIdListAck, DiscoverGatewayAndDevices },
                { ResponseCommandType.ReadAck, ProcessReadAck },
                { ResponseCommandType.Report, ProcessReport },
                { ResponseCommandType.Hearbeat, ProcessHeartbeat },
            };

            _deviceEvents = new Dictionary <Type, Action <MiHomeDevice> >
            {
                { typeof(AqaraCubeSensor), x => OnAqaraCubeSensor?.Invoke(this, x as AqaraCubeSensor) },
                { typeof(AqaraMotionSensor), x => OnAqaraMotionSensor?.Invoke(this, x as AqaraMotionSensor) },
                { typeof(AqaraOpenCloseSensor), x => OnAqaraOpenCloseSensor?.Invoke(this, x as AqaraOpenCloseSensor) },
                { typeof(DoorWindowSensor), x => OnDoorWindowSensor?.Invoke(this, x as DoorWindowSensor) },
                { typeof(MotionSensor), x => OnMotionSensor?.Invoke(this, x as MotionSensor) },
                { typeof(SmokeSensor), x => OnSmokeSensor?.Invoke(this, x as SmokeSensor) },
                { typeof(SocketPlug), x => OnSocketPlug?.Invoke(this, x as SocketPlug) },
                { typeof(Switch), x => OnSwitch?.Invoke(this, x as Switch) },
                { typeof(ThSensor), x => OnThSensor?.Invoke(this, x as ThSensor) },
                { typeof(WaterLeakSensor), x => OnWaterLeakSensor?.Invoke(this, x as WaterLeakSensor) },
                { typeof(WeatherSensor), x => OnWeatherSensor?.Invoke(this, x as WeatherSensor) },
                { typeof(WiredDualWallSwitch), x => OnWiredDualWallSwitch?.Invoke(this, x as WiredDualWallSwitch) },
                { typeof(WirelessDualWallSwitch), x => OnWirelessDualWallSwitch?.Invoke(this, x as WirelessDualWallSwitch) },
            };

            _transport = new UdpTransport(gatewayPassword);

            _miHomeDeviceFactory = new MiHomeDeviceFactory(_transport);

            _receiveTask = Task.Run(() => StartReceivingMessagesAsync(_cts.Token), _cts.Token);

            _transport.SendCommand(new DiscoverGatewayCommand());
        }
Esempio n. 7
0
 public void Switch(Mode.Config config)
 {
     OnSwitch?.Invoke(config);
 }