public PointJSON CaseToCase(CaseJSON case_src, CaseJSON case_dest) { int cX = case_dest.X - case_src.X; int cY = case_dest.Y - case_src.Y; PointJSON p = new PointJSON(); p.X = ((cX - cY) * 100) + case_dest.Adjustment.X - case_src.Adjustment.X; p.Y = ((cX + cY) * 50) + case_dest.Adjustment.Y - case_src.Adjustment.Y; return(p); //return {X:((cX-cY)*100)+case_dest.Adjustment.X-case_src.Adjustment.X,Y:((cX+cY)*50)+case_dest.Adjustment.Y-case_src.Adjustment.Y}; }
public void OnDistance(Point3D location_dest, PointJSON adjustment) { MoveDraw.Location.X = X; MoveDraw.Location.Y = Y; MoveDraw.Location.Z = Z; MoveDraw.Adjustment.X = Adjustment.X; MoveDraw.Adjustment.Y = Adjustment.Y; var Case_src = new CaseJSON(); // {X:0,Y:0, Adjustment:{X:0,Y:0}}; var Case_dest = new CaseJSON(); // {X:0,Y:0, Adjustment:{X:0,Y:0}}; Case_src.X = MoveDraw.Location.X - MoveDraw.Location.Z; Case_src.Y = MoveDraw.Location.Y - MoveDraw.Location.Z; Case_src.Adjustment.X = MoveDraw.Adjustment.X; Case_src.Adjustment.Y = MoveDraw.Adjustment.Y; Case_dest.X = location_dest.X - location_dest.Z; Case_dest.Y = location_dest.Y - location_dest.Z; Case_dest.Adjustment.X = adjustment.X; Case_dest.Adjustment.Y = adjustment.Y; MoveDraw.Distance = CaseToCase(Case_src, Case_dest); MoveDraw.DrawStep = 0; double ratio_X = Math.Abs((double)(this.MoveDraw.Distance.X / 100)); double ratio_Y = Math.Abs((double)(this.MoveDraw.Distance.Y / 100)); int ratio_Speed_X = Convert.ToInt32(Move.Speed * ratio_X); int ratio_Speed_Y = Convert.ToInt32(Move.Speed * ratio_Y); if (ratio_Speed_X > ratio_Speed_Y) { MoveDraw.Time = ratio_Speed_X; } else { MoveDraw.Time = ratio_Speed_Y; } Direction = ScreenDirection(MoveDraw.Distance.X, MoveDraw.Distance.Y); }