/// <summary> /// Constructor /// </summary> /// <param name="limit">Limit of range (max/min)</param> /// <param name="year">Year</param> /// <param name="month">Month</param> /// <param name="day">Day</param> /// <param name="hour">Hour</param> /// <param name="minute">Minute</param> /// <param name="second">Second</param> public TimeLimitAttribute(RangeLimit limit, int year, int month, int day, int hour = 0, int minute = 0, int second = 0) { //Inserisco i valori nelle proprietà Limit = limit; Year = year; Month = month; Day = day; Hour = hour; Minute = minute; Second = second; }
public static bool RangeCheck(InteractionEvent interactionEvent) { Vector3 point = interactionEvent.Point; // Ignore range when there is no point if (point.sqrMagnitude < 0.001) { return(true); } var interactionRangeLimit = interactionEvent.Source.GetComponentInTree <IInteractionRangeLimit>(out IGameObjectProvider provider); if (interactionRangeLimit == null) { // No range limit return(true); } Vector3 sourcePosition; if (provider is IInteractionOriginProvider origin) { // Object has a custom interaction origin sourcePosition = origin.InteractionOrigin; } else { // Use default game object origin sourcePosition = provider.GameObject.transform.position; } RangeLimit range = interactionEvent.Source.GetRange(); float horizontal = range.horizontal; // Check horizontal and vertical range return(Mathf.Abs(point.y - sourcePosition.y) < range.vertical && (new Vector2(point.x, point.z) - new Vector2(sourcePosition.x, sourcePosition.z)).sqrMagnitude < horizontal * horizontal); }
private async Task Run() { Activity[] activities = _startupStrategy; var range = new RangeLimit(0, 1); while (!_executionContext.TokenSource.Token.IsCancellationRequested && range.Increment()) { try { await activities.RunActivities(_executionContext.TokenSource.Token, _logger); _logger.LogInformation($"ML service is running"); return; } catch { activities = _restartStrategy; } } _executionContext.State = ExecutionState.Failed; }
public static bool RangeCheck(InteractionEvent interactionEvent) { Vector3 point = interactionEvent.Point; // Ignore range when there is no point if (point.sqrMagnitude < 0.001) { return(true); } var interactionRangeLimit = interactionEvent.Source.GetComponentInTree <IInteractionRangeLimit>(out IGameObjectProvider provider); if (interactionRangeLimit == null) { // No range limit return(true); } Vector3 sourcePosition; if (provider is IInteractionOriginProvider origin) { // Object has a custom interaction origin sourcePosition = origin.InteractionOrigin; } else { // Use default game object origin sourcePosition = provider.GameObject.transform.position; } RangeLimit range = interactionEvent.Source.GetRange(); return(range.IsInRange(sourcePosition, point)); }
public static bool RangeCheck(InteractionEvent interactionEvent) { Vector3 point = interactionEvent.Point; // Ignore range when there is no point if (point.sqrMagnitude < 0.001) { return(true); } var interactionRangeLimit = interactionEvent.Source.GetComponentInTree <IInteractionRangeLimit>(out IGameObjectProvider provider); if (interactionRangeLimit == null) { // No range limit return(true); } //Block interaction when point is on top of wall or above. if (IsWallTop(point, 0.4f)) { return(false); } Vector3 sourcePosition; if (provider is IInteractionOriginProvider origin) { // Object has a custom interaction origin sourcePosition = origin.InteractionOrigin; } else { // Use default game object origin sourcePosition = provider.GameObject.transform.position; } RangeLimit range = interactionEvent.Source.GetRange(); if (range.IsInRange(sourcePosition, point)) { return(true); } Collider targetCollider = interactionEvent.Target.GetComponent <Collider>(); if (targetCollider != null) { Vector3 closestPointOnCollider = targetCollider.ClosestPointOnBounds(sourcePosition); return(range.IsInRange(sourcePosition, closestPointOnCollider)); } Rigidbody targetRigidBody = interactionEvent.Target.GetComponent <Rigidbody>(); if (targetRigidBody != null) { Vector3 closestPointOnRigidBody = targetRigidBody.ClosestPointOnBounds(sourcePosition); return(range.IsInRange(sourcePosition, closestPointOnRigidBody)); } return(false); }
static void Main(string[] args) { int a3 = 0; int th1start = 0; int th1stop = 0; int th2start = 0; int th2stop = 0; int th3start = 0; int th3stop = 0; string actiontype; int actiontypeint = 0; int fileisopen = 0; Console.WriteLine("ChangeTextFormate"); Console.WriteLine(" To open file, press 1"); Console.WriteLine(" To make text processing, press 2"); Console.WriteLine(" To save file, press 3"); Console.WriteLine(" To exit, press 4"); var sw = new Stopwatch(); long elapsedMilliseconds = 0; for (;;) { Console.WriteLine("put your number"); actiontype = Console.ReadLine(); actiontypeint = Convert.ToInt32(actiontype); switch (actiontypeint) { case 1: if (fileisopen == 0) { lines = File.ReadAllLines(@"E:\igor_work\C_sharp_advanced\Lesson1\changefile\doc.txt", Encoding.UTF8); fileisopen = 1; // file is open now int length = (int)lines.Length; a3 = length / 3; // divide array to 3 th1stop = a3; th2start = th1stop + 1; th2stop = th2start + a3; th3start = th2stop + 1; th3stop = length - 1; Console.WriteLine("File is open"); } else { Console.WriteLine("File is ALREADY open"); break; } break; case 2: if (elapsedMilliseconds == 0) { //******************************************************************* sw.Start(); RangeLimit rangefirsttreade = new RangeLimit(); rangefirsttreade.Start = th1start; rangefirsttreade.Stop = th1stop; RangeLimit rangesecondtreade = new RangeLimit(); rangesecondtreade.Start = th2start; rangesecondtreade.Stop = th2stop; RangeLimit rangthirdtreade = new RangeLimit(); rangthirdtreade.Start = th3start; rangthirdtreade.Stop = th3stop; //********************************************************************* Thread myThread1 = new Thread(TextHandling); myThread1.Name = "myThread1"; Thread myThread2 = new Thread(TextHandling); myThread2.Name = "myThread2"; Thread myThread3 = new Thread(TextHandling); myThread3.Name = "myThread3"; myThread1.Start(rangefirsttreade); myThread2.Start(rangesecondtreade); myThread3.Start(rangthirdtreade); myThread1.Join(); myThread2.Join(); myThread3.Join(); Console.WriteLine("Text processing has been finished"); elapsedMilliseconds = sw.ElapsedMilliseconds; sw.Stop(); Console.WriteLine("Time execution" + elapsedMilliseconds); } else { Console.WriteLine("File is already EXECUTED"); break; } break; case 3: File.WriteAllLines(@"E:\igor_work\C_sharp_advanced\Lesson1\changefile\doc1changed.txt", lines); Console.WriteLine("File saved"); break; case 4: Environment.Exit(0); break; } } }