internal void WriteComplete(EventPoint point, string message) { if (AzureTaskComplete != null) { AzureTaskComplete(point, message); } }
public DeathmatchMap LoadAutoplay() { Random Random = new Random(); MapAttributes ActiveMapAttributes = ListMap.Where(x => x.Name == "Autoplay").First(); DeathmatchMap Autoplay = new DeathmatchMap(ActiveMapAttributes.Name, "Classic", null); Autoplay.ListGameScreen = ListGameScreen; while (Autoplay.ListPlayer.Count < ActiveMapAttributes.MaxNumberOfPlayers) { Player NewPlayer = new Player("Player " + (Autoplay.ListPlayer.Count + 1), "AI", false, false, Autoplay.ListPlayer.Count, ActiveMapAttributes.ArrayColor[Autoplay.ListPlayer.Count]); NewPlayer.IsAlive = false; Autoplay.ListPlayer.Add(NewPlayer); } for (int P = ActiveMapAttributes.MaxNumberOfPlayers - 1; P >= 0; --P) { Autoplay.ListPlayer[P].ListSpawnPoint.Clear(); for (int S = ActiveMapAttributes.ListSpawns.Count - 1; S >= 0; --S) { if (Convert.ToInt32(ActiveMapAttributes.ListSpawns[S].Tag) == P + 1) { EventPoint NewSpawnPoint = ActiveMapAttributes.ListSpawns[S]; Autoplay.ListPlayer[P].ListSpawnPoint.Add(NewSpawnPoint); NewSpawnPoint.LeaderPilot = ListPilot[Random.Next(ListPilot.Count)]; int NewUnitIndex = Random.Next(ArrayUnit.Length); NewSpawnPoint.LeaderTypeName = ArrayUnit[NewUnitIndex].Item1; NewSpawnPoint.LeaderName = ArrayUnit[NewUnitIndex].Item2; } } } return(Autoplay); }
void UpdateEventPoint( String spotCode, String futureCode, TradingDirection spotDirection, DateTime dateTimeFrom, PairTradingData tradingData, EventPoint ep) { if (spotDirection == TradingDirection.Long) { ep.LongCode = spotCode; ep.ShortCode = futureCode; } else { ep.LongCode = futureCode; ep.ShortCode = spotCode; } ep.DateTimeFrom = dateTimeFrom; if (tradingData != null) { ep.DateTimeTo = tradingData.MaxDateTime; ep.RangeMax = tradingData.MaxPnL; ep.RangeMin = tradingData.MinPnL; } else { ep.DateTimeTo = new DateTime(2999, 12, 31); ep.RangeMax = double.NaN; ep.RangeMin = double.NaN; } }
/// <summary> /// Finds all intersections between the specified line segments, using a sweep line /// algorithm.</summary> /// <param name="lines"> /// An <see cref="Array"/> containing the <see cref="LineD"/> instances to intersect. /// </param> /// <returns> /// A lexicographically sorted <see cref="Array"/> containing a <see cref="MultiLinePoint"/> /// for every point of intersection between the <paramref name="lines"/>.</returns> /// <exception cref="ArgumentException"> /// <paramref name="lines"/> contains a <see cref="LineD"/> instance whose <see /// cref="LineD.Start"/> and <see cref="LineD.End"/> coordinates are equal.</exception> /// <exception cref="ArgumentNullException"> /// <paramref name="lines"/> is a null reference.</exception> /// <exception cref="InvalidOperationException"> /// <paramref name="lines"/> contains coordinates that caused corruption to an internal /// search structure.</exception> /// <remarks><para> /// <b>Find</b> moves a horizontal sweep line across the specified <paramref name="lines"/>, /// testing only those elements for intersection which are adjacent along the sweep line. /// The runtime is O((n + k) log n) where k is the number of discovered intersections. /// </para><para> /// <b>Find</b> is very efficient when there are no or few intersections, achieving its best /// performance if the specified <paramref name="lines"/> are horizontal parallels. However, /// the event point schedule and sweep line structure impose a large overhead if there are /// many candidate lines to consider. The worst case of O(n^2) intersections is much slower /// than the brute force algorithm implemented by <see cref="FindSimple"/>. /// </para><para> /// <b>Find</b> always uses exact coordinate comparisons. Epsilon comparisons would corrupt /// the internal search structures due to the merging of nearby event points. Call <see /// cref="FindSimple(LineD[], Double)"/> to use epsilon comparisons.</para></remarks> public static MultiLinePoint[] Find(LineD[] lines) { Status status = new Status(); var crossings = status.FindCore(lines); return(EventPoint.Convert(crossings)); }
/// <summary> /// Adds an intersection <see cref="EventPoint"/> to the <see cref="Schedule"/> if the /// two specified <see cref="SweepLine"/> nodes indicate a line crossing.</summary> /// <param name="a"> /// The first <see cref="SweepLine"/> node to examine.</param> /// <param name="b"> /// The second <see cref="SweepLine"/> node to examine.</param> /// <param name="e"> /// The current <see cref="EventPoint"/> which receives a detected crossing that occurs /// exactly at the <see cref="Cursor"/>.</param> /// <remarks> /// If the <see cref="Schedule"/> already contains an <see cref="EventPoint"/> for the /// computed intersection, <b>AddCrossing</b> adds the indicated lines to the existing /// <see cref="EventPoint"/> if they are not already present.</remarks> private void AddCrossing(BraidedTreeNode <Int32, Int32> a, BraidedTreeNode <Int32, Int32> b, EventPoint e) { int aIndex = a.Key, bIndex = b.Key; LineIntersection c = Lines[aIndex].Intersect(Lines[bIndex]); // ignore crossings that involve only start or end points, // as those line events have been scheduled during initialization if ((c.First == LineLocation.Between && LineIntersection.Contains(c.Second)) || (LineIntersection.Contains(c.First) && c.Second == LineLocation.Between)) { // quit if crossing occurs before cursor PointD p = c.Shared.Value; int result = PointDComparerY.CompareExact(Cursor, p); if (result > 0) { return; } // update schedule if crossing occurs after cursor if (result < 0) { BraidedTreeNode <PointD, EventPoint> node; Schedule.TryAddNode(p, new EventPoint(p), out node); e = node._value; } // add crossing to current or scheduled event point e.TryAddLines(aIndex, c.First, bIndex, c.Second); } }
/// <summary> /// Finds all intersections between the specified line segments, using a brute force /// algorithm and given the specified epsilon for coordinate comparisons.</summary> /// <param name="lines"> /// An <see cref="Array"/> containing the <see cref="LineD"/> instances to intersect. /// </param> /// <param name="epsilon"> /// The maximum absolute difference at which two coordinates should be considered equal. /// </param> /// <returns> /// A lexicographically sorted <see cref="Array"/> containing a <see cref="MultiLinePoint"/> /// for every point of intersection between the <paramref name="lines"/>.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="lines"/> is a null reference.</exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="epsilon"/> is equal to or less than zero.</exception> /// <remarks> /// <b>FindSimple</b> is identical with the basic <see cref="FindSimple(LineD[])"/> overload /// but uses the specified <paramref name="epsilon"/> to determine intersections between the /// specified <paramref name="lines"/> and to combine nearby intersections.</remarks> public static MultiLinePoint[] FindSimple(LineD[] lines, double epsilon) { if (lines == null) { ThrowHelper.ThrowArgumentNullException("lines"); } if (epsilon <= 0.0) { ThrowHelper.ThrowArgumentOutOfRangeException( "epsilon", epsilon, Strings.ArgumentNotPositive); } var crossings = new BraidedTree <PointD, EventPoint>( (a, b) => PointDComparerY.CompareEpsilon(a, b, epsilon)); for (int i = 0; i < lines.Length - 1; i++) { for (int j = i + 1; j < lines.Length; j++) { var crossing = lines[i].Intersect(lines[j], epsilon); if (crossing.Exists) { PointD p = crossing.Shared.Value; BraidedTreeNode <PointD, EventPoint> node; crossings.TryAddNode(p, new EventPoint(p), out node); node._value.TryAddLines(i, crossing.First, j, crossing.Second); } } } return(EventPoint.Convert(crossings.Values)); }
private static void FindNewEvent(Segment s1, Segment s2, EventPoint eventPoint, RBTreeMap <EventPoint, LinkedList <Segment> > eventQueue) { //If two segments intersect below the sweep line, or on it and //to the right of the current event point, and the intersection //is not yet present as an event in Q: //then insert a new event point in Q for this intersection VecRat2 pointIntersection = new VecRat2(); SegRat2 segmentIntersection = new SegRat2(); //bool intersectionExists = Segment.ComputeIntersection(s1, s2, out pointIntersection); //if (intersectionExists) SegmentIntersectionType result = GeomAid.SegmentIntersection(s1.ToSegRat2(), s2.ToSegRat2(), ref pointIntersection, ref segmentIntersection); if (result == SegmentIntersectionType.Point) { EventPoint newEventPoint = new EventPoint(null); newEventPoint.Position = pointIntersection; if (eventPoint.CompareTo(newEventPoint) < 0 && !eventQueue.ContainsKey(newEventPoint)) { LinkedList <Segment> upperList = new LinkedList <Segment>(); eventQueue.Add(new RBTreeMapNode <EventPoint, LinkedList <Segment> >(newEventPoint, upperList)); } } else if (result == SegmentIntersectionType.Segment) { throw new NotImplementedException("Didn't think this would ever happen?!"); } }
/// <overloads> /// Finds all intersections between the specified line segments, using a brute force /// algorithm.</overloads> /// <summary> /// Finds all intersections between the specified line segments, using a brute force /// algorithm and exact coordinate comparisons.</summary> /// <param name="lines"> /// An <see cref="Array"/> containing the <see cref="LineD"/> instances to intersect. /// </param> /// <returns> /// A lexicographically sorted <see cref="Array"/> containing a <see cref="MultiLinePoint"/> /// for every point of intersection between the <paramref name="lines"/>.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="lines"/> is a null reference.</exception> /// <remarks><para> /// <b>FindSimple</b> performs a pairwise intersection of every <paramref name="lines"/> /// element with every other element. The runtime is therefore always O(n^2), regardless of /// the number of intersections found. /// </para><para> /// However, the constant factor is low and O(n^2) intersections are found in optimal time /// because <b>FindSimple</b> performs no additional work to avoid testing for possible /// intersections. For a small number of <paramref name="lines"/> (n < 50), /// <b>FindSimple</b> usually beats the sweep line algorithm implemented by <see /// cref="Find"/> regardless of the number of intersections.</para></remarks> public static MultiLinePoint[] FindSimple(LineD[] lines) { if (lines == null) { ThrowHelper.ThrowArgumentNullException("lines"); } var crossings = new BraidedTree <PointD, EventPoint>(PointDComparerY.CompareExact); for (int i = 0; i < lines.Length - 1; i++) { for (int j = i + 1; j < lines.Length; j++) { var crossing = lines[i].Intersect(lines[j]); if (crossing.Exists) { PointD p = crossing.Shared.Value; BraidedTreeNode <PointD, EventPoint> node; crossings.TryAddNode(p, new EventPoint(p), out node); node._value.TryAddLines(i, crossing.First, j, crossing.Second); } } } return(EventPoint.Convert(crossings.Values)); }
public EventPointsReader(String filePath, Boolean skipHeader) { this.EventPoints = new List<EventPoint>(); CsvFileReader reader = new CsvFileReader(filePath); Boolean headerSkipped = false; while (true) { CsvRow row = new CsvRow(); if (reader.ReadRow(row)) { if ((skipHeader && headerSkipped) || !skipHeader) { EventPoint ep = new EventPoint(); ep.LongCode = row[0]; ep.ShortCode = row[1]; ep.DateTimeFrom = DateTime.ParseExact(row[2], "yyyy-MM-dd HH:mm:ss.fff", null); ep.DateTimeTo = DateTime.ParseExact(row[3], "yyyy-MM-dd HH:mm:ss.fff", null); ep.RangeMax = Convert.ToDouble(row[4]); ep.RangeMin = Convert.ToDouble(row[5]); this.EventPoints.Add(ep); } headerSkipped = true; } else { break; } } }
private static void CalculateAndUpdate(List <StatusPoint> status, SortedSet <EventPoint> eventPoints, SortedSet <Vector2d> intersections) { for (int i = 0; i < status.Count - 1; i++) { var segA = status[i].Segment; var segB = status[i + 1].Segment; Vector2d intersection; Segment2d segInter; if (segA.Intersection(segB, out intersection, out segInter)) { if (Vector2d.IsNaN(intersection)) { intersections.Add(segA.A); intersections.Add(segA.B); } else { intersections.Add(intersection); } var eventPoint = new EventPoint( status[i].SegmentId, status[i + 1].SegmentId, 0, EventPoint.Type.Intersection); eventPoints.Add(eventPoint); } } }
public virtual void Load() { // _isBT = true; _isAlert = false; _sensorTimer = _attentionTime; _positionVision = null; _positionTrigger = null; _awareTimer = 0; _isAware = false; // _motor.ToSpawn(); // _anim.Load(_state); _anim.Load(); // _motor.Load(_state); _motor.Load(); _motor.CollidersToggle(true); _data.HealthRestore(); // _hostiles.Clear(); // * testing [nani? index?] System.Array.Clear(_timers, 0, _countTimers); System.Array.Clear(_flags, 0, _countFlags); _isVision = true; _isTrigger = true; // foreach (sensor_vision sensor in _sensorsVision) // sensor.SetActive(true); foreach (sensor_trigger sensor in _sensorsTrigger) { sensor.SetActive(true); } _isSensors = true; _sleep = false; _timerPath = 0f; _flagStatus = -1; _anim.SpritesToggle(true); }
// ToDo: Find where this is supposed to be used and use it. protected virtual void OnAzureTaskComplete(EventPoint point, string message) { var handler = AzureTaskComplete; if (handler != null) { handler(point, message); } }
// * testing [bell hurt] ? allow sensors to fire ? public void RegisterEvent(Vector2 position, LayerMask layer, float time) { // all sensors ? _positionVision = new EventPoint(position, layer, time); _positionTrigger = new EventPoint(position, layer, time); // // enable waypoints ? borked ? // EnableWaypoints(); _isAlert = true; _sensorTimer = 0; print(gameObject.name + " " + position); }
private IEnumerable <EventPoint> CreateEventPoints(IEnumerable <Segment> segments) { List <EventPoint> points = new List <EventPoint>(); foreach (var s in segments) { points.Add(EventPoint.Start(s)); points.Add(EventPoint.End(s)); } return(points); }
protected override void OnRelease(PlayerActor player) { switch (player.PlayerController.State) { case Normal _: case Onbu _: case Houchi _: EventPoint.ChangeNormalState(); MapUIContainer.SetVisibleHUD(true); break; } }
/// <summary> /// Load Collectors /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EventNotification_Load(object sender, EventArgs e) { spotImageProvider = new SpotImageService.Provider(); EventPoint model = spotImageProvider.RetrieveEvent(this.ImagePath); txtName.Text = model.Name; txtDate.Text = model.Date.ToString(); txtUserAddress.Text = model.Address.ToString(); txtWardName.Text = model.Ward; pictureImage.ImageLocation = model.ImagePath; this.EventId = model.Id; }
void MoveToWaypoint() { // _anchor.position = GetWaypointRandom(); EventPoint temp = new EventPoint(); // temp.Position = GetWaypointRandom(); temp.Position = GetWaypoint(); temp.Layer = _anchor.Layer; temp.Time = _anchor.Time; _anchor = temp; // _anchor.position = GetWaypointNearby(); Task.current.Succeed(); }
protected override void InitializeCommandLabels() { if (!((IReadOnlyList <CommandLabel.CommandInfo>) this.getLabels).IsNullOrEmpty <CommandLabel.CommandInfo>()) { return; } CommonDefine commonDefine = !Singleton <Resources> .IsInstance() ? (CommonDefine)null : Singleton <Resources> .Instance.CommonDefine; CommonDefine.CommonIconGroup commonIconGroup = !Object.op_Inequality((Object)commonDefine, (Object)null) ? (CommonDefine.CommonIconGroup)null : commonDefine.Icon; Resources instance = Singleton <Resources> .Instance; int guideCancelId = commonIconGroup.GuideCancelID; Sprite sprite; instance.itemIconTables.InputIconTable.TryGetValue(guideCancelId, out sprite); List <string> source; instance.Map.EventPointCommandLabelTextTable.TryGetValue(0, out source); int index = !Singleton <GameSystem> .IsInstance() ? 0 : Singleton <GameSystem> .Instance.languageInt; this.getLabels = new CommandLabel.CommandInfo[1] { new CommandLabel.CommandInfo() { Text = source.GetElement <string>(index), Transform = this.LabelPoint, IsHold = false, Icon = sprite, TargetSpriteInfo = commonIconGroup?.CharaSpriteInfo, Event = (System.Action)(() => { PlayerActor playerActor = !Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player; PlayerController playerController = !Object.op_Inequality((Object)playerActor, (Object)null) ? (PlayerController)null : playerActor.PlayerController; EventPoint.SetCurrentPlayerStateName(); if (Object.op_Inequality((Object)playerController, (Object)null)) { playerController.ChangeState("Idle"); } RequestUI requestUi = MapUIContainer.RequestUI; requestUi.SubmitEvent = (System.Action)(() => this.GetMecha()); requestUi.SubmitCondition = (Func <bool>)(() => this.CanGet()); requestUi.ClosedEvent = (System.Action)(() => EventPoint.ChangePrevPlayerMode()); requestUi.Open(Popup.Request.Type.Cuby); if (!requestUi.IsImpossible) { return; } MapUIContainer.PushWarningMessage(Popup.Warning.Type.InsufficientBattery); }) } }; }
public async Task <IActionResult> Create([FromBody] EventPoint eventPoint) { if (ModelState.IsValid) { context.Add(eventPoint); await context.SaveChangesAsync(); await context.Entry(eventPoint).GetDatabaseValuesAsync(); return(Json(new { success = "Event point returned!", eventPoint })); } return(BadRequest(new { error = "Unable to save the event point", eventPoint })); }
public static LinkedList <LineSegmentIntersection> FindIntersections(IEnumerable <DCEL_HalfEdge> lineSegments) { LinkedList <LineSegmentIntersection> result = new LinkedList <LineSegmentIntersection>(); Sweepline sweepline = new Sweepline(); RBTreeMap <EventPoint, LinkedList <Segment> > eventQueue = new RBTreeMap <EventPoint, LinkedList <Segment> >((x, y) => x.CompareTo(y)); var segments = lineSegments.Where(lineSegment => lineSegment.Origin.Position != lineSegment.Destination.Position) .Select(lineSegment => new Segment(lineSegment, sweepline)); //segments = FixOverlappingSegments(segments); foreach (var segment in segments) { var node = eventQueue.Find(segment.Upper); LinkedList <Segment> upperList = (node != null ? node.Value : null); if (upperList == null) { upperList = new LinkedList <Segment>(); eventQueue.Add(new RBTreeMapNode <EventPoint, LinkedList <Segment> >(new EventPoint(segment.Upper), upperList)); } upperList.AddLast(segment); if (!eventQueue.ContainsKey(segment.Lower)) { eventQueue.Add(new RBTreeMapNode <EventPoint, LinkedList <Segment> >(new EventPoint(segment.Lower), new LinkedList <Segment>())); } } RBTreeSet <Segment> status = new RBTreeSet <Segment>((x, y) => x.CompareTo(y)); while (eventQueue.Count > 0) { var pair = eventQueue.MinNode; eventQueue.RemoveMin(); EventPoint nextEventPoint = pair.Key; LinkedList <Segment> upperList = pair.Value; LineSegmentIntersection reportedIntersection; HandleEventPoint(nextEventPoint, upperList, sweepline, eventQueue, status, out reportedIntersection); if (reportedIntersection != null) { result.AddLast(reportedIntersection); } } return(result); }
private bool IsRespectiveListener(EventPoint epoint, Hashtable hlistener) { foreach (Object key in hlistener.Keys) { if (!epoint.data.ContainsKey(key)) { return(false); } if (!(epoint.data[key].ToString() == hlistener[key].ToString())) { return(false); } } return(true); }
void MoveToVision() { if (_positionVision == null) { Task.current.Fail(); } else { Task.current.debugInfo = _positionVision.Position.ToString(); // * testing [? chase bounds/limit] // _anchor.position = _positionVision.Position; _anchor = _positionVision; _positionVision = null; Task.current.Succeed(); } }
public List<EventPoint> GetEventPoints( PeriodicMarketDataCollection spot, PeriodicMarketDataCollection future, TradingDirection spotDirection) { List<EventPoint> eventPoints = new List<EventPoint>(); for (int i = 0; i < spot.Rmds.Count - 1; ++i) { RawMarketData spotStartRmd = spot.Rmds[i]; RawMarketData futureStartRmd = future.Rmds[i]; Trace.Assert(spotStartRmd.LastUpdatedTime == futureStartRmd.LastUpdatedTime); if (!RawMarketDataUtil.IsValidBidAskCurPrice(spotStartRmd) || !RawMarketDataUtil.IsValidBidAskCurPrice(futureStartRmd)) { EventPoint ep = new EventPoint(); UpdateEventPoint(spotStartRmd.Code, futureStartRmd.Code, spotDirection, spotStartRmd.LastUpdatedTime, null, ep); eventPoints.Add(ep); } else { PairTradingData tradingData = new PairTradingData(spotDirection); tradingData.SetEnterPrices(spotStartRmd, futureStartRmd, spotDirection); for (int j = i + 1; j < spot.Rmds.Count; ++j) { RawMarketData spotCurRmd = spot.Rmds[j]; RawMarketData futureCurRmd = future.Rmds[j]; if (!RawMarketDataUtil.IsValidBidAskCurPrice(spotCurRmd) || !RawMarketDataUtil.IsValidBidAskCurPrice(futureCurRmd)) { continue; } tradingData.UpdateExitNowPnL(spotCurRmd, futureCurRmd, spotDirection); } EventPoint ep = new EventPoint(); UpdateEventPoint(spotStartRmd.Code, futureStartRmd.Code, spotDirection, spotStartRmd.LastUpdatedTime, tradingData, ep); eventPoints.Add(ep); } } return eventPoints; }
void OnTriggerStay(Collider other) { if (other.tag == "Leader") { if (inputManager.DecisionButton == 1) { GetComponent <Animation>().Play(openAnimation); this.GetComponent <BoxCollider> ().enabled = false; GameObject o = Instantiate(Resources.Load("Prefabs/Event/Event_point", typeof(GameObject)) as GameObject, new Vector3(1.0f, 1.21f, -8.5f), Quaternion.identity) as GameObject; EventPoint ep = o.AddComponent <EventPoint> (); ep.Prepare(inputManager); Destroy(icon.gameObject); } } }
protected bool Sensor_Trigger() { if (!_isTrigger || !_isSensors) { return(false); } float distance = float.MaxValue; foreach (sensor_trigger sensor in _sensorsTrigger) { foreach (Transform target in sensor.Targets) { if (!_data.Hostiles.Contains(target)) { continue; } // * testing exclude dead existing if (target.gameObject.layer == game_variables.Instance.LayerPlayer || target.gameObject.layer == game_variables.Instance.LayerMob) { if (target.GetComponent <entity_data>().HealthInst <= 0) { continue; } } // ? closest [memory waste ?] if (Vector3.Distance(_motor.Position, target.position) < distance) { distance = Vector3.Distance(_motor.Position, target.position); _positionTrigger = new EventPoint(target.position, target.gameObject.layer, Time.time); } } // print(sensor.Targets.Count); } if (_positionTrigger != null) { // // enable waypoints ? borked ? // EnableWaypoints(); _isAlert = true; _sensorTimer = 0; // *testing instant aware _awareTimer = _attentionTime; return(true); } return(false); }
// override must always call base ? // protected override List<Waypoint> Filter_Waypoints(float distanceMin = int.MinValue, float distanceMax = int.MaxValue) // protected virtual List<Waypoint> Filter_Waypoints() // { // List<Waypoint> waypoints = new List<Waypoint>(); // foreach (Waypoint waypoint in _waypoints) // if (waypoint.IsEnabled) // waypoints.Add(waypoint); // return waypoints; // } // on alerted ? // protected void EnableWaypoints() // { // foreach (Waypoint waypoint in Filter_Waypoints()) // waypoint.Load(); // } protected bool Sensor_Vision() { if (!_isVision || !_isSensors) { return(false); } float distance = float.MaxValue; foreach (sensor_vision sensor in _sensorsVision) { foreach (Transform target in sensor.Targets) { if (!_data.Hostiles.Contains(target)) { continue; } // ? closest [memory waste ?] if (Vector3.Distance(_motor.Position, target.position) < distance) { distance = Vector3.Distance(_motor.Position, target.position); _positionVision = new EventPoint(target.position, target.gameObject.layer, Time.time); } } // print(gameObject.name + "\t" + sensor.Targets.Count); } if (_positionVision != null) { // // enable waypoints ? borked ? // EnableWaypoints(); _isAlert = true; _sensorTimer = 0; // *testing instant aware if (_isAware) { _awareTimer = _attentionTime; } return(true); } return(false); }
void MoveToOffsetRadius(float value) { // * testing [? retry attempts on invalid, chase bounds/limit] // _anchor.position += transform.right * Random.Range(-value, value) + transform.up * Random.Range(-value, value); // Vector3 direction = transform.right * Random.Range(-1f, 1f) + transform.up * Random.Range(-1f, 1f); // RaycastHit2D hit = Physics2D.Raycast(_anchor.Position, direction.normalized, value, game_variables.Instance.ScanLayerObstruction); // RaycastHit2D hit = Physics2D.Raycast(_motor.Position, direction.normalized, value, game_variables.Instance.ScanLayerObstruction); Vector2 offset = (transform.right * Random.Range(-1f, 1f) + transform.up * Random.Range(-1f, 1f)).normalized; RaycastHit2D hit = Physics2D.Raycast(_motor.Position, offset, value, game_variables.Instance.ScanLayerObstruction); EventPoint temp = new EventPoint(); // temp.Position = hit ? grid_map.Instance.WorldToGrid(hit.point + hit.normal * .3f) : grid_map.Instance.WorldToGrid(_motor.Position + (Vector3)offset * value); // temp.Position = hit ? grid_map.Instance.WorldToGrid(hit.point + hit.normal * .5f) : grid_map.Instance.WorldToGrid(_motor.Position + (Vector3)offset * value); // if (Physics2D.OverlapCircle(temp.Position, .9f, game_variables.Instance.ScanLayerObstruction) != null) // temp.Position = grid_map.Instance.WorldToGrid(_motor.Position); // temp.Position = hit ? grid_map.Instance.WorldToGrid(_motor.Position) : grid_map.Instance.WorldToGrid(_motor.Position + (Vector3)offset * value); temp.Position = hit ? grid_map.Instance.WorldToGrid(hit.point + hit.normal * .5f) : grid_map.Instance.WorldToGrid(_motor.Position); // safety ? if (Physics2D.OverlapCircle(temp.Position, .9f, game_variables.Instance.ScanLayerObstruction) != null) { // temp.Position = grid_map.Instance.WorldToGrid(_motor.Position); temp.Position = GetWaypoint(); } temp.Layer = _anchor.Layer; temp.Time = _anchor.Time; _anchor = temp; // else // // temp.Position = _anchor.Position + direction; // // temp.Position = _motor.Position + direction.normalized * value; // temp.Position = _anchor.Position; // // ? locking // while (hit) // { // direction = transform.right * Random.Range(-value, value) + transform.up * Random.Range(-value, value); // hit = Physics2D.Raycast(_anchor.Position, direction.normalized, value, game_variables.Instance.ScanLayerObstruction); // } // temp.Position = _anchor.Position + direction; Task.current.Succeed(); }
public Segment(DCEL_HalfEdge source, Sweepline sweepline) { Source = source; EventPoint origin = new EventPoint(source.Origin); EventPoint destination = new EventPoint(source.Destination); int comp = origin.CompareTo(destination); if (comp < 0) { Upper = origin; Lower = destination; } else if (comp > 0) { Upper = destination; Lower = origin; } else { throw new InvalidOperationException("Trivial line segment."); } Sweepline = sweepline; }
public EventPoint AddEventPoint(string name, string description, DateTime createDate, decimal scoreAward, string pointName, string eventPointType, bool isPermanent, DateTime?timeLeft = null) { var point = DataContext.Points .FirstOrDefault( x => x.Name.Equals(pointName, StringComparison.CurrentCultureIgnoreCase)); if (point == null) { return(null); //Точка {pointName} не создана! } var pointType = DataContext.EventPointTypes .FirstOrDefault( x => x.Name.Equals(eventPointType, StringComparison.CurrentCultureIgnoreCase)); var eventPoint = new EventPoint { Name = name, Point = point, DateCreate = createDate, IsPermanent = isPermanent, TimeLeft = timeLeft, ScoreAward = scoreAward, EventPointType = pointType, Description = description }; if (DataContext.EventPoints.ToList() .Exists(x => x.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase) && x.Description.Equals(description, StringComparison.CurrentCultureIgnoreCase))) { return(null); //Событие {name} уже существует! } DataContext.EventPoints.Add(eventPoint); DataContext.SaveChanges(); return(eventPoint); }
// private LineRenderer _feedbackFOV; protected override void Awake() { // ? post base.Awake(); // // _anchor = Instantiate(new GameObject(), transform.position, transform.rotation).transform; // _anchor = (new GameObject()).transform; // _anchor.position = transform.position; // _anchor.rotation = transform.rotation; // _anchor.gameObject.name = gameObject.name + "-anchorMove"; _anchor = new EventPoint(transform.position, gameObject.layer, 0f); // // _BT = GetComponent<PandaBehaviour>(); // _isBT = false; _isAlert = false; _sensorTimer = _attentionTime; _positionVision = null; _positionTrigger = null; _awareTimer = 0; _isAware = false; // _hostiles = new List<Transform>(); _timers = new float[_countTimers]; _flags = new bool[_countFlags]; _isVision = true; _isTrigger = true; _isSensors = true; _sleep = true; _timerPath = 0f; _flagStatus = -1; // _id = 0; // _feedbackFOV = GetComponent<LineRenderer>(); // if (_feedbackFOV) // _feedbackFOV.positionCount = 0; // Vector3[] temp = new Vector3[path.Length + 1]; // _feedbackFOV.SetPositions(); }
void Update() { if (_sleep) { // _anim.SpritesToggle(game_camera.Instance.InView(_motor.Position)); return; } // // * testing [redundant calculation ?] // if (_data.HealthInst > 0) // _anim.SpritesToggle(game_camera.Instance.InView(_motor.Position)); // --- // ??? awareness if (Sensor_Vision() || Sensor_Trigger()) { // _awareTimer += _awareTime * Time.deltaTime * Vector3.Distance(transform.position, _positionVision) / _visionRadius; // _awareTimer += _attentionTime * Time.deltaTime * Vector3.Distance(transform.position, _positionVision) / _visionRadius; _awareTimer += _attentionTime * Time.deltaTime; if (_isAware) { if (_flagStatus != 1) { _flagStatus = 1; feedback_popup.Instance.SetAlert(transform, 1); } } else if (_flagStatus != 0) { _flagStatus = 0; feedback_popup.Instance.SetAlert(transform, 0); } // // ? feedback // if (_feedbackFOV) // { // if (_feedbackFOV.positionCount != 2) // _feedbackFOV.positionCount = 2; // _feedbackFOV.SetPosition(0, _motor.Position); // _feedbackFOV.SetPosition(1, _anchor.Position); // } } else if (_awareTimer > 0) { _awareTimer -= Time.deltaTime; if (_flagStatus != 0) { _flagStatus = 0; feedback_popup.Instance.SetAlert(transform, 0); } // // ? feedback // if (_feedbackFOV) // _feedbackFOV.SetPosition(0, _motor.Position); } else if (_flagStatus != -1) { _flagStatus = -1; // // ? feedback // if (_feedbackFOV) // { // feedback_popup.Instance.SetAlert(transform, -1); // if (_feedbackFOV.positionCount != 2) // _feedbackFOV.positionCount = 2; // } } // if (_awareTimer > _awareTime) if (_awareTimer > _attentionTime) { // _awareTimer = _awareTime; _awareTimer = _attentionTime; _isAware = true; } else if (_awareTimer < 0) { _awareTimer = 0; _isAware = false; } _sensorTimer += Time.deltaTime; _sensorTimer = Mathf.Clamp(_sensorTimer, 0, _attentionTime); // * testing for (int i = 0; i < _countTimers; i++) { if (_timers[i] > 0f) { _timers[i] -= Time.deltaTime; } } if (_timerPath > 0) { _timerPath -= Time.deltaTime; } // * testing discard old [conduit] if (_positionTrigger != null && Time.time - _positionTrigger.Time > _attentionTime) { _positionTrigger = null; } if (_positionVision != null && Time.time - _positionVision.Time > _attentionTime) { _positionVision = null; } }
protected override void OnAwake(PlayerActor player) { this._eventPoint = player.CurrentEventPoint; if (Object.op_Inequality((Object)this._eventPoint, (Object)null)) { CommonDefine.EventStoryInfoGroup playInfo = !Singleton <Resources> .IsInstance() ? (CommonDefine.EventStoryInfoGroup)null : Singleton <Resources> .Instance.CommonDefine?.EventStoryInfo; Dictionary <int, List <string> > textTable = !Singleton <Resources> .IsInstance() ? (Dictionary <int, List <string> >)null : Singleton <Resources> .Instance.Map?.EventPointCommandLabelTextTable; MapUIContainer.RequestUI.CancelEvent = (System.Action)(() => EventPoint.ChangePrevPlayerMode()); MapUIContainer.RequestUI.ClosedEvent = (System.Action)(() => player.CurrentEventPoint = (EventPoint)null); MapUIContainer.RequestUI.SubmitEvent = (System.Action)(() => { if (Object.op_Equality((Object)this._eventPoint, (Object)null)) { EventPoint.ChangePrevPlayerMode(); } else { this._eventPoint.RemoveConsiderationCommand(); int eventId = this._eventPoint.EventID; int groupId = this._eventPoint.GroupID; int pointId = this._eventPoint.PointID; switch (eventId) { case 0: if (Object.op_Equality((Object)player, (Object)null) || playInfo == null) { EventPoint.ChangePrevPlayerMode(); break; } player.PlayerController.ChangeState("Idle"); EventPoint.OpenEventStart(player, playInfo.StartEventFadeTime, playInfo.EndEventFadeTime, playInfo.Generator.SEID, playInfo.Generator.SoundPlayDelayTime, playInfo.Generator.EndIntervalTime, (System.Action)(() => { if (Singleton <Manager.Map> .IsInstance()) { Singleton <Manager.Map> .Instance.SetTimeRelationAreaOpenState(0, true); } Manager.Map.ForcedSetTutorialProgress(25); }), (System.Action)(() => { if (!textTable.IsNullOrEmpty <int, List <string> >()) { List <string> source; textTable.TryGetValue(6, out source); MapUIContainer.PushMessageUI(source.GetElement <string>(EventPoint.LangIdx) ?? string.Empty, 0, 0, (System.Action)null); } EventPoint.ChangePrevPlayerMode(); })); break; case 1: if (Object.op_Equality((Object)player, (Object)null) || playInfo == null) { EventPoint.ChangePrevPlayerMode(); break; } player.PlayerController.ChangeState("Idle"); EventPoint.OpenEventStart(player, playInfo.StartEventFadeTime, playInfo.EndEventFadeTime, playInfo.ShipRepair.SEID, playInfo.ShipRepair.SoundPlayDelayTime, playInfo.ShipRepair.EndIntervalTime, (System.Action)(() => { if (!Object.op_Inequality((Object)this._eventPoint, (Object)null)) { return; } this._eventPoint.SetDedicatedNumber(1); this.ChangeGameCleared(); }), (System.Action)(() => { (!Singleton <Manager.Map> .IsInstance() ? (StoryPointEffect)null : Singleton <Manager.Map> .Instance.StoryPointEffect)?.FadeOutAndDestroy(); if (!textTable.IsNullOrEmpty <int, List <string> >()) { List <string> source; textTable.TryGetValue(7, out source); MapUIContainer.PushMessageUI(source.GetElement <string>(EventPoint.LangIdx) ?? string.Empty, 0, 0, (System.Action)null); } Manager.Map.ForcedSetTutorialProgress(28); DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <long>((IObservable <M0>)Observable.Timer(TimeSpan.FromSeconds(!Singleton <Resources> .IsInstance() ? 5.0 : (double)Singleton <Resources> .Instance.CommonDefine.EventStoryInfo.StoryCompleteNextSupportChangeTime)), (System.Action <M0>)(_ => Manager.Map.ForcedSetTutorialProgressAndUIUpdate(29))), (Component)Singleton <MapScene> .Instance); EventPoint.ChangePrevPlayerMode(); })); break; case 2: if (Object.op_Equality((Object)player, (Object)null) || playInfo == null || pointId != 4 && pointId != 5 && pointId != 6) { EventPoint.ChangePrevPlayerMode(); break; } player.PlayerController.ChangeState("Idle"); EventPoint.OpenEventStart(player, playInfo.StartEventFadeTime, playInfo.EndEventFadeTime, playInfo.PodDevice.SEID, playInfo.PodDevice.SoundPlayDelayTime, playInfo.PodDevice.EndIntervalTime, (System.Action)(() => this._eventPoint.SetAgentOpenState(true)), (System.Action)(() => { if (!textTable.IsNullOrEmpty <int, List <string> >()) { List <string> source; textTable.TryGetValue(9, out source); MapUIContainer.PushMessageUI(source.GetElement <string>(EventPoint.LangIdx) ?? string.Empty, 0, 0, (System.Action)null); } EventPoint.ChangePrevPlayerMode(); })); break; case 3: EventPoint.ChangePrevPlayerMode(); break; case 4: case 5: case 6: EventPoint.ChangePrevPlayerMode(); break; } } }); MapUIContainer.OpenRequestUI((Popup.Request.Type) this._eventPoint.EventID); if (0 > this._eventPoint.WarningID || !MapUIContainer.RequestUI.IsImpossible) { return; } MapUIContainer.PushWarningMessage((Popup.Warning.Type) this._eventPoint.WarningID); } else { player.PlayerController.ChangeState("Normal"); } }
/// <summary> /// Handles the specified <see cref="EventPoint"/> that was just removed from the <see /// cref="Schedule"/>.</summary> /// <param name="e"> /// The <see cref="EventPoint"/> to handle.</param> /// <remarks> /// <b>HandleEvent</b> always updates the <see cref="SweepLine"/>, and possibly the <see /// cref="Schedule"/> via <see cref="AddCrossing"/>.</remarks> private void HandleEvent(EventPoint e) { BraidedTreeNode <Int32, Int32> node, previous = null, next = null; Cursor = e.Shared; bool adding = false; // remove end point & crossing nodes for (int i = 0; i < e.Locations.Count; i++) { switch (e.Locations[i]) { case LineLocation.Start: adding = true; break; case LineLocation.End: node = SweepLine.FindNode(e.Lines[i]); if (node == null) { ThrowHelper.ThrowInvalidOperationException( Strings.SearchStructureCorrupted); } // remember surrounding lines previous = node._previous; next = node._next; SweepLine.RemoveNode(node); break; case LineLocation.Between: if (!SweepLine.Remove(e.Lines[i])) { ThrowHelper.ThrowInvalidOperationException( Strings.SearchStructureCorrupted); } adding = true; break; } } if (!adding) { // intersect remaining neighbors of removed lines if (previous._parent != null && next._parent != null) { AddCrossing(previous, next, e); } // record intersection event var lines = e.Lines; if (lines.Count < 2) { return; } /* * The sweep line algorithm would normally record TWO intersections for * overlapping lines that share the same lexicographic end point: one for the * start point, and one for the end point. So when we encounter an event that * contains only end points, we must check that its line segments arrive from at * least two different directions, and only then record an intersection. */ double slope = Slopes[lines[0]]; for (int i = 1; i < lines.Count; i++) { if (slope != Slopes[lines[i]]) { e.Normalize(Lines); Crossings.Add(e); break; } } return; } // update remaining sweep line to prepare for insertion var root = SweepLine.RootNode; for (node = root._next; node != root; node = node._next) { int index = node.Key; double slope = Slopes[index]; if (slope != Double.MaxValue) { PointD start = Lines[index].Start; Positions[index] = slope * (Cursor.Y - start.Y) + start.X; } } // (re-)insert start point & crossing nodes previous = next = null; for (int i = 0; i < e.Locations.Count; i++) { if (e.Locations[i] != LineLocation.End) { int index = e.Lines[i]; Positions[index] = Cursor.X; SweepLine.TryAddNode(index, 0, out node); // remember surrounding lines if (previous == null) { previous = node._previous; next = node._next; } } } // intersect outermost added lines with existing neighbors if (previous._parent != null) { AddCrossing(previous, previous._next, e); } if (next._parent != null) { AddCrossing(next._previous, next, e); } // record intersection event if (e.Lines.Count > 1) { e.Normalize(Lines); Crossings.Add(e); } }
public void WriteComplete(EventPoint point, string message) { if (AzureTaskComplete != null) AzureTaskComplete(point, message); }