public HexSide(HexPoint hp1, HexPoint hp2) { this.StartPoint = hp1; this.EndPoint = hp2; SetPointList(); }
private PointF ConvertHexPointToPointF(HexPoint hp) { PointF result = new PointF(hp.X, hp.Y); return result; }
private void SetPoints() { this.SE = new HexPoint(this.SW.X + this.HexSideLength, this.SW.Y); this.W = new HexPoint(this.SW.X - shortside, this.SW.Y - longside); this.E = new HexPoint(this.SE.X + shortside, this.SE.Y - longside); this.NW = new HexPoint(this.SW.X, this.SW.Y - (longside * 2)); this.NE = new HexPoint(this.SE.X, this.SE.Y - (longside * 2)); this.DrawHexPoints = new List<HexPoint>(); this.DrawPointFs = new List<PointF>(); this.DrawHexPoints.Add(this.SW); this.DrawHexPoints.Add(this.SE); this.DrawHexPoints.Add(this.E); this.DrawHexPoints.Add(this.NE); this.DrawHexPoints.Add(this.NW); this.DrawHexPoints.Add(this.W); foreach (HexPoint hp in this.DrawHexPoints) { this.DrawPointFs.Add(ConvertHexPointToPointF(hp)); } }
private void pboxMain_MouseDown(object sender, MouseEventArgs e) { var h1 = (from hx in hexagons where hx.Selected select hx).FirstOrDefault(); HexPoint hp = new HexPoint(e.X, e.Y); hexagons.ForEach(h => h.Selected = false); var hex = (from h in hexagons where h.NW.X <= e.X && h.NE.X >= e.X && h.NW.Y <= e.Y && h.SW.Y >= e.Y select h).FirstOrDefault(); MoveResult moveresult = new MoveResult(MoveResult.eMoveResult.DNE, ""); if (hex != null) { moveresult = HexUtils.isMoveAllowed(h1, hex,jumpup,jumpdown); if (moveresult.MoveResultStatus== MoveResult.eMoveResult.Success) { if (h1 != null) { h1.Selected = false; } hex.Selected = true; } else { if (h1 != null) { h1.Selected = true; hex.Selected = false; } } } WriteLog(moveresult); this.Refresh(); }