protected string CheckAtackDirection(PointBase A, PointBase B) { if (A.positionY > B.positionY) { if (A.positionY - B.positionY >= Mathf.Abs(A.positionX - B.positionY)) { return("up"); } else if (A.positionX >= B.positionX) { return("right"); } else { return("left"); } } else { if (B.positionY - A.positionY >= Mathf.Abs(A.positionX - B.positionY)) { return("down"); } else if (A.positionX >= B.positionX) { return("right"); } else { return("left"); } } }
public void playOneSound(AudioClip value, PointBase unit) { AudioSource currentCanal = null; currentCanal = canalDispetcher; if (unit != null) { if (unit.massiveIndex == capitanIndex) { currentCanal = canalAlpha; } else if (unit.massiveIndex == soldierIndex) { currentCanal = canalDelta; } if (unit.massiveIndex == medicIndex) { currentCanal = canalOmega; } if (unit.lastSound != value && !currentCanal.isPlaying) { currentCanal.clip = value; currentCanal.Play(); //currentCanal.PlayOneShot(value); //unit.lastSound = value; } } else if (!currentCanal.isPlaying) { currentCanal.clip = value; currentCanal.Play(); //currentCanal.PlayOneShot(value); } }
public void TestMethodLineFitted() { Random rnd = new Random(DateTime.Now.Millisecond); //generate point set alone one line (10 points List <ElementBase> pSet = new List <ElementBase>(); PointBase start = new PointBase(new List <ElementBase> { c1 }); start.Point = new Mat(3, 1, MatType.CV_64FC1, new double[] { 0, 0, 1 }); for (int i = 0; i < 10; i++) { PointBase next = new PointBase(new List <ElementBase> { c1 }); next.Point = start.Point + l0055.Vector * i + new Mat(3, 1, MatType.CV_64FC1, new double[] { rnd.NextDouble() - 1, rnd.NextDouble() - 1, 1 }); pSet.Add(next); } LineFitted lf = new LineFitted(pSet); Trace.WriteLine(lf.Coefficient()); }
public void Initialize() { p00 = new PointBase(new System.Collections.Generic.List <ElementBase> { c1 }); p55 = new PointBase(new System.Collections.Generic.List <ElementBase> { c1 }); p05 = new PointBase(new System.Collections.Generic.List <ElementBase> { c1 }); p50 = new PointBase(new System.Collections.Generic.List <ElementBase> { c1 }); p00.Point.SetArray(0, 0, new double[] { 0, 0 }); //good mat initilizer p55.Point.SetArray(0, 0, new double[] { 5, 5 }); //good mat initilizer p05.Point = new Mat(3, 1, MatType.CV_64FC1, new double[] { 0, 5, 1 }); //good mat initilizer p50.Point = new Mat(3, 1, MatType.CV_64FC1, new double[] { 5, 0, 1 }); //good mat initilizer l0000 = new LineBase(new System.Collections.Generic.List <ElementBase> { p00, p00 }); l0550 = new LineBase(new System.Collections.Generic.List <ElementBase> { p05, p50 }); l0055 = new LineBase(new System.Collections.Generic.List <ElementBase> { p00, p55 }); Mat coeff0550 = l0550.Coefficient(); Mat coeff0055 = l0055.Coefficient(); }
public virtual IPoint CreatePoint(object[] obj) { IPoint p = new PointBase((double)obj[0], (double)obj[1]); int[] col = new int[3]; for (int i = 0; i < col.Length; i++) { double c = (double)obj[i + 2]; int x = (int)(c * 255); if (x < 0) { x = 0; } if (x > 255) { x = 255; } col[i] = x; } Color color = Color.FromArgb(255, col[0], col[1], col[2]); double s = (double)obj[5]; ColoredCircle circle = new ColoredCircle((int)s, color); p.Properties = circle; return(p); }
/// <summary> /// Use this method to request details about a selected point /// </summary> /// <param name="dataSet"></param> /// <param name="username"></param> /// <param name="basicPoint"></param> /// <param name="pointsSource"></param> /// <returns></returns> public Point RequestPointDetails(string dataSet, string username, PointBase basicPoint, PointsSource pointsSource = PointsSource.Cassandra) { int dataSetID = this.userRepository.GetDatasetID(username, dataSet); if (dataSetID == -1) { throw new ApplicationException($"User do not have a dataset with name {dataSet}"); } //datasource can be switched between current dataPointsRepository and other repos IDataPointsRepository detailsSource = this.dataPointsRepository; switch (pointsSource) { case PointsSource.Geoserver: detailsSource = new PostgreSQLDataPointsRepository(); break; case PointsSource.Cassandra: default: break; } return(detailsSource.GetPointDetails(dataSetID, basicPoint)); }
private List <Row> selectPointDetails(int dataSetID, PointBase basicPoint) { CassandraQueryBuilder queryBuilder = new CassandraQueryBuilder() { QueryType = CassandraQueryBuilder.QueryTypes.Select }; //update: do not use latitude and longitude to search for points details queryBuilder.TableName = "points_by_dataset"; queryBuilder.ClausesList.Add(new BuilderTuple("dataSetID", "dataset_id", CassandraQueryBuilder.Clauses.Equals)); queryBuilder.ClausesList.Add(new BuilderTuple("number", "number", CassandraQueryBuilder.Clauses.Equals)); executionInstance.UserDefinedTypeMappings.Define(UdtMap.For <PointDisplacementType>("points_displacements")); var preparedStatement = executionInstance.GetPreparedStatement("points_by_dataset", queryBuilder); var result = executionInstance.ExecuteQuery(new { dataSetID, number = basicPoint.Number }, preparedStatement).Result; return(result); }
public void FindObject(PointBase obj) { isObjectFound = true; strength += obj.bonusStrength; intellect += obj.bonusIntellect; social += obj.bonusSocial; health += obj.bonusHealth; }
public LineBase(List <ElementBase> dependencies) : base(dependencies) { //perform downcasting , lack of exception handling m_end1 = dependencies.First() as PointBase; m_end2 = dependencies.Last() as PointBase; OnValueChanged(this, null); }
public void FindObject(PointBase obj) { isObjectFound = true; strength += obj.bonusStrength; intellect+= obj.bonusIntellect; social += obj.bonusSocial; health += obj.bonusHealth; }
public HTuple PiexlGrayval(PointBase point)//取得某點的pixel值 直接函式輸出 { HTuple Grayval; if (Image != null) HOperatorSet.GetGrayval(Image, point.row, point.col, out Grayval); else Grayval = "null"; return Grayval; }
private void CreatMatchingModel_window_HMouseMove(object sender, HalconDotNet.HMouseEventArgs e) { PointBase mousePosition = new PointBase(); //取得滑鼠在視窗上的位置 mousePosition.GetMposition(CreateMatchingModel_window.HalconWindow); //顯示位置 MouseXY.Text = "Mouse(" + mousePosition.col.ToString() + "," + mousePosition.row.ToString() + ")"; //顯示滑鼠位置的灰階值 pixelvalue.Text = "pixelvalue =" + CreateMatchingModel_window_image.PiexlGrayval(mousePosition).ToString(); }
/// <summary> /// Constructor /// </summary> /// <param name="series">Base series</param> public SeriesGraph(SeriesBase series) { this.series = series; points.Clear(); for (int i = 0; i < series.Count; i++) { IPoint p = new PointBase(series[i, 0], series[i, 1]); points.Add(p); } }
void AddFigurePoint(IniFile.Section section, PointBase point, int index) { var pointSection1 = sectionLookup["Point" + section["Points" + index.ToString()]]; point.Name = pointSection1["Name"]; point.X = pointSection1.ReadDouble("X"); point.Y = pointSection1.ReadDouble("Y"); SetPointStyle(pointSection1, point); var pointIndex = GetPointIndex(section, index); points[pointIndex] = point; }
protected bool checkObjectEncounter(PointBase unit) { bool findUnit = false; float distance = checkDistance(this, unit); float intellectBonus = 1; if (unit.isObjectSearching) { intellectBonus = SharedVars.Inst.checkImprove; } if (distance <= intellectBonus * unit.intellect / 10 && unit.health > 0) { findUnit = true; health = 0; unit.FindObject(this); } return(findUnit); }
protected bool checkEncounter(PointBase unit) { bool findUnit = false; float distance = checkDistance(this, unit); string atackDirection = CheckAtackDirection(this, unit); if (distance <= intellect / 10 && unit.health > 0) { findUnit = true; if (unit.readyDirection == "") { unit.GetDamage(strength * Time.deltaTime); } else if (atackDirection == unit.readyDirection) { unit.MakeShot(this); } else { unit.GetDamage(2 * strength * Time.deltaTime); } selectTarget(unit.positionX, unit.positionY); } float distanceModificator = 1; if (atackDirection == unit.readyDirection) { distanceModificator = 2; } else if (unit.readyDirection != "") { distanceModificator = 0.5f; } if (distance <= distanceModificator * unit.intellect / 10 && unit.health > 0) { unit.MakeShot(this); selectTarget(unit.positionX, unit.positionY); } return(findUnit); }
void OnGUI() { PointBase unit = gameController.GetUnit(0); health0.text = "Health:" + unit.health; strength0.text = "Strength:" + unit.strength; intellect0.text = "Intellect:" + unit.intellect; social0.text = "Social:" + unit.social + " " + unit.readyDirection; unit = gameController.GetUnit(1); health1.text = "Health:" + unit.health; strength1.text = "Strength:" + unit.strength; intellect1.text = "Intellect:" + unit.intellect; social1.text = "Social:" + unit.social + " " + unit.readyDirection; unit = gameController.GetUnit(2); health2.text = "Health:" + unit.health; strength2.text = "Strength:" + unit.strength; intellect2.text = "Intellect:" + unit.intellect; social2.text = "Social:" + unit.social + " " + unit.readyDirection; }
protected void createOperationMap() { mans = new PointBase[enemyNumber + 3 + objectsNumber + 1]; mans[0] = new PointBase("capitan", "team", 15, 15, this, 0); mans[0].strength = Random.Range(1, SharedVars.Inst.charMax); mans[0].intellect = Random.Range(1, SharedVars.Inst.charMax); mans[0].social = Random.Range(1, SharedVars.Inst.charMax); capitanIndex = 0; mans[1] = new PointBase("soldier", "team", 5, 10, this, 1); mans[1].strength = Random.Range(1, SharedVars.Inst.charMax); mans[1].intellect = Random.Range(1, SharedVars.Inst.charMax); mans[1].social = Random.Range(1, SharedVars.Inst.charMax); soldierIndex = 1; mans[2] = new PointBase("medic", "team", 10, 5, this, 2); mans[2].strength = Random.Range(1, SharedVars.Inst.charMax); mans[2].intellect = Random.Range(1, SharedVars.Inst.charMax); mans[2].social = Random.Range(1, SharedVars.Inst.charMax); medicIndex = 2; for (int i = 3; i < enemyNumber + 3; i++) { mans[i] = new PointBase("enemy" + i.ToString(), "enemy", Random.Range(0.1f, 0.9f) * SharedVars.Inst.operationMapSize, Random.Range(0.1f, 0.9f) * SharedVars.Inst.operationMapSize, this, i); mans[i].startEndlessWalking(); } for (int i = enemyNumber + 3; i < enemyNumber + 3 + objectsNumber; i++) { mans[i] = new PointBase("object" + i.ToString(), "object", Random.Range(0.1f, 0.9f) * SharedVars.Inst.operationMapSize, Random.Range(0.1f, 0.9f) * SharedVars.Inst.operationMapSize, this, i); } mans[mans.Length - 1] = new PointBase("mission", "mission", Random.Range(0.75f, 0.9f) * SharedVars.Inst.operationMapSize, Random.Range(0.75f, 0.9f) * SharedVars.Inst.operationMapSize, this, mans.Length - 1); missionIndex = mans.Length - 1; allteamPoints = createPoints(allteamPoints, screen3); capitanPoints = createPoints(capitanPoints, screen0); soldierPoints = createPoints(soldierPoints, screen1); medicPoints = createPoints(medicPoints, screen2); mans[capitanIndex].selectFinalTarget(mans[mans.Length - 1].positionX, mans[mans.Length - 1].positionY); mans[soldierIndex].selectFinalTarget(mans[mans.Length - 1].positionX, mans[mans.Length - 1].positionY); mans[medicIndex].selectFinalTarget(mans[mans.Length - 1].positionX, mans[mans.Length - 1].positionY); }
public void run() { M1DP_form.Measure_Image.SetImage = M1DP_in.O_T[M1DP_form.index_img[whichpicture.SelectedIndex].i].OImage[M1DP_form.index_img[whichpicture.SelectedIndex].j]; switch (M1DP_form.measuretype) { case (int)MeasureType.pos: //如果toolWindow視窗裡有影像才執行 if (M1DP_form.Measure_Image.GetImage != null) { HOperatorSet.GenEmptyObj(out M1DP_form.ho_CrossFirst); HOperatorSet.GenMeasureRectangle2(M1DP_in.region_line.line_rec.row, M1DP_in.region_line.line_rec.column, M1DP_in.region_line.line_rec.phi, M1DP_in.region_line.line_rec.length1, ROIWeight_trackBar.Value, toolWindow.WindowImage.GetWidth, toolWindow.WindowImage.GetHeight, "nearest_neighbor", out M1DP_form.hv_MeasureHandle); HOperatorSet.MeasurePos(M1DP_form.Measure_Image.GetImage, M1DP_form.hv_MeasureHandle, M1DP_form.sigma, M1DP_form.threshold, M1DP_form.transition_pos, M1DP_form.select, out M1DP_form.hv_RowEdgeFirst, out M1DP_form.hv_ColumnEdgeFirst, out M1DP_form.hv_AmplitudeFirst, out M1DP_form.hv_Distance); M1DP_form.ho_CrossFirst.Dispose(); HOperatorSet.CloseMeasure(M1DP_form.hv_MeasureHandle); M1DP_out.dstfirstpoint.Clear(); for (int i = 0; i < M1DP_form.hv_RowEdgeFirst.Length; i++) { PointBase PB_temp = new PointBase(); PB_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; M1DP_out.dstfirstpoint.Add(PB_temp); } } break; case (int)MeasureType.pair: if (M1DP_form.Measure_Image.GetImage != null) { HOperatorSet.GenEmptyObj(out M1DP_form.ho_CrossFirst); HOperatorSet.GenEmptyObj(out M1DP_form.ho_CrossSecond); HOperatorSet.GenMeasureRectangle2(M1DP_in.region_line.line_rec.row, M1DP_in.region_line.line_rec.column, M1DP_in.region_line.line_rec.phi, M1DP_in.region_line.line_rec.length1, ROIWeight_trackBar.Value, toolWindow.WindowImage.GetWidth, toolWindow.WindowImage.GetHeight, "nearest_neighbor", out M1DP_form.hv_MeasureHandle); HOperatorSet.MeasurePairs(M1DP_form.Measure_Image.GetImage, M1DP_form.hv_MeasureHandle, M1DP_form.sigma, M1DP_form.threshold, M1DP_form.transition_pair, M1DP_form.select, out M1DP_form.hv_RowEdgeFirst, out M1DP_form.hv_ColumnEdgeFirst, out M1DP_form.hv_AmplitudeFirst, out M1DP_form.hv_RowEdgeSecond, out M1DP_form.hv_ColumnEdgeSecond, out M1DP_form.hv_AmplitudeSecond, out M1DP_form.hv_PinWidth, out M1DP_form.hv_PinDistance); HOperatorSet.CloseMeasure(M1DP_form.hv_MeasureHandle); M1DP_out.dstfirstpoint.Clear(); M1DP_out.dstsecondpoint.Clear(); for (int i = 0; i < M1DP_form.hv_RowEdgeFirst.Length; i++) { PointBase PB1_temp = new PointBase(); PointBase PB2_temp = new PointBase(); PB1_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB1_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; PB2_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB2_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; M1DP_out.dstfirstpoint.Add(PB1_temp); M1DP_out.dstsecondpoint.Add(PB2_temp); } } break; } }
/// <summary> /// Adds new point /// </summary> /// <param name="x">X - coordinate</param> /// <param name="y">Y - coordinate</param> public void AddXY(double x, double y) { IPoint p = new PointBase(x, y); pointList.Add(p); }
public void playOneSound(AudioClip value, PointBase unit) { AudioSource currentCanal = null; currentCanal = canalDispetcher; if(unit!=null) { if(unit.massiveIndex == capitanIndex) { currentCanal = canalAlpha; } else if(unit.massiveIndex == soldierIndex) { currentCanal = canalDelta; } if(unit.massiveIndex == medicIndex) { currentCanal = canalOmega; } if(unit.lastSound!=value && !currentCanal.isPlaying) { currentCanal.clip = value; currentCanal.Play(); //currentCanal.PlayOneShot(value); //unit.lastSound = value; } } else if (!currentCanal.isPlaying) { currentCanal.clip = value; currentCanal.Play(); //currentCanal.PlayOneShot(value); } }
public GridLine(PointBase start, PointBase end, int thickness = 1) { Start = start; End = end; Thickness = thickness; }
public float checkDistance(PointBase A, PointBase B) { return Mathf.Sqrt((A.positionX - B.positionX) * (A.positionX - B.positionX) + (A.positionY - B.positionY) * (A.positionY - B.positionY)); }
public bool Equals(PointBase <T> other) { return(other.x.Length == this.x.Length && other.x.Zip(this.x, (a, b) => a.Equals(b)).All(val => val)); }
protected bool checkEncounter(PointBase unit) { bool findUnit = false; float distance = checkDistance(this, unit); string atackDirection = CheckAtackDirection(this,unit); if(distance<=intellect/10 && unit.health>0) { findUnit = true; if(unit.readyDirection=="") { unit.GetDamage(strength*Time.deltaTime); } else if(atackDirection == unit.readyDirection) { unit.MakeShot(this); } else { unit.GetDamage(2*strength*Time.deltaTime); } selectTarget(unit.positionX, unit.positionY); } float distanceModificator = 1; if(atackDirection == unit.readyDirection) { distanceModificator = 2; } else if (unit.readyDirection!="") { distanceModificator = 0.5f; } if(distance<=distanceModificator*unit.intellect/10 && unit.health>0) { unit.MakeShot(this); selectTarget(unit.positionX, unit.positionY); } return findUnit; }
public void MakeShot(PointBase target) { target.GetDamage(strength*Time.deltaTime); game.playOneSound(game.snd_enemycontact,this); }
public Point GetPointDetails(int dataSetID, PointBase basicPoint) { var dataRows = selectPointDetails(dataSetID, basicPoint); return(convertRowSetToPointList(dataRows).FirstOrDefault()); }
private void TheVerticalLine_Activated(object sender, EventArgs e) { if (TVL_form.ifopenformornot == false) { TVL_form.ifopenformornot = true; TVL_form.SelectImage.Clear(); for (int i = 0; i < TVL_in.O_T.Count; i++) { for (int j = 0; j < TVL_in.O_T[i].OImage.Count; j++) { if (TVL_in.O_T[i].OImage[j] != null) { SelectImageNName M1S = new SelectImageNName(); M1S.Image = TVL_in.O_T[i].OImage[j]; M1S.ImageName = (string)TVL_in.O_T[i].OImageName[j]; TVL_form.SelectImage.Add(M1S); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; TVL_form.index_img.Add(ij_temp); } } } whichpicture.DataSource = null; whichpicture.DataSource = TVL_form.SelectImage; whichpicture.DisplayMember = "ImageName"; whichpicture.ValueMember = "Image"; for (int i = 0; i < TVL_in.O_T.Count; i++) { for (int j = 0; j < TVL_in.O_T[i].OPoint.Count; j++) { if (TVL_in.O_T[i].OPoint[j]!=null) { SelectPointNName SPNN = new SelectPointNName(); SPNN.Point = TVL_in.O_T[i].OPoint[j]; SPNN.PointName = (string)TVL_in.O_T[i].OPointName[j]; SPNN.circleorpoint = 0; TVL_form.SelectPoint1.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; TVL_form.index_1.Add(ij_temp); } } } for (int i = 0; i < TVL_in.O_T.Count; i++) { for (int j = 0; j < TVL_in.O_T[i].OCircle.Count; j++) { if (TVL_in.O_T[i].OCircle[j] != null) { SelectPointNName SPNN = new SelectPointNName(); PointBase P_temp = new PointBase(); P_temp.row = TVL_in.O_T[i].OCircle[j].row; P_temp.col = TVL_in.O_T[i].OCircle[j].column; SPNN.Point = P_temp; SPNN.PointName = TVL_in.O_T[i].OCircleName[j]; SPNN.circleorpoint = 1; TVL_form.SelectPoint1.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; TVL_form.index_1.Add(ij_temp); } } } whichpoint1.DataSource = null; whichpoint1.DataSource = TVL_form.SelectPoint1; whichpoint1.DisplayMember = "PointName"; whichpoint1.ValueMember = "Point"; for (int i = 0; i < TVL_in.O_T.Count; i++) { for (int j = 0; j < TVL_in.O_T[i].OPoint.Count; j++) { if (TVL_in.O_T[i].OPoint[j] != null) { SelectPointNName SPNN = new SelectPointNName(); SPNN.Point = TVL_in.O_T[i].OPoint[j]; SPNN.PointName = (string)TVL_in.O_T[i].OPointName[j]; SPNN.circleorpoint = 0; TVL_form.SelectPoint2.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; TVL_form.index_2.Add(ij_temp); } } } for (int i = 0; i < TVL_in.O_T.Count; i++) { for (int j = 0; j < TVL_in.O_T[i].OCircle.Count; j++) { if (TVL_in.O_T[i].OCircle[j] != null) { SelectPointNName SPNN = new SelectPointNName(); PointBase P_temp = new PointBase(); P_temp.row = TVL_in.O_T[i].OCircle[j].row; P_temp.col = TVL_in.O_T[i].OCircle[j].column; SPNN.Point = P_temp; SPNN.PointName = TVL_in.O_T[i].OCircleName[j]; SPNN.circleorpoint = 1; TVL_form.SelectPoint2.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; TVL_form.index_2.Add(ij_temp); } } } whichpoint2.DataSource = null; whichpoint2.DataSource = TVL_form.SelectPoint2; whichpoint2.DisplayMember = "PointName"; whichpoint2.ValueMember = "Point"; TVL_form.loadfinish = true; toolWindow.Clear_Object_disp(); TVL_form.src_Image.SetImage = (HObject)whichpicture.SelectedValue; PointBase temp1 = (PointBase)whichpoint1.SelectedValue; PointBase temp2 = (PointBase)whichpoint2.SelectedValue; TVL_form.hv_first_row = temp1.row; TVL_form.hv_first_col = temp1.col; TVL_form.hv_Second_row = temp2.row; TVL_form.hv_Second_col = temp2.col; HOperatorSet.GenCrossContourXld(out TVL_form.ho_Cross_firstpoint, TVL_form.hv_first_row, TVL_form.hv_first_col, 10, 0); HOperatorSet.GenCrossContourXld(out TVL_form.ho_Cross_secondpoint, TVL_form.hv_Second_row, TVL_form.hv_Second_col, 10, 0); toolWindow.Add_Object_disp(TVL_form.ho_Cross_firstpoint, "red", "margin", 3); toolWindow.Add_Object_disp(TVL_form.ho_Cross_secondpoint, "blue", "margin", 3); toolWindow.WindowImage.SetImage = TVL_form.src_Image.GetImage; toolWindow.WindowImage.GetImageSize(); toolWindow.showImage(); toolWindow1.WindowImage.SetImage = TVL_form.src_Image.GetImage; toolWindow1.WindowImage.GetImageSize(); toolWindow1.showImage(); } if (toolWindow.WindowImage.GetImage != null) toolWindow.showImage(); if (toolWindow1.WindowImage.GetImage != null) toolWindow1.showImage(); }
private void AddLocationPin(GeocodeResult result) { var point = new Point(result.Locations[0].Longitude, result.Locations[0].Latitude); if (resultsShapeLayer == null) { resultsShapeLayer = new GeometryLayer(MapInstance) { ID = "RESULTSLAYER" }; Style style = (Application.Current.Resources["PushPinArrowStyle"]) as Style; resultsShapeLayer.ItemsStyle = style; MapInstance.Layers.Add(resultsShapeLayer); } else { resultsShapeLayer.Clear(); } MapInstance.SetViewCenter(point, 12); //Add an arrow pin whose another point is an anchor of 0.5, 1.0; PointBase arrowPin = new PointBase { Point = point}; resultsShapeLayer.Add(arrowPin); }
private void PL_distance_Activated(object sender, EventArgs e) { if (setornot == false) { if (ifopenformornot == false) { ifopenformornot = true; SelectImage.Clear(); for (int i = 0; i < O_T.Count; i++) { for (int j = 0; j < O_T[i].OImage.Count; j++) { if (O_T[i].OImage[j] != null) { SelectImageNName M1S = new SelectImageNName(); M1S.Image = O_T[i].OImage[j]; M1S.ImageName = (string)O_T[i].OImageName[j]; SelectImage.Add(M1S); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; index_img.Add(ij_temp); } } } whichpicture.DataSource = null; whichpicture.DataSource = SelectImage; whichpicture.DisplayMember = "ImageName"; whichpicture.ValueMember = "Image"; for (int i = 0; i < O_T.Count; i++) { for (int j = 0; j < O_T[i].OPoint.Count; j++) { if (O_T[i].OPoint[j] != null) { SelectPointNName SPNN = new SelectPointNName(); SPNN.Point = O_T[i].OPoint[j]; SPNN.PointName = (string)O_T[i].OPointName[j]; SPNN.circleorpoint = 0; SelectPoint1.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; index_P1.Add(ij_temp); } } } for (int i = 0; i < O_T.Count; i++) { for (int j = 0; j < O_T[i].OCircle.Count; j++) { if (O_T[i].OCircle[j] != null) { SelectPointNName SPNN = new SelectPointNName(); PointBase P_temp = new PointBase(); P_temp.row = O_T[i].OCircle[j].row; P_temp.col = O_T[i].OCircle[j].column; SPNN.Point = P_temp; SPNN.PointName = O_T[i].OCircleName[j]; SPNN.circleorpoint = 1; SelectPoint1.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; index_C1.Add(ij_temp); } } } whichpoint1.DataSource = null; whichpoint1.DataSource = SelectPoint1; whichpoint1.DisplayMember = "PointName"; whichpoint1.ValueMember = "Point"; for (int i = 0; i < O_T.Count; i++) { for (int j = 0; j < O_T[i].OLine.Count; j++) { if (O_T[i].OLine[j] != null) { SelectLineNName SPNN = new SelectLineNName(); SPNN.Line = O_T[i].OLine[j]; SPNN.LineName = (string)O_T[i].OLineName[j]; SelectLine.Add(SPNN); index_ij ij_temp = new index_ij(); ij_temp.i = i; ij_temp.j = j; index_L1.Add(ij_temp); } } } whichLline.DataSource = null; whichLline.DataSource = SelectLine; whichLline.DisplayMember = "LineName"; whichLline.ValueMember = "Line"; loadfinish = true; toolWindow.Clear_Object_disp(); src_Image.SetImage = (HObject)whichpicture.SelectedValue; PointBase temp1 = (PointBase)whichpoint1.SelectedValue; Line temp2 = (Line)whichLline.SelectedValue; PLD.hv_first_row = temp1.row; PLD.hv_first_col = temp1.col; PLD.hv_row1 = temp2.row_start; PLD.hv_col1 = temp2.column_start; PLD.hv_row2 = temp2.row_end; PLD.hv_col2 = temp2.column_end; HOperatorSet.GenCrossContourXld(out PLD.ho_Cross_firstpoint, PLD.hv_first_row, PLD.hv_first_col, 10, 0); HOperatorSet.GenRegionLine(out PLD.ho_RegionLines, PLD.hv_row1, PLD.hv_col1, PLD.hv_row2, PLD.hv_col2); toolWindow.Add_Object_disp(PLD.ho_Cross_firstpoint, "red", "margin", 3); toolWindow.Add_Object_disp(PLD.ho_RegionLines, "green", "margin", 3); toolWindow.WindowImage.CopyImagetoThis(src_Image.GetImage); toolWindow.showImage(); } } else if (setornot == true) { if (ifopenformornot == false) { ifopenformornot = true; toolWindow.showImage(); } } }
public HTuple PiexlGrayval_Interpolated(PointBase point)//取得某點的pixel值(內插法) 直接函式輸出 { HTuple Grayval_Interpolated; if (Image != null) { HOperatorSet.GetImageSize(Image, out hv_Width, out hv_Height); if (point.row > 0 && point.row < hv_Height && point.col > 0 && point.col < hv_Width) HOperatorSet.GetGrayvalInterpolated(Image, point.row, point.col, "bilinear", out Grayval_Interpolated); else Grayval_Interpolated = "null"; } else { Grayval_Interpolated = "null"; } return Grayval_Interpolated; }
protected string CheckAtackDirection(PointBase A, PointBase B) { if(A.positionY>B.positionY) { if(A.positionY-B.positionY>=Mathf.Abs(A.positionX-B.positionY)) { return "up"; } else if(A.positionX>=B.positionX) { return "right"; } else { return "left"; } } else { if(B.positionY-A.positionY>=Mathf.Abs(A.positionX-B.positionY)) { return "down"; } else if(A.positionX>=B.positionX) { return "right"; } else { return "left"; } } }
private void MainWindow_HMouseMove(object sender, HMouseEventArgs e) { PointBase mousePosition = new PointBase(); mousePosition.col = (int)e.X; mousePosition.row = (int)e.Y; MouseX.Text = mousePosition.col.ToString(); MouseY.Text = mousePosition.row.ToString(); pixel.Text = Mainpicture_Base.PiexlGrayval(mousePosition).ToString(); }
protected bool checkObjectEncounter(PointBase unit) { bool findUnit = false; float distance = checkDistance(this, unit); float intellectBonus = 1; if(unit.isObjectSearching) { intellectBonus = SharedVars.Inst.checkImprove; } if(distance<=intellectBonus*unit.intellect/10 && unit.health>0) { findUnit = true; health = 0; unit.FindObject(this); } return findUnit; }
public Point GetPointDetails(int dataSetID, PointBase basicPoint) { try { Query query = new Query(Tables.metadataTableName) .Select("table_names") .Where("data_set_id", dataSetID); SqlResult queryResult = new SqlServerCompiler().Compile(query); string tableName = SqlExecutionInstance.ExecuteScalar (new NpgsqlCommand(queryResult.ToString().Replace("[", "").Replace("]", "")), null, new NpgsqlConnection(this.connectionString))?.ToString(); if (tableName == null) { return(null); } query = new Query(Tables.metadataTableName) .Select("time_references") .Where("data_set_id", dataSetID); queryResult = new SqlServerCompiler().Compile(query); long[] timeReferences = (long[])SqlExecutionInstance.ExecuteScalar (new NpgsqlCommand(queryResult.ToString().Replace("[", "").Replace("]", "")), null, new NpgsqlConnection(this.connectionString)); if (timeReferences == null) { return(null); } List <string> queryColumns = new List <string>(); for (int i = 0; i < timeReferences.Length; i++) { queryColumns.Add($"d_{i}"); } queryColumns.AddRange( UserDefinedTypeAttributeExtensions.GetUserDefinedColumnsNames(typeof(Tables.MetadataTableColumns))); query = new Query(tableName) .Select(queryColumns.ToArray()) .WhereRaw("geom && ST_Expand(ST_SetSRID(ST_MakePoint(?,?),4326),100)", basicPoint.Longitude, basicPoint.Latitude) .OrderByRaw("ST_SetSRID(ST_MakePoint(?,?),4326) <-> geom", basicPoint.Longitude, basicPoint.Latitude); queryResult = new SqlServerCompiler().Compile(query); using (var datasetResult = SqlExecutionInstance.ExecuteQuery( new NpgsqlCommand(queryResult.ToString() .Replace("[", "") .Replace("]", "") + " limit 1"), null, new NpgsqlConnection(this.connectionString), (command) => { return(new NpgsqlDataAdapter((NpgsqlCommand)command)); })) { var pointDetails = parsePointDetails(datasetResult.Tables[0].Rows, timeReferences); if (pointDetails == null) { CoreContainers.LogsRepository.LogWarning($"Nothing found for dataset id {dataSetID} - lat: {basicPoint.Latitude}, long: {basicPoint.Longitude}", Core.Database.Logs.LogTrigger.DataAccess); CoreContainers.LogsRepository.LogWarning($"Query failed for table {tableName}", Core.Database.Logs.LogTrigger.DataAccess); } return(pointDetails); } } catch (Exception exception) { CoreContainers.LogsRepository.LogError(exception, Core.Database.Logs.LogTrigger.DataAccess); return(new Point()); } }
public void MakeShot(PointBase target) { target.GetDamage(strength * Time.deltaTime); game.playOneSound(game.snd_enemycontact, this); }
protected void createOperationMap() { mans = new PointBase[enemyNumber+3+objectsNumber+1]; mans[0] = new PointBase("capitan","team",15,15,this,0); mans[0].strength = Random.Range(1,SharedVars.Inst.charMax); mans[0].intellect = Random.Range(1,SharedVars.Inst.charMax); mans[0].social = Random.Range(1,SharedVars.Inst.charMax); capitanIndex = 0; mans[1] = new PointBase("soldier","team",5,10,this,1); mans[1].strength = Random.Range(1,SharedVars.Inst.charMax); mans[1].intellect = Random.Range(1,SharedVars.Inst.charMax); mans[1].social = Random.Range(1,SharedVars.Inst.charMax); soldierIndex = 1; mans[2] = new PointBase("medic","team",10,5,this,2); mans[2].strength = Random.Range(1,SharedVars.Inst.charMax); mans[2].intellect = Random.Range(1,SharedVars.Inst.charMax); mans[2].social = Random.Range(1,SharedVars.Inst.charMax); medicIndex = 2; for (int i=3;i<enemyNumber+3;i++) { mans[i] = new PointBase("enemy"+i.ToString(),"enemy",Random.Range(0.1f,0.9f)*SharedVars.Inst.operationMapSize,Random.Range(0.1f,0.9f)*SharedVars.Inst.operationMapSize,this,i); mans[i].startEndlessWalking(); } for (int i=enemyNumber+3;i<enemyNumber+3+objectsNumber;i++) { mans[i] = new PointBase("object"+i.ToString(),"object",Random.Range(0.1f,0.9f)*SharedVars.Inst.operationMapSize,Random.Range(0.1f,0.9f)*SharedVars.Inst.operationMapSize,this,i); } mans[mans.Length-1] = new PointBase("mission","mission",Random.Range(0.75f,0.9f)*SharedVars.Inst.operationMapSize,Random.Range(0.75f,0.9f)*SharedVars.Inst.operationMapSize,this,mans.Length-1); missionIndex = mans.Length-1; allteamPoints = createPoints(allteamPoints,screen3); capitanPoints = createPoints(capitanPoints,screen0); soldierPoints = createPoints(soldierPoints,screen1); medicPoints = createPoints(medicPoints,screen2); mans[capitanIndex].selectFinalTarget(mans[mans.Length-1].positionX,mans[mans.Length-1].positionY); mans[soldierIndex].selectFinalTarget(mans[mans.Length-1].positionX,mans[mans.Length-1].positionY); mans[medicIndex].selectFinalTarget(mans[mans.Length-1].positionX,mans[mans.Length-1].positionY); }
private void OK_Click(object sender, EventArgs e) { M1DP_form.setornot = true; switch (M1DP_form.measuretype) { case (int)MeasureType.pos: M1DP_out.dstfirstpoint.Clear(); for (int i = 0; i < M1DP_form.hv_RowEdgeFirst.Length; i++) { PointBase PB_temp = new PointBase(); PB_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; M1DP_out.dstfirstpoint.Add(PB_temp); } break; case (int)MeasureType.pair: M1DP_out.dstfirstpoint.Clear(); M1DP_out.dstsecondpoint.Clear(); for (int i = 0; i < M1DP_form.hv_RowEdgeFirst.Length; i++) { PointBase PB1_temp = new PointBase(); PointBase PB2_temp = new PointBase(); PB1_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB1_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; PB2_temp.row = M1DP_form.hv_RowEdgeFirst[i]; PB2_temp.col = M1DP_form.hv_ColumnEdgeFirst[i]; M1DP_out.dstfirstpoint.Add(PB1_temp); M1DP_out.dstsecondpoint.Add(PB2_temp); } break; } Hide(); }
public HTuple PiexlGrayval_Interpolated(PointBase point)//取得某點的pixel值(內插法) 直接函式輸出 { HTuple Grayval_Interpolated; HOperatorSet.GetGrayvalInterpolated(Image, point.row, point.col, "bilinear", out Grayval_Interpolated); return Grayval_Interpolated; }
public float checkDistance(PointBase A, PointBase B) { return(Mathf.Sqrt((A.positionX - B.positionX) * (A.positionX - B.positionX) + (A.positionY - B.positionY) * (A.positionY - B.positionY))); }
public HTuple PiexlGrayval(PointBase point)//取得某點的pixel值 直接函式輸出 { HTuple Grayval; if (Image != null) { HOperatorSet.GetImageSize(Image, out hv_Width, out hv_Height); if (point.row > 0 && point.row < hv_Height && point.col > 0 && point.col < hv_Width) HOperatorSet.GetGrayval(Image, point.row, point.col, out Grayval); else Grayval = "null"; } else { Grayval = "null"; } return Grayval; }