public override void OnTouchUp(int x, int y) { switch (state) { case FieldState.OneDown: state = FieldState.OneSelected; break; case FieldState.OneSelectedOneDown: PerformSegment(); break; case FieldState.OneStretched: ClearTargets(); points[pointA].State = GamePoint.PointState.Normal; dottedSegment = null; state = FieldState.Free; break; case FieldState.OneStretchedOneAimed: ClearTargets(); dottedSegment = null; PerformSegment(); break; } }
public override void OnTouchMove(int absX, int absY) { int x = (int)(absX - pivot.AbsX); int y = (int)(absY - pivot.AbsY); int curID = FindAlivePointID(x, y); switch (state) { case FieldState.OneDown: if (curID == pointA) { break; } dottedSegment = new GameSegment(ColorBank.Yellow, 0, 0, pivot, (int)points[pointA].pivot.X, (int)points[pointA].pivot.Y); dottedSegment.Style = GameSegment.SegmentStyle.Dotted; state = FieldState.OneStretched; break; case FieldState.OneSelectedOneDown: if (curID == pointB) { break; } points[pointA].State = GamePoint.PointState.Normal; pointA = pointB; points[pointA].State = GamePoint.PointState.Selected; MakeTargets(pointA); dottedSegment = new GameSegment(ColorBank.Yellow, 0, 0, pivot, (int)points[pointA].pivot.X, (int)points[pointA].pivot.Y); dottedSegment.Style = GameSegment.SegmentStyle.Dotted; state = FieldState.OneStretched; break; case FieldState.OneStretchedOneAimed: if (curID == pointB) { break; } points[pointB].State = GamePoint.PointState.Highlighted; state = FieldState.OneStretched; break; } if (state == FieldState.OneStretched) { if (curID == -1 || curID == pointA || !pointsTargeted.Contains(curID)) { dottedSegment.HeadX = (int)(x - points[pointA].pivot.X); dottedSegment.HeadY = (int)(y - points[pointA].pivot.Y); return; } pointB = curID; points[pointB].State = GamePoint.PointState.Selected; dottedSegment.HeadX = (int)(points[pointB].pivot.X - points[pointA].pivot.X); dottedSegment.HeadY = (int)(points[pointB].pivot.Y - points[pointA].pivot.Y); state = FieldState.OneStretchedOneAimed; } }
void GoToFreeStateFromAnyTouchedState() { if (state == FieldState.Free || state == FieldState.OneSelected) { return; } ClearTargets(); points[pointA].State = GamePoint.PointState.Normal; dottedSegment = null; state = FieldState.Free; if (state == FieldState.OneDown || state == FieldState.OneStretched) { return; } points[pointB].State = GamePoint.PointState.Normal; }
void AddSegment(int point1, int point2, int colorID) { pointsAlive.Remove(point1); pointsAlive.Remove(point2); GamePoint a = points[point1], b = points[point2]; GameSegment cur = new GameSegment(colorID, (int)(b.pivot.X - a.pivot.X), (int)(b.pivot.Y - a.pivot.Y), pivot, (int)a.pivot.X, (int)a.pivot.Y); cur.AnimateAppearance(); segments.Add(cur); int segID = fieldData.segmentID[point1, point2]; foreach (int segProhibitID in fieldData.intersectedWith[segID]) { availableSegments.Remove(segProhibitID); } }