private void BuildGrid() { for (float yCoordinate = this.comShipMovement.viewportMinY; yCoordinate <= this.comShipMovement.viewportMaxY; yCoordinate += this.pointSeparation) { for (float xCoordinate = this.comShipMovement.viewportMinX; xCoordinate <= this.comShipMovement.viewportMaxX; xCoordinate += this.pointSeparation) { //TODO: JPS: This sets z to -10 for some reason. Why? Vector3 currentPointPosition = this.comShipMovement.renderCamera.ViewportToWorldPoint(new Vector3(xCoordinate, yCoordinate, 0)); Vector3 adjustedPointPosition = new Vector3(currentPointPosition.x, currentPointPosition.y, 0); //Point currentPoint = new Point(adjustedPointPosition, this.numberOfScanIterations); GameObject pointObject = Instantiate(this.navigationPointPrefab, adjustedPointPosition, new Quaternion()) as GameObject; NavigationPoint navPoint = pointObject.GetComponent <NavigationPoint>(); navPoint.InitializePoint(adjustedPointPosition, this.numberOfScanIterations); this.grid.Add(navPoint); //navPoint.pointReference = this.grid.Last(); //JPS Can't I just use currentPoint? } } }
private void BuildBorders() { float borderLength = this.borderWidth * this.pointSeparation; //Top Border for (float rowIndex = 0; rowIndex < this.borderWidth; rowIndex++) { for (float xCoordinate = this.comShipMovement.viewportMinX - borderLength; xCoordinate <= this.comShipMovement.viewportMaxX + borderLength; xCoordinate += this.pointSeparation) { //TODO: JPS: This sets z to -10 for some reason. Why? Vector3 currentPointPosition = this.comShipMovement.renderCamera.ViewportToWorldPoint(new Vector3(xCoordinate, this.comShipMovement.viewportMaxY + (this.pointSeparation * (rowIndex + 1)), 0)); Vector3 adjustedPointPosition = new Vector3(currentPointPosition.x, currentPointPosition.y, 0); //Point currentPoint = new Point(adjustedPointPosition, 1); //currentPoint.dangerScore = 1; GameObject pointObject = Instantiate(this.navigationPointPrefab, adjustedPointPosition, new Quaternion()) as GameObject; NavigationPoint navPoint = pointObject.GetComponent <NavigationPoint>(); navPoint.InitializePoint(adjustedPointPosition, 1); navPoint.dangerScore = 1; //navPoint.pointReference = currentPoint; } } //Bottom Border for (float rowIndex = 0; rowIndex < this.borderWidth; rowIndex++) { for (float xCoordinate = this.comShipMovement.viewportMinX - borderLength; xCoordinate <= this.comShipMovement.viewportMaxX + borderLength; xCoordinate += this.pointSeparation) { //TODO: JPS: This sets z to -10 for some reason. Why? Vector3 currentPointPosition = this.comShipMovement.renderCamera.ViewportToWorldPoint(new Vector3(xCoordinate, this.comShipMovement.viewportMinY - (this.pointSeparation * (rowIndex + 1)), 0)); Vector3 adjustedPointPosition = new Vector3(currentPointPosition.x, currentPointPosition.y, 0); //Point currentPoint = new Point(adjustedPointPosition, 1); //currentPoint.dangerScore = 1; GameObject pointObject = Instantiate(this.navigationPointPrefab, adjustedPointPosition, new Quaternion()) as GameObject; NavigationPoint navPoint = pointObject.GetComponent <NavigationPoint>(); navPoint.InitializePoint(adjustedPointPosition, 1); navPoint.dangerScore = 1; //navPoint.pointReference = currentPoint; } } //Left Border for (float rowIndex = 0; rowIndex < this.borderWidth; rowIndex++) { for (float yCoordinate = this.comShipMovement.viewportMinY - borderLength; yCoordinate <= this.comShipMovement.viewportMaxY + borderLength; yCoordinate += this.pointSeparation) { //TODO: JPS: This sets z to -10 for some reason. Why? Vector3 currentPointPosition = this.comShipMovement.renderCamera.ViewportToWorldPoint(new Vector3(this.comShipMovement.viewportMinX - (this.pointSeparation * (rowIndex + 1)), yCoordinate, 0)); Vector3 adjustedPointPosition = new Vector3(currentPointPosition.x, currentPointPosition.y, 0); //Point currentPoint = new Point(adjustedPointPosition, 1); //currentPoint.dangerScore = 1; GameObject pointObject = Instantiate(this.navigationPointPrefab, adjustedPointPosition, new Quaternion()) as GameObject; NavigationPoint navPoint = pointObject.GetComponent <NavigationPoint>(); navPoint.InitializePoint(adjustedPointPosition, 1); navPoint.dangerScore = 1; //navPoint.pointReference = currentPoint; } } //Right Border for (float rowIndex = 0; rowIndex < this.borderWidth; rowIndex++) { for (float yCoordinate = this.comShipMovement.viewportMinY - borderLength; yCoordinate <= this.comShipMovement.viewportMaxY + borderLength; yCoordinate += this.pointSeparation) { //TODO: JPS: This sets z to -10 for some reason. Why? Vector3 currentPointPosition = this.comShipMovement.renderCamera.ViewportToWorldPoint(new Vector3(this.comShipMovement.viewportMaxX + (this.pointSeparation * rowIndex), yCoordinate, 0)); Vector3 adjustedPointPosition = new Vector3(currentPointPosition.x, currentPointPosition.y, 0); //Point currentPoint = new Point(adjustedPointPosition, 1); //currentPoint.dangerScore = 1; GameObject pointObject = Instantiate(this.navigationPointPrefab, adjustedPointPosition, new Quaternion()) as GameObject; NavigationPoint navPoint = pointObject.GetComponent <NavigationPoint>(); navPoint.InitializePoint(adjustedPointPosition, 1); navPoint.dangerScore = 1; //navPoint.pointReference = currentPoint; } } }