Beispiel #1
0
    void ResetGame()
    {
        if (_broken)
        {
            ResetGlass();
            Destroy(voronoi);
            showPoint.Destroy();

            randomPoint = new RandomPoint();
            voronoi     = new VoronoiCell();

            timeline.value = 0f;
            prompt.active  = true;
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        pieces = new List <GameObject>();

        gp        = GetComponent <GeneratePieces>();
        showPoint = GetComponent <ShowPoint>();
        smash     = GetComponent <Smash>();

        randomPoint = new RandomPoint();
        voronoi     = new VoronoiCell();

        resetButton.onClick.AddListener(ResetGame);

        prompt.active = true;

        _broken = true;

        ResetGlass();
    }
 public static Vector2 GetInRectangle(this Rect rect, Vector2 recOffset)
 {
     return(RandomPoint.GetInRectangle(rect, recOffset));
 }
Beispiel #4
0
            public static void RndPointCmd()
            {
                var id = ObjectCollector.SelectAllowedClassObject <Polyline>("Укажите полилинию", "Выбранный объект не полилиния");

                if (id == null)
                {
                    return;
                }
                Editor ed = AcadEnvironments.Editor;

                var stepRes = ed.GetDouble(new PromptDoubleOptions("Укажите \'шаг\', м")
                {
                    AllowNegative = false,
                    DefaultValue  = 10,
                    AllowZero     = false
                });

                if (stepRes.Status != PromptStatus.OK)
                {
                    return;
                }
                double step = stepRes.Value;

                var kwOpt = new PromptKeywordOptions("Acad | Cogo points?");

                kwOpt.AllowNone = true;
                kwOpt.AppendKeywordsToMessage = true;
                kwOpt.Keywords.Add("AcadPoints");
                kwOpt.Keywords.Add("CogoPoints");
                kwOpt.AllowArbitraryInput = true;

                var kwRes = ed.GetKeywords(kwOpt);

                if (kwRes.Status != PromptStatus.OK)
                {
                    return;
                }

                Tools.StartTransaction((trans, doc) => {
                    Polyline pline        = id.GetObject <Polyline>(OpenMode.ForRead);
                    var polygon           = pline.GetPoints3d();
                    RandomPoint test      = new RandomPoint(polygon);
                    List <Point3d> points = new List <Point3d>();
                    int count             = (int)(System.Math.Floor(pline.Area / System.Math.Pow(step, 2))) + 2;
                    if (count > System.Math.Pow(10000, 2))
                    {
                        ed.WriteMessage($"\nСлишком много точек - {count}, Нужно увеличить шаг (текущее значение шага - {step}м)\n");
                        return;
                    }
                    int maxIter = 1000, i = 0;
                    while (points.Count < count && i < maxIter)
                    {
                        if (test.GenPoint(polygon, out Point3d point))
                        {
                            points.Add(point);
                        }
                        else
                        {
                            i++;
                        }
                    }
                    if (kwRes.StringResult == "AcadPoints")
                    {
                        Tools.AppendEntity(points.Select(p => new DBPoint(p)));
                    }
                    else
                    {
                        IgorKL.ACAD3.Model.CogoPoints.CogoPointFactory.CreateCogoPoints(points);
                    }
                });
            }
Beispiel #5
0
 public void SetRandomPoint()
 {
     rp = new RandomPoint(this.pbCanvas.Width, this.pbCanvas.Height);
     rp.setBarSize(8);
     rp.setPointSize(12);
 }