public void Reset() { click = 0; current = null; secondPointSelected = false; thirdPointSelected = false; bezier = null; figure = null; path = null; pf = null; }
void Start() { arrowPath = GetComponent <ArrowPath>(); isFinished = false; waveCount = 0; enemyCount = 0; pathUsed = new int[paths.Length]; for (int i = 0; i < pathUsed.Length; ++i) { pathUsed[i] = 0; } for (int i = 0; i < waves.Length; ++i) { StartCoroutine(WaitAndSpawn(waves[i])); } LevelProgression.Instance.Build(waves); }
void Awake() { ArrowColor = transform.Find("ArrowColor").GetComponent <Image>(); ArrowBase = transform.Find("ArrowBase").GetComponent <Image>(); Path = transform.Find("ArrowPath").GetComponent <ArrowPath>(); }
public TikzBezier(ArrowPath path, TikzStyle tikzStyle) : base(path, tikzStyle) { }
public DrawingShape GetShape(CanvasEventArgs a, TikzStyle style) { if (click == 0) // first click, draw a straight line { if (a.MouseState == MouseState.DOWN) { //FIXME: small bug here, sometimes when a user clicks for the first time long line appears for a split second, noticeable but should not influence performance firstPoint = a.Point; bezier = new BezierSegment() { Point3 = a.Point.GetSystemPoint() }; figure = new PathFigure(); figure.Segments.Add(bezier); path = new ArrowPath(); path.SetStyle(style); path.Margin = ShapeUtils.GetMargin(firstPoint.X, firstPoint.Y); pf = new PathFigure[] { figure }; path.Data = new PathGeometry(pf); current = new DrawingShape( new TikzBezier(path, style), ShapeState.START ); } else if (a.MouseState == MouseState.MOVE) { bezier.Point3 = GetPointWithoutMargin(firstPoint, a.Point); } else { bezier.Point3 = GetPointWithoutMargin(firstPoint, a.Point); click++; } return(current); } else if (click == 1) // second click, select first control point { if (a.MouseState == MouseState.DOWN) { secondPointSelected = true; bezier.Point1 = GetPointWithoutMargin(firstPoint, a.Point); } else if (a.MouseState == MouseState.MOVE) { if (secondPointSelected) { bezier.Point1 = GetPointWithoutMargin(firstPoint, a.Point); } } else { bezier.Point1 = GetPointWithoutMargin(firstPoint, a.Point); click++; } return(current); } else if (click == 2) // third click, select second control point { if (a.MouseState == MouseState.DOWN) { thirdPointSelected = true; bezier.Point2 = GetPointWithoutMargin(firstPoint, a.Point); } else if (a.MouseState == MouseState.MOVE) { if (thirdPointSelected) { bezier.Point2 = GetPointWithoutMargin(firstPoint, a.Point); } } else { bezier.Point2 = GetPointWithoutMargin(firstPoint, a.Point); current.ShapeState = ShapeState.FINISHED; click = 0; secondPointSelected = thirdPointSelected = false; } Canvas.SetLeft(current.TikzShape.Shape, 0); Canvas.SetTop(current.TikzShape.Shape, 0); return(current); } else { throw new Exception("Sth went wrong, bezier line should be drawn in 3 clicks"); } }