void StartMover() { if (moving) { return; } moving = true; Vector3 f = GetPointAtPosition(path[pathPosition]); Vector3 t = GetPointAtPosition(path[pathPosition + 1]); pointPosition = path[pathPosition + 1]; Vector3 next = pathPosition + 2 < path.Count - 1 ? GetPointAtPosition(path[pathPosition + 2]) : new Vector3(-1, -1, -1); rotator.InitMovement(f, t, next); pathPosition++; float speed = 2f; float distance = Vector3.Distance(f, t); float time = distance / speed; Co2.StartCoroutine( time, (float p) => { Move(p, f, t); }, OnArriveAtPoint ); }
/// <summary> /// Initializes the ModuleClient and sets up the callback to receive /// messages containing temperature information /// </summary> static async Task Init() { MqttTransportSettings mqttSetting = new MqttTransportSettings(TransportType.Mqtt_Tcp_Only); ITransportSettings[] settings = { mqttSetting }; // Open a connection to the Edge runtime IoTHubModuleClient = await ModuleClient.CreateFromEnvironmentAsync(settings); await IoTHubModuleClient.OpenAsync(); Console.WriteLine("IoT Hub module client initialized."); // Register callback to be called when a message is received by the module //await ioTHubModuleClient.SetInputMessageHandlerAsync("input1", PipeMessage, ioTHubModuleClient); //initialize Raspberry _raspberryPins = new Pins(); _raspberryPins.ConnectGpio(); _raspberryPins.LoopGpioPins(); _paradox1738 = new Paradox1738(); _paradox1738.ParadoxSecurity(); _paradox1738.IRSensorsReading(); //Receive Netatmo data _receiveNetatmoData = new ReceiveNetatmoData(); _receiveNetatmoData.ReceiveData(); //read from ome temperature sensors _homeTemperature = new HomeTemperature(); _homeTemperature.ReadTemperature(); //Starting schedulers _co2Scheduler = new Co2(); _co2Scheduler.CheckCo2Async(); _saunaHeating = new SaunaHeating(); _saunaHeating.CheckHeatingTime(); _heatingScheduler = new Heating(); _heatingScheduler.ReduceHeatingSchedulerAsync(); //Receive IoTHub commands _receiveData = new ReceiveData(); _receiveData.ReceiveCommandsAsync(); //query WiFiProbes _wiFiProbes = new WiFiProbes(); _wiFiProbes.QueryWiFiProbes(); //shelly's TelemetryDataClass.isOutsideLightsOn = await Shelly.GetShellyState(Shelly.OutsideLight); SomeoneAtHome.CheckLightStatuses(); //Send data to IoTHub _sendData = new SendTelemetryData(); _sendData.SendTelemetryEventsAsync(); }
public void OnEnable() { // This is stupid but necessary because the scale comes in all weird RectTransform.localScale = Vector3.zero; Co2.WaitForFixedUpdate(() => { RectTransform.localScale = Vector3.one; }); }
public void Stop () { State = TaskState.Idle; performing = false; perform = false; Co2.StopCoroutine (SetProgress); if (acceptTask != null) acceptTask.Binder.Remove (this, settings.BindCapacity); }
public void Swell(float duration, bool repeat = false) { Co2.StartCoroutine(duration, (float p) => { Fill = Mathf.Sin(Mathf.PI * p); }, () => { if (repeat) { Swell(duration, true); } }); }
void GiveWarning() { if (warningCount < warningMax) { warningCount++; Status = LoanStatus.Late; } else { LoanManager.Defaulted = true; Status = LoanStatus.Defaulted; Co2.WaitForFixedUpdate(() => { Group.Remove(this); }); } }
void StartOnEnable () { if (!Enabled) { float time = Duration; #if QUARTER_TIME time *= 0.25f; #endif Co2.WaitForSeconds (time, () => { if (!perform) return; if (!Start ()) { StartOnEnable (); } }); } }
/// <summary> /// Repeatedly invokes a function as long as the condition is met /// </summary> /// <param name="time">(optional) The initial delay before invoking begins</param> /// <param name="rate">The delay between invoke calls</param> /// <param name="condition">The expression to evaluate. When 'condition' is false, the coroutine stops.</param> /// <param name="onEnd">(optional) A function to run after the coroutine has finished</param> public static void InvokeWhileTrue(float time, float rate, Func <bool> condition, Action onInvoke, Action onEnd = null) { float duration = time > 0f ? time : rate; Co2.WaitForSeconds(duration, () => { if (condition()) { onInvoke(); InvokeWhileTrue(0f, rate, condition, onInvoke, onEnd); } else if (onEnd != null) { onEnd(); } }); }
public bool Start () { // Don't allow the action to overlap itself if (!Enabled || performing) return false; performing = true; perform = true; Log ("Start", true); OnStart (); Co2.StartCoroutine (Duration #if QUARTER_TIME *0.25f #else , SetProgress, End); #endif return true; }
public void AddTime() { elapsedTime++; if (elapsedTime > settings.GracePeriod) { /*if (PlayerItemGroup.Count < Payment) { * GiveWarning (); * elapsedTime --; * } else { * }*/ Status = LoanStatus.Repayment; PlayerItemGroup.Remove(Payment); } if (elapsedTime == settings.GracePeriod + settings.RepaymentLength) { Co2.WaitForFixedUpdate(() => { Group.Remove(this); }); } if (onUpdate != null) { onUpdate(); } }
protected override void OnEnable() { base.OnEnable(); Co2.WaitForFixedUpdate(() => { if (gameObject.activeSelf) { GridPoint gp = Element as GridPoint; if (gp != null) { pbar = UI.Instance.CreateProgressBar(gp.Position); } else { Connection c = Element as Connection; if (c != null) { pbar = UI.Instance.CreateProgressBar(c.Center); } } } }); }
public void TestRepeat(PerformerTask repeat) { PerformableTasks.Add(repeat); repeat.onEnd += (PerformerTask task) => { Co2.WaitForFixedUpdate(() => { if (repeat.Performing) { Debug.Log("Repeat test succeeded :)"); } else { Debug.Log("Repeat test failed :("); } repeat.Stop(); }); }; if (!repeat.Settings.Repeat) { throw new System.Exception("The task '" + repeat.GetType() + "' will not repeat because its data model has Repeat set to false"); } repeat.Start(); }
public Putfragment Add(Co2 o1) { return(AddBox(o1.Min, o1.Max)); }