public async Task <ActionResult <List <JourneyDto> > > SearchJourney2([FromBody] JourneyAdvancedSearchDto dto) { if (!ModelState.IsValid) { return(BadRequest()); } var origin = await locationRepository.Get(dto.OriginId); var destination = await locationRepository.Get(dto.DestinationId); if (origin == null || destination == null) { return(NotFound("")); } // TODO : Send/Get all active the journeys into/from Redis var journeys = journeyRepository.GetAllLazy(); var eligibleJourneys = journeys.ToList().Where(j => j.IsActive && CoordinateHelper.IsBetween( new Coordinate { X = origin.CoorditateX, Y = origin.CoorditateY }, new Coordinate { X = destination.CoorditateX, Y = destination.CoorditateY }, new Coordinate { X = j.Origin.CoorditateX, Y = j.Origin.CoorditateY }, new Coordinate { X = j.Destination.CoorditateX, Y = j.Destination.CoorditateY } )); return(Ok(eligibleJourneys.ToList())); }
private Piece CreateKnight(bool isWhite, Coordinate coordinate) { Piece piece = Instantiate(isWhite ? whiteKnightPrefab : blackKnightPrefab, CoordinateHelper.CoordinateToVector3(coordinate), Quaternion.identity).GetComponent <Piece>(); piece.Initialize(ChessPiece.Knight, isWhite, 3, coordinate); return(piece); }
public AttackOutcome AttackOpponent(Guid boardId, AttackRequest attackRequest) { _setupValidationService.ValidateCoordinatePlacement(attackRequest.Coordinate); var attackCoordinate = attackRequest.Coordinate; var board = _boardRepository.Find(boardId); if (board == null) { throw new BadRequestException($"Board ID '{boardId}' was not found."); } var ships = board.Ships; foreach (var ship in ships) { var shipCoordinates = CoordinateHelper.GetCoordinates(ship.TopLeftCoordinate, ship.ShipLength, ship.Alignment); var conflictWithExistingShip = shipCoordinates.FirstOrDefault(a => a.Equals(attackCoordinate)); if (conflictWithExistingShip != null) { ship.SuccessfulHits.Add(attackCoordinate); return(AttackOutcome.Hit); } } return(AttackOutcome.Miss); }
public Coordinate GetCoordinateFromScreenPoint(Vector3 screenPoint) { RaycastHit hit; if (Physics.Raycast(GameManager.Instance.CameraManager.SateliteCamera.ScreenPointToRay(screenPoint), out hit)) { Vector3 worldPoint = Map.transform.InverseTransformPoint(hit.point); //~ Debug.Log(map.transform.InverseTransformPoint(hit.point))); Vector3 point = new Vector3(worldPoint.x * Map.transform.localScale.x, worldPoint.y * Map.transform.localScale.y, worldPoint.z * Map.transform.localScale.z); //~ Debug.Log(GameManager.Instance.xToLong(point.x)); //Vector3 pos = new Vector3(((worldPoint.x - 5.0f) * map.transform.localScale.x) * -1, worldPoint.y, ((worldPoint.z + 5.0f) * map.transform.localScale.z)); float a = GameManager.Instance.XMapModifier; float b = GameManager.Instance.YMapModifier; Vector3 pos2 = new Vector3(); //y = -225a-1 + a-1x //pos2.x = -1347.305389f + 5.988023952f * hit.point.x; pos2.x = -GameManager.Instance.XMapAddition * Mathf.Pow(a, -1) + Mathf.Pow(a, -1) * hit.point.x; pos2.z = -GameManager.Instance.YMapAddtion * Mathf.Pow(b, -1) + Mathf.Pow(b, -1) * hit.point.z; pos2.y = Map.transform.position.y; Coordinate coordPoint = CoordinateHelper.FromOrthoProjectedCoordinate(pos2.z, pos2.x); return(coordPoint); } return(null); }
private void PlaceObjects(Vector3 position) { if (OnlyMovingProps()) { foreach (var kvp in wwObjectToOrigCoordinates) { var origOffset = CoordinateHelper.WWCoordToUnityCoord(kvp.Value); var y = input.GetControllerPoint().y; var origin = new Vector3(position.x + origOffset.x, y, position.z + origOffset.z); var stuckPoint = ToolUtilities.RaycastGridThenCustom(origin, Vector3.down, gridController.GetGridCollider(), WWType.Tile, 200f); var coord = CoordinateHelper.UnityCoordToWWCoord(stuckPoint); kvp.Key.SetPosition(coord); } } else { var delta = GetDeltaSnap(position); foreach (var kvp in wwObjectToOrigCoordinates) { var coord = CoordinateHelper.UnityCoordToWWCoord( position + CoordinateHelper.WWCoordToUnityCoord(kvp.Value) + delta); kvp.Key.SetPosition(coord); } } }
/// <summary> /// Draws the outlines of active path nodes in the map based on their world position. Use this to debug any pathing problems. /// </summary> /// <param name="renderer">Renderer.</param> private void DrawActiveNodeCenters(Renderer renderer) { var pathNodes = tiledMap.GetActivePathNodes(); foreach (var pathNode in pathNodes) { Vector projected1 = CoordinateHelper.WorldSpaceToScreenSpace(pathNode.Bounds.X, pathNode.Bounds.Y, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected2 = CoordinateHelper.WorldSpaceToScreenSpace(pathNode.Bounds.Right, pathNode.Bounds.Y, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected3 = CoordinateHelper.WorldSpaceToScreenSpace(pathNode.Bounds.X, pathNode.Bounds.Bottom, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected4 = CoordinateHelper.WorldSpaceToScreenSpace(pathNode.Bounds.Right, pathNode.Bounds.Bottom, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); projected1 -= Camera.Position; projected2 -= Camera.Position; projected3 -= Camera.Position; projected4 -= Camera.Position; renderer.SetDrawColor(255, 8, 8, 255); Primitive.DrawLine(renderer, (int)projected1.X, (int)projected1.Y, (int)projected2.X, (int)projected2.Y); // top left to top right Primitive.DrawLine(renderer, (int)projected1.X, (int)projected1.Y, (int)projected3.X, (int)projected3.Y); // top left to bottom left Primitive.DrawLine(renderer, (int)projected2.X, (int)projected2.Y, (int)projected4.X, (int)projected4.Y); // top right to bottom right Primitive.DrawLine(renderer, (int)projected3.X, (int)projected3.Y, (int)projected4.X, (int)projected4.Y); // bottom left to bottom right //Primitive.DrawLine(renderer, pathNode.Bounds.X, pathNode.Bounds.Y, pathNode.Bounds.Right, pathNode.Bounds.Y); //Primitive.DrawLine(renderer, pathNode.Bounds.X, pathNode.Bounds.Y, pathNode.Bounds.X, pathNode.Bounds.Bottom); //Primitive.DrawLine(renderer, pathNode.Bounds.Right, pathNode.Bounds.Y, pathNode.Bounds.Right, pathNode.Bounds.Bottom); //Primitive.DrawLine(renderer, pathNode.Bounds.X, pathNode.Bounds.Bottom, pathNode.Bounds.Right, pathNode.Bounds.Bottom); renderer.SetDrawColor(0, 0, 0, 255); } }
public static WWObject Instantiate(WWObjectData objectData) { Vector3 spawnPos = CoordinateHelper.WWCoordToUnityCoord(objectData.wwTransform.coordinate); // Load resource and check to see if it is valid. WWResource resource = WWResourceController.GetResource(objectData.resourceTag); GameObject gameObject; WWResourceMetadata resourceMetadata = resource.GetMetaData(); if (resource.GetPrefab() == null) { gameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); resourceMetadata = gameObject.AddComponent <WWResourceMetadata>(); gameObject.transform.Translate(spawnPos); } else { if (resource.GetMetaData() == null) { Debug.Log("There is no metadata for this resource, so it cannot be instantiated."); return(null); } // Create a GameObject at the correct location and rotation. gameObject = Object.Instantiate(resource.GetPrefab(), spawnPos, Quaternion.Euler(0, objectData.wwTransform.rotation, 0)); } // Use ResourceMetaData to construct the object. WWObject wwObject = ConstructWWObject(gameObject, resourceMetadata); // Give the new WWObject the data used to create it. wwObject.Init(objectData, resourceMetadata); wwObject.SetTransform(objectData.wwTransform); return(wwObject); }
/** * Executing the upgrades */ public override void Execute(MinEventParams _params) { if (GameManager.Instance.World == null) { return; } World world = GameManager.Instance.World; for (int i = 0; i < this.targets.Count; i++) { Log.Out("Checking for Entity"); if (this.targets[i] as Entity == null) { Log.Out("Null, continue"); continue; } Vector3i currentPosition = new Vector3i(this.targets[i].GetPosition()); Dictionary <Vector3i, Block> blockPositions = CoordinateHelper.GetBlocksFromCoordinates(world, CoordinateHelper.GetCoOrdinatesAround(currentPosition, this.range)); foreach (KeyValuePair <Vector3i, Block> entry in blockPositions) { Block blockToCheck = entry.Value; if (blockToCheck.GetBlockName() != this.blockName) { continue; } BlockHelpers.DoBlockUpgrade(entry.Key, this.targets[i], this.requireMaterials); } } }
public void ConvertRDtoWGS84() { var result = CoordinateHelper.RDtoWGS84(122202, 487250); Assert.IsTrue(result[0] == 4.90559760435224); Assert.IsTrue(result[1] == 52.372143838117); }
public void ConvertWGS84toRD() { var result = CoordinateHelper.WGS84toRD(4.90559760435224, 52.372143838117); Assert.IsTrue(result[0] == 122202); Assert.IsTrue(result[1] == 487250); }
public async Task <IActionResult> Calculate([FromBody] TargetGroupPointVM groupMemberLocationVM) { if (!ModelState.IsValid) { return(BadRequest()); } var memberLocations = (await _dbRepository.GetGroupMemberLocations(groupMemberLocationVM.GroupUid))?.ToList(); if (memberLocations == null) { return(NoContent()); } var targetPoint = CoordinateHelper.GetTargetCoordinate(memberLocations.Select(m => m.GetCoordinate())); var result = await GetPlaces(targetPoint, groupMemberLocationVM.Category); if (result == null) { return(NoContent()); } await SavePotentialRoutes(groupMemberLocationVM.GroupUid, memberLocations, groupMemberLocationVM.Time ?? DateTime.Now, result.Results.Items); var webSiteEndpoint = $"{_appSettings.WebSiteDomain}/result/{groupMemberLocationVM.GroupUid}"; return(Ok(webSiteEndpoint)); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Coordinate square = CoordinateHelper.Vector3ToCoordinate(Camera.main.ScreenToWorldPoint(Input.mousePosition)); if (_isPieceClicked) { // Update when clicking new tile on board if (_validMoves.Contains(square)) { OnPieceMove?.Invoke(_pieceClicked.Position, square); if (!Networked) { MoveTo(_pieceClicked.Position, square); } } _validMoves.Clear(); _isPieceClicked = false; } else if (_board[square] != null && _board[square].IsWhite == _isWhiteMove) { _isPieceClicked = true; _pieceClicked = _board[square]; FindValidMoves(_pieceClicked); // Print clicked piece's moves for debug purposes Debug.LogFormat("{0} move: {1}", _pieceClicked.Type.ToString(), string.Join(", ", _validMoves)); } } }
private void ProcessEndOfDrag(int xCoord) { double relativeX = CoordinateHelper.Unstretch(LocationAxisXCoordinate, MaximumXCoordinate, xCoord - DragPointerOffset); if (Model.GraphEditStyle == GraphEditStyle.Free) { _nearestVertex.X = relativeX; Model.GetTimeOfDayFromXPosition(relativeX).CopyTo(_nearestVertex.Time); } else if (Model.GraphEditStyle == GraphEditStyle.PreserveSectionTimes) { TimeSpan timeOffset = Model.GetTimeOfDayFromXPosition(relativeX) - _nearestVertex.Time; IList <VertexInformation> vertexes; // Departure moved later if ((_nearestVertex.ArrivalDeparture & ArrivalDepartureOptions.Departure) != 0 && timeOffset.TotalSeconds > 0) { vertexes = _nearestVertex.TrainDrawingInfo.LineVertexes.LaterThan(_nearestVertex).ToList(); } // Arrival moved earlier else if ((_nearestVertex.ArrivalDeparture & ArrivalDepartureOptions.Arrival) != 0 && timeOffset.TotalSeconds < 0) { vertexes = _nearestVertex.TrainDrawingInfo.LineVertexes.EarlierThan(_nearestVertex).ToList(); } // Departure moved earlier or arrival moved later else { vertexes = _nearestVertex.TrainDrawingInfo.LineVertexes.ToList(); } ShiftVertexes(vertexes, timeOffset); } _nearestVertex.Train.RefreshTimingPointModels(); }
private void DrawLine( Graphics graphics, Pen trainPen, VertexInformation v0, VertexInformation v1, float leftLimit, float rightLimit, float topLimit, float bottomLimit, List <Tuple <float, float> > controlHandleCoordinates) { float xc0 = CoordinateHelper.Stretch(leftLimit, rightLimit, v0.X); float yc0 = CoordinateHelper.Stretch(topLimit, bottomLimit, 1 - v0.Y); float xc1 = CoordinateHelper.Stretch(leftLimit, rightLimit, v1.X); float yc1 = CoordinateHelper.Stretch(topLimit, bottomLimit, 1 - v1.Y); AddCoordinate(v0, xc0, yc0); AddCoordinate(v1, xc1, yc1); graphics.DrawLine(trainPen, new PointF(xc0, yc0), new PointF(xc1, yc1)); if (controlHandleCoordinates != null && v0.Train == Model.SelectedTrain) { controlHandleCoordinates.Add(new Tuple <float, float>(xc0, yc0)); controlHandleCoordinates.Add(new Tuple <float, float>(xc1, yc1)); } }
public override void Process(object c) { var casted = H.Cast <IPlayer>(c); base.Process(casted); var visibleCities = casted.VisibleCities.ToList(); foreach (var worldCity in casted.PlayersWorld.Cities.Collection) { if (!visibleCities.Contains(worldCity.Guid)) { if (CoordinateHelper.GetDistance(casted.X, casted.Y, worldCity.X, worldCity.Y) < worldCity.Size * 2) { visibleCities.Add(worldCity.Guid); } } } casted.VisibleCities = visibleCities.ToArray(); if (casted.IsMoving) { casted.IsMoving = !CoordinateHelper.IsInRadius(casted.X, casted.Y, casted.MoveToX, casted.MoveToY, 0.01f); // !(Math.Abs(casted.X - casted.MoveToX) < 0.01) || !(Math.Abs(casted.Y - casted.MoveToY) < 0.01); if (!casted.IsMoving) { ProcessStop(casted); } } }
private void Scan() { var pos = Robot.GetLastTargetCoordinates(); if (pos.X == 0 && pos.Y == 0) { return; } double degrees = CoordinateHelper.GetAngle(Robot.X, Robot.Y, pos.X, pos.Y); double diff = (degrees - Robot.RadarHeading) + 180; if (Robot.RadarTurnRemaining == 0) { if (scanLeft) { Robot.SetRadarHeadingTo(degrees + 45); scanLeft = false; } else { Robot.SetRadarHeadingTo(degrees - 45); scanLeft = true; } } //Robot.SetRadarHeadingTo(degrees - 45); //Robot.SetRadarHeadingTo(degrees + 45); }
/// <summary> /// Draws the employees' collision boxes based on world position. Use this to debug any pathing or collision problems. /// </summary> /// <param name="renderer">Renderer.</param> private void DrawEmployeCollisionBoxes(Renderer renderer) { foreach (var employee in simulationManager.TrackedEmployees) { Vector projected1 = CoordinateHelper.WorldSpaceToScreenSpace(employee.CollisionBox.X, employee.CollisionBox.Y, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected2 = CoordinateHelper.WorldSpaceToScreenSpace(employee.CollisionBox.Right, employee.CollisionBox.Y, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected3 = CoordinateHelper.WorldSpaceToScreenSpace(employee.CollisionBox.X, employee.CollisionBox.Bottom, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); Vector projected4 = CoordinateHelper.WorldSpaceToScreenSpace(employee.CollisionBox.Right, employee.CollisionBox.Bottom, CoordinateHelper.ScreenOffset, CoordinateHelper.ScreenProjectionType.Orthogonal); projected1 -= Camera.Position; projected2 -= Camera.Position; projected3 -= Camera.Position; projected4 -= Camera.Position; renderer.SetDrawColor(8, 255, 8, 255); Primitive.DrawLine(renderer, (int)projected1.X, (int)projected1.Y, (int)projected2.X, (int)projected2.Y); // top left to top right Primitive.DrawLine(renderer, (int)projected1.X, (int)projected1.Y, (int)projected3.X, (int)projected3.Y); // top left to bottom left Primitive.DrawLine(renderer, (int)projected2.X, (int)projected2.Y, (int)projected4.X, (int)projected4.Y); // top right to bottom right Primitive.DrawLine(renderer, (int)projected3.X, (int)projected3.Y, (int)projected4.X, (int)projected4.Y); // bottom left to bottom right //Primitive.DrawLine(renderer, employee.CollisionBox.X, employee.CollisionBox.Y, employee.CollisionBox.Right, employee.CollisionBox.Y); //Primitive.DrawLine(renderer, employee.CollisionBox.X, employee.CollisionBox.Y, employee.CollisionBox.X, employee.CollisionBox.Bottom); //Primitive.DrawLine(renderer, employee.CollisionBox.Right, employee.CollisionBox.Y, employee.CollisionBox.Right, employee.CollisionBox.Bottom); //Primitive.DrawLine(renderer, employee.CollisionBox.X, employee.CollisionBox.Bottom, employee.CollisionBox.Right, employee.CollisionBox.Bottom); renderer.SetDrawColor(0, 0, 0, 255); } }
public void InValidCoordinate() { Plateau plateau = new Plateau(new Coordinate(1, 1)); Assert.False(CoordinateHelper.IsValidCoordinate(plateau.plateauCoordinate, new Coordinate(-1, 3))); Assert.False(CoordinateHelper.IsValidCoordinate(plateau.plateauCoordinate, new Coordinate(-1, 4))); }
/** * Checks whether nearby blocks are needed. */ public bool HasNearbyBlocks() { if (!this.CanTick()) { return(this.hasNearbyBlocks); } if (!this.requiresNearbyBlocks) { return(this.hasNearbyBlocks = true); } World world = GameManager.Instance.World; bool namesFound = true; bool tagsFound = true; if (this.nearbyBlockNames.Count > 0) { namesFound = CoordinateHelper.EnoughBlocksInCoordinatesThatAre(world, this.nearbyBlockCoords, this.nearbyBlockNames, this.nearbyBlocksNeeded); } if (this.nearbyBlockTags.Count > 0) { tagsFound = CoordinateHelper.EnoughBlocksInCoordinatesThatHaveTags(world, this.nearbyBlockCoords, this.nearbyBlockTags, this.nearbyBlocksNeeded, this.nearbyBlockRequireAllTags); } return(this.hasNearbyBlocks = (tagsFound & namesFound)); }
public PpmWorker() { _coordinateHelper = new CoordinateHelper(); _ppmPoints = new PpmPoint[20]; EventsHelper.ChangeAerodromeEvent += ChangeAerodrome; EventsHelper.OutLineFromLastPointEvent += OutLineFromLastPointEvent; }
public void PlaceObject() { if (curObject != null) { MoveObject(); curObject.SetPosition(CoordinateHelper.UnityCoordToWWCoord(curObject.transform.position)); if (!ManagerRegistry.Instance.GetAnInstance <SceneGraphManager>().Add(curObject)) { Destroy(curObject.gameObject); // If the object collided with another, destroy it. } else { if (curObject.gameObject.layer == 8 || curObject.gameObject.layer == 9) { ManagerRegistry.Instance.GetAnInstance <WWAIManager>().RefreshGrid(); } else if (curObject.gameObject.layer == 10) { WWSeeker script = curObject.GetComponent <WWSeeker>(); script.Place(); } } curObject = null; } }
public void UpdateElement(Document document, ElementId id) { if (document == null) { throw new ArgumentNullException(nameof(document)); } if (document.IsFamilyDocument) { PostWarningIsFamilyDocument(document, id); } else { Element foundation = document.GetElement(id); if (foundation.Location != null) { if (foundation.Location is LocationPoint locationPoint) { XYZ location = CoordinateHelper.GetWorldCoordinates(document, locationPoint.Point); UpdateParameters(foundation, location); } } } }
static void drawRoadGizmo(GameObject terr, GizmoType gizmoType) { if (terr.name == "Terrain" && roadBuilt && CityGeneratorUI.DebugMode) { // Draw gizmos... for (int i = 0; i < (int)PreviewRoads.NrRoads; i++) { if (roads [i].getRoadType() == RoadTypes.HIGHWAY) { Gizmos.color = Color.blue; } else { Gizmos.color = Color.yellow; } Vector3 n1 = new Vector3(roads [i].n1.x, CoordinateHelper.worldToTerrainHeight(roads [i].n1) + 3, roads [i].n1.y); Vector3 n2 = new Vector3(roads [i].n2.x, CoordinateHelper.worldToTerrainHeight(roads [i].n2) + 3, roads [i].n2.y); Gizmos.DrawLine(n1, n2); Gizmos.color = Color.green; Gizmos.DrawSphere(n1, 1); Gizmos.DrawSphere(n2, 1); } } }
public async Task <Result <IEnumerable <Party> > > RequestPartyWithFilter() { Result <IEnumerable <Party> > requestResult = new Result <IEnumerable <Party> >(); Coordinates coordinates = await CoordinateHelper.GetCoordinates(); try { //Format coordinates var uri = $"?lat={coordinates.Latitude}&lon={coordinates.Longitude}&radius={_storageService.Storage.FilterRadius}" .Replace(",", "."); //Backend does not like , in the request requestResult = await _clientService.SendRequest <IEnumerable <Party> >("api/party", RestType.Get, urlQuery : uri, token : Token?.AccessToken); } catch (Exception e) { DebugHelper.PrintDebug(DebugType.Error, "Fetching parties failed.\n" + e); requestResult.RequestFailedToException = true; } await HandleCaching(requestResult, PartyListType.Local); //Check if the request was a success SetNearParties(requestResult.Data); return(requestResult); }
private void TryPlaceDoor(Vector3 hitPoint) { Debug.Log("TryPlaceDoor called."); Coordinate coord = CoordinateHelper.UnityCoordToWWCoord(hitPoint); List <WWObject> objects = ManagerRegistry.Instance.GetAnInstance <SceneGraphManager>().GetObjectsInCoordinateIndex(coord); Debug.Log("objects count " + objects.Count); foreach (WWObject obj in objects) { Debug.Log(" object type " + obj.ResourceMetadata.wwObjectMetadata.type); if (obj.ResourceMetadata.wwObjectMetadata.type == WWType.Tile) { Debug.Log("A tile was in the coordinate"); if (curObject.ResourceMetadata.wwObjectMetadata.type == WWType.Door) { Debug.Log("The current Object is a door"); if (ManagerRegistry.Instance.GetAnInstance <SceneGraphManager>().AddDoor((Door)curObject, (Tile)obj, hitPoint)) { curObject = null; } } } } }
private void TrackForeMove(Body body, Joint head, Joint handLeft, Joint handRight) { CameraSpacePoint newPoint = default(CameraSpacePoint); if (IsHandInInitialGesture(body.HandRightState)) { newPoint = handRight.Position; Debug.WriteLine("Force hand: Right"); } else if (IsHandInInitialGesture(body.HandLeftState)) { newPoint = handLeft.Position; Debug.WriteLine("Force hand: Left"); } if (newPoint != default(CameraSpacePoint)) { var distance = CoordinateHelper.GetDistance(newPoint, _lastHandPosition); if (_handTrackedCount > 0 && distance > 0.15F) { Debug.WriteLine("oldPoint: x={0} y={1} z={2}", _lastHandPosition.X, _lastHandPosition.Y, _lastHandPosition.Z); Debug.WriteLine("newPoint: x={0} y={1} z={2}", newPoint.X, newPoint.Y, newPoint.Z); ResetTrackingCounters(1); Debug.WriteLine("Reseted in order ot distance: {0}", distance); } _lastHeadPosition = _lastHeadPosition.GetAccumulatedAvarage(head.Position, ref _headTrackedCount); _lastHandPosition = _lastHandPosition.GetAccumulatedAvarage(newPoint, ref _handTrackedCount); Debug.WriteLine("Forse tracked: {0} Frame: {1}", _handTrackedCount, _frameCount); } if (CanFireForesMove()) { var handPosition = _lastHandPosition; var headPosition = _lastHeadPosition; // ZY Projection var headZY = headPosition.GetProjectionForZY(); var handZY = handPosition.GetProjectionForZY(); var y = CoordinateHelper.FindPointProjection(headZY, handZY); // XZ Projection var x = CoordinateHelper.FindPointProjection(headPosition.GetProjectionForXZ(), handPosition.GetProjectionForXZ(), y); var point = new Point { X = x, Y = y }; ForceApplying.SafeRise(this, point); Debug.WriteLine("Force Point: x={0} y={1}", point.X, point.Y); ResetTrackingCounters(); } else if (CanFireForesDispel()) { ForceDispel.SafeRise(this); ResetTrackingCounters(); } }
/// <summary> /// Generate new roads based on an existing one. /// </summary> /// <param name="oldRoad">Predecessor road</param> /// <returns>A list of new roads</returns> public List <Edge> generateNewRoads(Edge oldRoad) { List <Edge> newBranches = new List <Edge>(); // Get the growth rule we are used based on the old edge's end point int growthRule = CoordinateHelper.worldToGrowth(oldRoad.n2.x, oldRoad.n2.y); switch (growthRule) { case GrowthRuleGenerator.red: currentRule = basicRule; break; case GrowthRuleGenerator.green: currentRule = newYorkRule; break; case GrowthRuleGenerator.blue: currentRule = parisRule; break; default: Debug.LogError("Invalid Growth Rule"); break; } newBranches.AddRange(generateBranches((oldRoad.getRoadType() == RoadTypes.HIGHWAY)? BranchType.HIGHWAY_TO_HIGHWAY : BranchType.STREET_TO_STREET, oldRoad)); newBranches.AddRange(generateBranches(BranchType.ANY_ROAD_TO_STREET, oldRoad)); return(newBranches); }
public override void Run() { Robot.BodyColor = System.Drawing.Color.Pink; if (Robot.RadarTurnRemaining == 0) { Robot.SetTurnRadarLeft(360); } double xMiddle = Robot.BattleFieldWidth / 2; double yMiddle = Robot.BattleFieldHeight / 2; if (!isTurning && !isDriving) { Robot.SetTankHeadingTo(CoordinateHelper.GetAngle(Robot.X, Robot.Y, xMiddle, yMiddle)); isTurning = true; } else if (Robot.TurnRemaining == 0 && !isDriving) { Robot.SetAhead(200); isDriving = true; } else if (Robot.DistanceRemaining == 0 && Robot.TurnRemaining == 0) { Robot.CurrentPhase = RoboPhase.WallRush; Robot.TargetEnemyName = null; Robot.AttackerEnemyName = null; } }
/// <summary> /// Returns a boolean that tells if the two endpoints in input are valid endpoints for a road. /// </summary> /// <param name="n1"></param> /// <param name="n2"></param> /// <returns></returns> private static bool areNodesOK(Node n1, Node n2, RoadTypes roadType) { float distance = (n1.pos - n2.pos).magnitude; float roadSlope = (float)Mathf.Abs(CoordinateHelper.worldToTerrainHeight(n2) - CoordinateHelper.worldToTerrainHeight(n1)) / (float)distance; float maxSlope = (roadType == RoadTypes.HIGHWAY) ? CityGenerator.highwayMaxSlope : CityGenerator.streetMaxSlope; return((roadSlope <= maxSlope) && !isNodeUnderWater(n2) && CoordinateHelper.validEndPoint(n2)); }
/// <summary> /// Set the position of this WWObject and update the coordinate. /// </summary> /// <param name="coordinate">The coordinate to set</param> public void SetPosition(Coordinate coordinate) { if (ResourceMetadata.wwObjectMetadata.type == WWType.Tile) { coordinate.SnapToGrid(); } SetPosition(CoordinateHelper.WWCoordToUnityCoord(coordinate)); }