private void UpdatePoint(object sender, RoutedEventArgs e) { if (PointARB.IsChecked == true) mPointDirection = PointDirection.TOOLS; else mPointDirection = PointDirection.SYMBOL; }
public void PointAtButton(Button button, PointDirection pointDirection = PointDirection.Down, float delayShowTime = 0) { canvasGroup.blocksRaycasts = true; canvasGroup.interactable = true; canvasBackground.enabled = true; RectTransform rectTransform = button.GetComponent <RectTransform>(); Vector2 pointPosition = new Vector2(0, (rectTransform.sizeDelta.y / 2 + 75) * (pointDirection == PointDirection.Down ? 1 : -1)); originalParent = button.transform.parent; originalSiblingIndex = button.transform.GetSiblingIndex(); button.transform.SetParent(container); pointObject = Instantiate((pointDirection == PointDirection.Down ? pointPrefabDown : pointPrefabUp), button.transform); pointObject.GetComponent <RectTransform>().anchoredPosition = pointPosition; pointObject.transform.SetParent(canvasGroup.transform); pointObject.GetComponent <PointerHelper>().StartAnimation(pointDirection); button.onClick.AddListener(RemovePointer); if (delayShowTime <= 0) { canvasGroup.DOFade(1, 0.3f); } else { StartCoroutine(Delay(delayShowTime, () => canvasGroup.DOFade(1, 0.3f))); } }
private Vector2[] GetPath(ref List <PointDirection> all_walls) { List <Vector2> to_return = new List <Vector2>(); List <PointDirection> to_remove = new List <PointDirection>(); PointDirection first_wall = all_walls[0]; PointDirection current_wall = new PointDirection(first_wall.point, first_wall.direction); to_return.Add(Beginning(current_wall, true)); while (true) { PointDirection[] next_candidate = new PointDirection[4]; next_candidate[0] = new PointDirection(current_wall.point, current_wall.direction.Previous()); next_candidate[1] = new PointDirection(current_wall.point + current_wall.direction.Previous().Offset(), current_wall.direction); next_candidate[2] = new PointDirection(current_wall.point + current_wall.direction.Previous().Offset() + current_wall.direction.Offset(), current_wall.direction.Next()); next_candidate[3] = new PointDirection(current_wall.point + current_wall.direction.Offset(), current_wall.direction.Opposite()); /* * // against self * if (all_walls.Any(w => w == next_candidate[0])) * { * to_return.Add(End(current_wall, true)); * current_wall = all_walls.Find(w => w == next_candidate[0]); * } */ // straight if (all_walls.Any(w => w == next_candidate[1])) { current_wall = all_walls.Find(w => w == next_candidate[1]); } /* * // away from self * else if (all_walls.Any(w => w == next_candidate[2])) * { * to_return.Add(AwayFrom(current_wall)); * current_wall = all_walls.Find(w => w == next_candidate[2]); * } */ // completely reverse else { to_return.Add(End(current_wall, false)); current_wall = all_walls.Find(w => w == next_candidate[3]); to_return.Add(Beginning(current_wall, false)); } to_remove.Add(current_wall); if (current_wall == first_wall) { break; } } foreach (PointDirection pd in to_remove) { all_walls.Remove(pd); } return(to_return.ToArray()); }
public void StartAnimation(PointDirection direction) { tweenSequence = DOTween.Sequence(); float moveTowards = direction == PointDirection.Down ? -30 : 30; tweenSequence.Append(rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y + moveTowards, 0.5f).SetEase(Ease.InOutSine)); tweenSequence.Append(rectTransform.DOAnchorPosY(rectTransform.anchoredPosition.y, 0.5f).SetEase(Ease.InOutSine)); tweenSequence.SetLoops(-1); tweenSequence.Play(); }
public void AddDirection (PointDirection pointDir) { var matchedPt = _pointDrawingInfos.Find (x => x.Point == pointDir.Point); if (matchedPt == null) return; matchedPt.Dir = pointDir.Direction; matchedPt.Polyline = DecodePoly (pointDir.Direction.routes [0].overview_polyline.points); OnUiThread(() => DrawPolyline (matchedPt.Polyline)); }
public void AddDirection(PointDirection pointDir) { var matchedPt = _pointDrawingInfos.Find(x => x.Point == pointDir.Point); if (matchedPt == null) { return; } matchedPt.Dir = pointDir.Direction; matchedPt.Polyline = DecodePoly(pointDir.Direction.routes [0].overview_polyline.points); OnUiThread(() => DrawPolyline(matchedPt.Polyline)); }
public Vector2 End(PointDirection pd, bool use_pad) { if (pd.direction == Direction.North) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2((use_pad ? WALL_THICKNESS : 0), 1 - WALL_THICKNESS)); } else if (pd.direction == Direction.East) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(1 - WALL_THICKNESS, 1 - (use_pad ? WALL_THICKNESS : 0))); } else if (pd.direction == Direction.South) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(1 - (use_pad ? WALL_THICKNESS : 0), WALL_THICKNESS)); } else { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(WALL_THICKNESS, (use_pad ? WALL_THICKNESS : 0))); } }
public Vector2 AwayFrom(PointDirection pd) { if (pd.direction == Direction.North) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(-WALL_THICKNESS, 1 - WALL_THICKNESS)); } else if (pd.direction == Direction.East) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(1 - WALL_THICKNESS, 1 + WALL_THICKNESS)); } else if (pd.direction == Direction.South) { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(1 + WALL_THICKNESS, WALL_THICKNESS)); } else { return(new Vector2(MapGenerator.DRAW_PAD, MapGenerator.DRAW_PAD) + (Vector2)pd.point + new Vector2(WALL_THICKNESS, -WALL_THICKNESS)); } }
private static MeshDraft TriDraft(PointDirection point1, PointDirection point2, PointDirection point3, Dictionary <PointDirection, TilePoint> tilePoints, Atlas atlas, string resourceKey) { var draft = MeshDraft.Triangle(tilePoints[point1], tilePoints[point2], tilePoints[point3]); draft.uv = new List <Vector2>(); var uv1 = _baseUV[point1]; var uv2 = _baseUV[point2]; var uv3 = _baseUV[point3]; if (atlas != null) { var atlasTile = atlas.Map[resourceKey]; var texOffset = new Vector2(atlasTile.X, atlasTile.Y) * atlas.TileFraction; uv1 = (uv1 * atlas.TileFraction) + texOffset; uv2 = (uv2 * atlas.TileFraction) + texOffset; uv3 = (uv3 * atlas.TileFraction) + texOffset; } TriUV(draft, uv1, uv2, uv3); return(draft); }
/// <summary> /// 椐据方位生成连线点 /// </summary> /// <param name="der">当前方位</param> /// <returns></returns> private System.Collections.Generic.List <Point> CreatePoints(PointDirection der) { //连线的转折点 var result = new System.Collections.Generic.List <Point>(); ////获取出线第一个转点 //var fp = new Point(); ////固定从底部出线。因此第一个点是固定的 //fp.X = StartPoint.X; //fp.Y = ((int)StartPoint.Y / Helper.Config.GridSize.Height + 1) * Helper.Config.GridSize.Height; result.Add(StartPoint); switch (der) { //起始点在水平左边 case PointDirection.Left: //起始点位于左下方 case PointDirection.LBRT: case PointDirection.LTRB: { var sp = new Point(); sp.Y = StartPoint.Y; //X取中点 sp.X = (EndPoint.X - StartPoint.X) / 2 + StartPoint.X; //((int)EndPoint.X / Helper.Config.GridSize.Width) * Helper.Config.GridSize.Width; result.Add(sp); //第三个转点 var tp = new Point(); tp.Y = EndPoint.Y; tp.X = sp.X; result.Add(tp); result.Add(EndPoint); result.AddRange(CreateEndPoints(EndPoint, 1)); //生成向右的箭头 break; } //超始点在结束点水平右边 case PointDirection.Right: case PointDirection.Top: case PointDirection.Bottom: //起始点位于右下方 case PointDirection.RBLT: case PointDirection.RTLB: { var sp = new Point(); sp.Y = StartPoint.Y; //X取中间点 sp.X = StartPoint.X + StartElement.GridMargin.Right; //((int)EndPoint.X / Helper.Config.GridSize.Width + 1) * Helper.Config.GridSize.Width; result.Add(sp); //第三个转点 var tp = new Point(); var offsety = (StartPoint.Y - EndPoint.Y) / 2; if (Math.Abs(offsety) < Helper.Config.GridSize.Height / 2) { offsety = Helper.Config.GridSize.Height / 2; } tp.Y = EndPoint.Y + offsety; tp.X = sp.X; result.Add(tp); var fp = new Point(); fp.X = EndPoint.X - EndElement.GridMargin.Left; fp.Y = tp.Y; result.Add(fp); var fp2 = new Point(); fp2.X = fp.X; fp2.Y = EndPoint.Y; result.Add(fp2); result.Add(EndPoint); result.AddRange(CreateEndPoints(EndPoint, 1)); //生成向左 的箭头 break; } ////起始点在垂直上边 //case PointDirection.Top: // { // var sp = new Point(); // sp.Y = StartPoint.Y; // //var yc1 = (int)StartPoint.Y / Helper.Config.GridSize.Height; // //var yc2 = (int)EndPoint.Y / Helper.Config.GridSize.Height; // ////如果起始点高于结束点一个网格以上 // //if (yc1 < yc2 - 1) // //{ // // var l = StartPoint.X % Helper.Config.GridSize.Width; // // //如果起始点偏右,则从右走线 // // //否则从左走线 // // if (l > Helper.Config.GridSize.Width / 2) // // { // // sp.X = ((int)StartPoint.X / Helper.Config.GridSize.Width + 1) * Helper.Config.GridSize.Width; // // } // // else // // { // // sp.X = ((int)StartPoint.X / Helper.Config.GridSize.Width) * Helper.Config.GridSize.Width; // // } // // result.Add(sp); // // //第三个转点 // // var tp = new Point(); // // tp.X = sp.X; // // tp.Y = (int)EndPoint.Y / Helper.Config.GridSize.Height * Helper.Config.GridSize.Height; // // result.Add(tp); // // var frp = new Point() { X = EndPoint.X, Y = tp.Y }; // // result.Add(frp); // //} // ////起始点就在结束点上一个网格 // //else // //{ // // sp.X = EndPoint.X; // // result.Add(sp); // //} // sp.X = StartPoint.X + StartElement.GridMargin.Right; // result.Add(sp); // var tp = new Point(); // tp.X = sp.X; // tp.Y = StartPoint.Y + (EndPoint.Y - StartPoint.Y) / 2; // result.Add(tp); // var fp = new Point(); // fp.Y = tp.Y; // fp.X = EndPoint.X - EndElement.GridMargin.Left; // result.Add(fp); // var fp2 = new Point(); // fp2.X = fp.X; // fp2.Y = EndPoint.Y; // result.Add(fp2); // result.Add(EndPoint); // result.AddRange(CreateEndPoints(EndPoint, 1));//生成向下的箭头 // break; // } ////起始点在结束点下边 //case PointDirection.Bottom: // { // var sp = new Point(); // sp.Y = StartPoint.Y; // var l = StartPoint.X % Helper.Config.GridSize.Width; // var flag = 2;//默认为向右的箭头 // //如果起始点偏右,则从右走线 // //否则从左走线 // if (l > Helper.Config.GridSize.Width / 2) // { // sp.X = ((int)StartPoint.X / Helper.Config.GridSize.Width + 1) * Helper.Config.GridSize.Width; // } // else // { // flag = 1;//表示箭头向左 // sp.X = ((int)StartPoint.X / Helper.Config.GridSize.Width) * Helper.Config.GridSize.Width; // } // result.Add(sp); // //第三个转点 // var tp = new Point(); // tp.X = sp.X; // tp.Y = EndPoint.Y; // result.Add(tp); // result.Add(EndPoint); // result.AddRange(CreateEndPoints(EndPoint, flag));//生成向flag的箭头 // break; // } ////起始点位于左上方 //case PointDirection.LTRB: // { // var sp = new Point(); // sp.Y = StartPoint.Y; // //从右边走线 // sp.X = ((int)EndPoint.X / Helper.Config.GridSize.Width) * Helper.Config.GridSize.Width; // result.Add(sp); // //第三个转点 // var tp = new Point(); // tp.X = sp.X; // tp.Y = ((int)EndPoint.Y / Helper.Config.GridSize.Height) * Helper.Config.GridSize.Height; // result.Add(tp); // //第四个转点 // var frp = new Point(); // frp.X = EndPoint.X; // frp.Y = tp.Y; // result.Add(frp); // result.Add(EndPoint); // result.AddRange(CreateEndPoints(EndPoint, 0));//生成向下的箭头 // break; // } //起始点位于左下方 //case PointDirection.LBRT: // { // var sp = new Point(); // sp.Y = fp.Y; // //从右边走线 // sp.X = ((int)EndPoint.X / Helper.Config.GridSize.Width) * Helper.Config.GridSize.Width; // result.Add(sp); // //第四个转点 // var frp = new Point(); // frp.X = sp.X; // frp.Y = EndPoint.Y; // result.Add(frp); // break; // } ////起始点位于右上方 //case PointDirection.RTLB: // { // var sp = new Point(); // sp.Y = StartPoint.Y; // //从左边走线 // sp.X = ((int)EndPoint.X / Helper.Config.GridSize.Width + 1) * Helper.Config.GridSize.Width; // result.Add(sp); // //第三个转点 // var tp = new Point(); // tp.X = sp.X; // tp.Y = ((int)EndPoint.Y / Helper.Config.GridSize.Height) * Helper.Config.GridSize.Height; // result.Add(tp); // //第四个转点 // var frp = new Point(); // frp.X = EndPoint.X; // frp.Y = tp.Y; // result.Add(frp); // result.Add(EndPoint); // result.AddRange(CreateEndPoints(EndPoint, 0));//生成向下的箭头 // break; // } } return(result); }
private GraphicsPath CreatePointedRectangularPath(Graphics g, Rectangle bounds, PointDirection direction, float radius, int depth, int inset) { int diff = 0; // create a path GraphicsPath pathBounds = new GraphicsPath(); switch (direction) { case PointDirection.Bottom: { // line left pathBounds.AddLine(bounds.Left, bounds.Bottom - radius, bounds.Left, bounds.Top + radius); if (radius > 0) pathBounds.AddArc(bounds.Left, bounds.Top, radius, radius, 180, 90); // line top pathBounds.AddLine(bounds.Left + radius, bounds.Top, bounds.Right - radius, bounds.Top); if (radius > 0) pathBounds.AddArc(bounds.Right - radius, bounds.Top, radius, radius, 270, 90); // line right pathBounds.AddLine(bounds.Right, bounds.Top + radius, bounds.Right, bounds.Bottom - radius); // pointed path // if (inset == -1) radius = 0; if (radius > 0) pathBounds.AddArc(bounds.Right - radius, bounds.Bottom - radius, radius, radius, 0, 90); // line bottom right pathBounds.AddLine(bounds.Right - radius, bounds.Bottom, bounds.Right - (radius + inset), bounds.Bottom); // pointed center diff = (bounds.Width / 2) - ((int)radius + inset); // right half pathBounds.AddLine(bounds.Right - (radius + inset), bounds.Bottom, bounds.Right - (radius + inset + diff), bounds.Bottom + depth); // left half pathBounds.AddLine(bounds.Right - (radius + inset + diff), bounds.Bottom + depth, bounds.Left + radius + inset, bounds.Bottom); // line bottom left pathBounds.AddLine(bounds.Left + radius + inset, bounds.Bottom, bounds.Left + radius, bounds.Bottom); if (radius > 0) pathBounds.AddArc(bounds.Left, bounds.Bottom - radius, radius, radius, 90, 90); break; } case PointDirection.Right: { // line top pathBounds.AddLine(bounds.Left + radius, bounds.Top, bounds.Right - (radius + depth), bounds.Top); // arc top right if (radius > 0) pathBounds.AddArc(bounds.Right - (radius + depth), bounds.Top, radius, radius, 270, 90); // top line pathBounds.AddLine(bounds.Right - depth, bounds.Top + radius, bounds.Right - depth, bounds.Top + (radius + inset)); // pointed center diff = (bounds.Height / 2) - ((int)radius + inset); // top half pathBounds.AddLine(bounds.Right - depth, bounds.Top + (radius + inset), bounds.Right, bounds.Bottom - (radius + inset + diff)); // bottom half pathBounds.AddLine(bounds.Right, bounds.Bottom - (radius + inset + diff), bounds.Right - depth, bounds.Bottom - (radius + inset)); // line right bottom pathBounds.AddLine(bounds.Right - depth, bounds.Bottom - (radius + inset), bounds.Right - depth, bounds.Bottom - radius); // arc bottom right if (radius > 0) pathBounds.AddArc(bounds.Right - (radius + depth), bounds.Bottom - radius, radius, radius, 0, 90); // line bottom pathBounds.AddLine(bounds.Right - (radius + depth), bounds.Bottom, bounds.Left + radius, bounds.Bottom); if (inset == -1) radius = 0; // arc bottom left if (radius > 0) pathBounds.AddArc(bounds.Left, bounds.Bottom - radius, radius, radius, 90, 90); // line left pathBounds.AddLine(bounds.Left, bounds.Bottom - radius, bounds.Left, bounds.Top + radius); // arc top left if (radius > 0) pathBounds.AddArc(bounds.Left, bounds.Top, radius, radius, 180, 90); /*// pointed path // // line left bottom pathBounds.AddLine(bounds.Left, bounds.Bottom - radius, bounds.Left, bounds.Bottom - (radius + inset)); // pointed center diff = (bounds.Height / 2) - ((int)radius + inset); // bottom half pathBounds.AddLine(bounds.Left, bounds.Bottom - (radius + inset), bounds.Left - depth, bounds.Bottom - (radius + inset + diff)); // top half pathBounds.AddLine(bounds.Left - depth, bounds.Bottom - (radius + inset + diff), bounds.Left, bounds.Top + (radius + inset)); // top line pathBounds.AddLine(bounds.Left, bounds.Top + (radius + inset), bounds.Left, bounds.Top + radius); if (radius > 0) pathBounds.AddArc(bounds.Left, bounds.Top, radius, radius, 180, 90);*/ break; } } pathBounds.CloseFigure(); return pathBounds; }
internal override PointDirection[] initPointArray(params string[] param) { PointDirection[] _pd = new PointDirection[] {PointDirection.UP, PointDirection.DOWN}; return _pd; }
public PointDir(int XDir, int YDir, PointDirection Direction) { this.Position = new Point(XDir, YDir); this.Direction = Direction; }
private void PointAtSceneObject(RectTransform rectTransform, ObjectClickTracker linkedClickableObject, PointDirection pointDirection, float delayShowTime) { canvasGroup.blocksRaycasts = true; canvasGroup.interactable = true; canvasBackground.enabled = false; Vector2 pointPosition = new Vector2(0, (rectTransform.sizeDelta.y / 2 + 75) * (pointDirection == PointDirection.Down ? 1 : -1)); pointObject = Instantiate((pointDirection == PointDirection.Down ? pointPrefabDown : pointPrefabUp), rectTransform.transform); pointObject.GetComponent <RectTransform>().anchoredPosition = pointPosition; pointObject.transform.SetParent(canvasGroup.transform); pointObject.GetComponent <PointerHelper>().StartAnimation(pointDirection); linkedClickableObject.OnObjectClicked += RemovePointer; if (delayShowTime <= 0) { canvasGroup.DOFade(1, 0.3f); } else { StartCoroutine(Delay(delayShowTime, () => canvasGroup.DOFade(1, 0.3f))); } }
public static Texture2D CreateTriangle(Color color, int Width, int Height, PointDirection pointDirection) { GraphicsDevice graphicsDevice = ChristianGame.graphicsDevice; Color[] colors = new Color[Width * Height]; Point p1 = new Point(0, 0); // top Point p2 = new Point(Width, Height / 2); // middle Point p3 = new Point(0, Height); // down float m1 = Tools.MyMath.M(p1.ToVector2(), p2.ToVector2()); float m2 = Tools.MyMath.M(p3.ToVector2(), p2.ToVector2()); int count = 0; for (int h = 0; h < Height; h++) { for (int w = 0; w < Width; w++) { if (h < Height / 2) { int result = (int)(m1 * w + p1.Y); if (result <= h) { colors[count] = color; } else { colors[count] = Color.Transparent; } } else { int result = (int)(m2 * w + p3.Y); if (result >= h) { colors[count] = color; } else { colors[count] = Color.Transparent; } } count++; } } Texture2D texture2D = new Texture2D(graphicsDevice, Width, Height, false, SurfaceFormat.Color); switch (pointDirection) { case PointDirection.Up: { Color[,] multidimentionalColors = Tools.Other.ToMultidimentional(colors, Width, Height); multidimentionalColors = Tools.Other.RotateArray_90_AntiClockwise(multidimentionalColors); colors = Tools.Other.FlattenArray(multidimentionalColors); } break; case PointDirection.Down: { Color[,] multidimentionalColors = Tools.Other.ToMultidimentional(colors, Width, Height); multidimentionalColors = Tools.Other.RotateArray_270_AntiClockwise(multidimentionalColors); colors = Tools.Other.FlattenArray(multidimentionalColors); } break; case PointDirection.Right: // original break; case PointDirection.Left: { Color[,] multidimentionalColors = Tools.Other.ToMultidimentional(colors, Width, Height); multidimentionalColors = Tools.Other.RotateArray_180_AntiClockwise(multidimentionalColors); colors = Tools.Other.FlattenArray(multidimentionalColors); } break; } texture2D.SetData(colors); return(texture2D); }
public PointDir() { this.Position = new Point(0, 0); this.Direction = PointDirection.N; }
internal override PointDirection[] initPointArray(params string[] param) { PointDirection[] _pd = new PointDirection[] {PointDirection.LEFT, PointDirection.RIGHT}; return _pd; }
public static PointDirection OtherSide(this PointDirection pd) { return(new PointDirection(pd.point + pd.direction.Offset(), pd.direction.Opposite())); }