Exemplo n.º 1
0
    [SerializeField] private GameObject bombRBPrefab = null; //bomba con rigid body


    private void Start()
    {
        pickedUpItem = null;
        controller   = GetComponent <AnotherCharacterController>();
        collider     = GetComponents <BoxCollider2D>()[0];
        drawCircle   = GetComponentInChildren <DrawCircle>();
    }
Exemplo n.º 2
0
 public void DrawCircleROI(int row = 100, int col = 100, double radius = 10)
 {
     if (bDrawing)
     {
         MessageHelper.ShowWarning("显示界面正在进行ROI操作!");
         return;
     }
     if (Image == null)
     {
         return;
     }
     if (circle == null)
     {
         circle = new DrawCircle(Window, Image, row, col, radius);
     }
     else
     {
         circle.Row    = row;
         circle.Col    = col;
         circle.Radius = radius;
     }
     bDrawing     = true;
     DrawingShape = ROIShape.Circle;
     //添加参数事件
     BindingCircleROIEvent();
     circle.CreateROI();
 }
Exemplo n.º 3
0
        private void InitializeOptions()
        {
            _points    = new List <Point>();
            ClientSize = new Size(1280, 800);

            var pen        = new Pen(Color.Black);
            var brushColor = Color.Black;
            var graphics   = CreateGraphics();

            //Иницилизация наших классов
            _drawLine       = new DrawLine(graphics, pen, brushColor);
            _drawRectangles = new DrawRectangle(graphics, pen, brushColor);
            _drawPoint      = new DrawPoint(CreateGraphics(), pen, brushColor);
            _drawCircle     = new DrawCircle(graphics, pen, brushColor);
            _drawTriangle   = new DrawTriangle(graphics, pen, brushColor);

            EventMainColor();
            EventBrushColor();

            mainColorButton.BackColor  = pen.Color;
            brushColorButton.BackColor = brushColor;

            _count = 0;

            PositionLabel.Location = new Point(this.Width - 125, this.Height - 70);

            TimerDraw.Start();
        }
Exemplo n.º 4
0
    private void Init()
    {
        drawline   = GetComponent <DrawFreeLine>();
        drawcircle = GetComponent <DrawCircle>();
        drawarrow  = GetComponent <DrawArrow>();

        tex            = new Texture2D(Screen.width, Screen.height, TextureFormat.RGBA32, false);
        tex.filterMode = FilterMode.Point;
        tex.wrapMode   = TextureWrapMode.Clamp;

        image.texture = tex;

        pixels      = new byte[Screen.width * Screen.height * 4];
        pixelsUndo  = new byte[Screen.width * Screen.height * 4];
        clearPixels = new byte[Screen.width * Screen.height * 4];
        ClearDrawed();

        if (Application.isEditor)
        {
            directoryPath = Application.persistentDataPath + "/../undos/";
        }
        else
        {
            directoryPath = Application.persistentDataPath + "/undos/";
        }
        if (!Directory.Exists(directoryPath))
        {
            Directory.CreateDirectory(directoryPath);
        }
    }
Exemplo n.º 5
0
        private void DrawCircleMethod()
        {
            DrawCircle drawCircle = new DrawCircle();

            drawCircle.bitmap = mBitmap;
            drawCircle.DrawFromCenter(100, Color.Orange);
        }
Exemplo n.º 6
0
    static void Main(string[] args)
    {
        System.Console.WriteLine("assignment 1");
        DrawCircle s = new DrawCircle();

        Application.Run(s);
        System.Console.WriteLine("end of assignment 1");
    }
Exemplo n.º 7
0
 void Start()
 {
     player   = GameObject.FindGameObjectWithTag("Player").transform;
     planet   = GetComponent <Planet>();
     minRange = planet.circleAroundRadius;
     maxRange = planet.rangeRadius;
     drawer   = GetComponent <DrawCircle>();
 }
Exemplo n.º 8
0
        private void Start()
        {
            DrawCircle drawCircleScript = GetComponent <DrawCircle>();

            drawCircleScript.radiusXY = gravityRange;

            // TODO: refactor, it might be better to move this logic to object active state switcher
            drawCircleScript.enabled = simulationConfig.simulationMode == SimulationConfig.SimulationMode.Demo;
        }
Exemplo n.º 9
0
    public static void AddToObject(GameObject where, float radius, float lineWidth, Color color)
    {
        DrawCircle drawCircle = where.AddComponent <DrawCircle>();

        drawCircle.radius    = radius;
        drawCircle.lineWidth = lineWidth;
        drawCircle.color     = color;
        drawCircle.Init();
    }
Exemplo n.º 10
0
 public void GenerateCircle()
 {
     drawCircleObj = Instantiate(drawCircle);
     radius        = 2;
     drawCircleObj.GetComponent <CircleCollider2D> ().offset = Vector2.zero;
     drawCircleObj.GetComponent <CircleCollider2D> ().radius = radius;
     DrawCircle.ToDrawCircle(drawCircleObj.transform, Vector3.zero, radius);
     StartCoroutine("CircleFollowPlayer");
 }
Exemplo n.º 11
0
    void Start()
    {
        minionHolder   = GameObject.FindObjectOfType <WaveSpawner>().minionHolder;
        sqrRange       = range * range;
        target         = null;
        nextShot       = timeBetweenShots + Time.time;
        nextTargetScan = Time.time + 0.5f;
        DrawCircle dc = transform.GetComponent <DrawCircle>();

        dc.radius = range;
    }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            var drawCircle = new DrawCircle();
            var drawSquare = new DrawSquare();

            var draw = new DrawFigure(drawCircle);

            draw.Draw();
            var draw1 = new DrawFigure(drawSquare);

            draw1.Draw();
        }
 // Start is called before the first frame update
 void Start()
 {
     foreach (GameObject planet in planets)
     {
         DrawCircle orbitDistance = planet.GetComponent <DrawCircle>();
         Vector3    sunPos        = transform.position;
         sunPos.z += orbitDistance.orbitRadius;
         GameObject newPlanet = Instantiate(planet, sunPos, Quaternion.identity);
         newPlanet.transform.RotateAround(transform.position, Vector3.up, RandFloat());
         newPlanet.GetComponent <DrawCircle>().orbitTarget = transform;
     }
 }
Exemplo n.º 14
0
    float seeMax, bais = Mathf.Floor(UnityEngine.Random.Range(0.8f, 1.6f)); //-4~6

    public gameBits(biologyCS parent)
    {
        DrawCircle  = parent.GetComponent <DrawCircle>();
        actionIsOn  = false;
        allBiologys = parent.allBiologys;
        bioCamp     = parent.getBioCamp();
        leaderName  = parent.getleaderNumber();
        seeMax      = parent.getSeeMax();
        Transform   = parent.getTransform();
        this.parent = parent;


        //todo:之後要各生物儲存
        decideList.Add("decideHpUnder90percentAlly");
        actionList.Add("actionHeal");
        decideList.Add("decideClosestEnemy");
        actionList.Add("actionAttack");
    }
Exemplo n.º 15
0
        private void PlotCircle(DrawCircle func, Vector <double> x, double R, string color, int linewidth)
        {
            LineSeries ls = new LineSeries()
            {
                Color           = OxyPlot.OxyColor.Parse(color).ToColor(),
                StrokeThickness = linewidth
            };

            DataPoint[] p = new DataPoint[x.Count];
            for (int i = 0; i < x.Count; ++i)
            {
                var pd = func(x[i], R);
                p[i] = new DataPoint(pd[0], pd[1]);
            }
            ls.ItemsSource = p;
            m_Canvas.Series.Add(ls);

            m_Canvas.InvalidatePlot(true);
        }
        void Start()
        {
            place       = new PlaceObjectToGround();
            drawCircle1 = new DrawCircle(GetComponent <LineRenderer>());
            yVec3       = new Vector3(
                0.0f,
                Vector3.up.y * sqrt2,
                0.0f);

            //normVec3 = vec3 + yVec3;
            //vec_1a = CalcVec3(1,1);
            //vec_2a =  CalcVec3(2,1);
            graphLength = (int)(Vector3.Distance(transform.position, target.position) / rad) - limit;
            Debug.Log("dist to target" + graphLength);
            vec3points = new Vector3[graphLength];
            angle      = GetAngle();
            CalcGraph();
            PlaceObjByGraph();
        }
Exemplo n.º 17
0
        /// <summary> Get the shape implementing Interface.</summary>
        /// <param name="shapeType">Type of the shape.</param>
        /// <returns>Shape</returns>
        public IDrawShape getShape(string shapeType)
        {
            IDrawShape shape = null;

            switch (shapeType)
            {
            case "CIRCLE":
                shape = new DrawCircle();
                break;

            case "RECTANGLE":
                shape = new DrawRectangle();
                break;

            case "TRIANGLE":
                shape = new DrawTriangle();
                break;
            }
            return(shape);
        }
Exemplo n.º 18
0
        public static DrawObject GetObjectFromString(string s, Point lastEndPoint)
        {
            var informations = new Dictionary <ObjectInformation, string>();

            //einzelne Daten werden in einem StringArray abgespeichert
            string[] data = s.Split('/');

            //einzelne Informationen werden abgespeichert
            foreach (var informatin in data)
            {
                //teilt information in Art der Information und den Wert auf
                string[] splitInformation = informatin.Split(':');

                try
                {
                    informations.Add((ObjectInformation)Enum.Parse(typeof(ObjectInformation), splitInformation[0]), splitInformation[1]);
                }
                catch
                { }
            }

            //ObjektTyp wird abgespeichert
            ObjectTypes objectType = (ObjectTypes)Enum.Parse(typeof(ObjectTypes), informations.GetObjectInformation(ObjectInformation.objectType));

            //-----Informationen werden abgespeichert

            //Endpunkt
            var endPoint = new Point(
                MainWindow.CentimeterTopixel(Double.Parse(informations.GetObjectInformation(ObjectInformation.endX))),
                MainWindow.CentimeterTopixel(Double.Parse(informations.GetObjectInformation(ObjectInformation.endY))));

            DrawObject newObject = null;

            switch (objectType)
            {
            case ObjectTypes.Line:
            {
                var lineMode = (DrawLine.LineMode)Enum.Parse(typeof(DrawLine.LineMode), informations.GetObjectInformation(ObjectInformation.lineMode));

                //ende des letzen Objekts ist der Start der Linie
                newObject = new DrawLine(lastEndPoint, endPoint, lineMode);
            }
            break;

            case ObjectTypes.Ellipse:
            {
                //Breite
                var width = double.Parse(informations.GetObjectInformation(ObjectInformation.width));

                //Höhe
                var height = double.Parse(informations.GetObjectInformation(ObjectInformation.height));

                newObject = new DrawEllipse(endPoint, width, height);
            }
            break;

            case ObjectTypes.Arc:
            {
                var radius = MainWindow.CentimeterTopixel(Double.Parse(informations.GetObjectInformation(ObjectInformation.radius)));

                var circleSizeAngle = double.Parse(informations.GetObjectInformation(ObjectInformation.circleSizeAngle));

                var startAngle = double.Parse(informations.GetObjectInformation(ObjectInformation.startAngle));

                var isInverted = Boolean.Parse(informations.GetObjectInformation(ObjectInformation.inverted));

                newObject = new DrawCircle(lastEndPoint, radius, circleSizeAngle, startAngle, isInverted);
            }
            break;

            default:
            {
                newObject = null;
            }
            break;
            }

            return(newObject);
        }
Exemplo n.º 19
0
 protected override void Setup()
 {
     formationType = InputControl.Formation.Mob;
     circle        = transform.Find("Circle").GetComponent <DrawCircle>();
     circle.Init();
 }
        public IList <DrawingItem> ExportShapes()
        {
            List <DrawingItem> items = new List <DrawingItem>();

            if (_areas != null)
            {
                foreach (HtmlElement_area hb in _areas)
                {
                    DrawingItem di = null;
                    switch (hb.shape)
                    {
                    case EnumAreaShape.circle:
                        DrawCircle dc = new DrawCircle();
                        if (hb.coords != null && hb.coords.Length > 1)
                        {
                            dc.CircleCenter = new System.Drawing.Point(hb.coords[0], hb.coords[1]);
                            if (hb.coords.Length > 2)
                            {
                                dc.Radius = hb.coords[2];
                            }
                            else
                            {
                                dc.Radius = 20;
                            }
                        }
                        else
                        {
                            dc.CircleCenter = new System.Drawing.Point(60, 60);
                            dc.Radius       = 20;
                        }
                        di = dc;
                        break;

                    case EnumAreaShape.poly:
                        if (hb.coords != null && hb.coords.Length > 1)
                        {
                            List <CPoint> lst = new List <CPoint>();
                            int           i   = 0;
                            while (i < hb.coords.Length - 1)
                            {
                                lst.Add(new CPoint(new Point(hb.coords[i], hb.coords[i + 1])));
                                i += 2;
                            }
                            if (lst.Count > 3)
                            {
                                DrawPolygon dp = new DrawPolygon();
                                dp.Points = lst;
                                di        = dp;
                            }
                        }
                        break;

                    case EnumAreaShape.rect:
                    default:
                        if (hb.coords != null && hb.coords.Length > 3)
                        {
                            if (hb.coords[2] > hb.coords[0] && hb.coords[3] > hb.coords[1])
                            {
                                Rectangle rc = new Rectangle(hb.coords[0], hb.coords[1], hb.coords[2] - hb.coords[0], hb.coords[3] - hb.coords[1]);
                                DrawRect  dr = new DrawRect();
                                dr.Rectangle = rc;
                                di           = dr;
                            }
                        }
                        break;
                    }
                    di.SetGuid(hb.ElementGuid);
                    di.Name = hb.id;
                    items.Add(di);
                }
            }
            return(items);
        }
Exemplo n.º 21
0
    private void AddCircle(float radius)
    {
        var newCircle = Instantiate(prefab, transform);

        DrawCircle.AddToObject(newCircle, radius, lineWidth, color);
    }
 private void buttonOK_Click(object sender, EventArgs e)
 {
     if (_currentMap != null)
     {
         List <HtmlElement_area> areas = new List <HtmlElement_area>();
         List <DrawingItem>      lst   = mapCtrl.ExportDrawingItems();
         if (lst != null && lst.Count > 0)
         {
             foreach (DrawingItem di in lst)
             {
                 HtmlElement_area ha   = null;
                 ClassPointer     root = _webpage.GetDevClass() as ClassPointer;
                 DrawCircle       dc   = di as DrawCircle;
                 if (dc != null)
                 {
                     ha           = new HtmlElement_area(root);
                     ha.shape     = EnumAreaShape.circle;
                     ha.coords    = new int[3];
                     ha.coords[0] = dc.CircleCenter.X;
                     ha.coords[1] = dc.CircleCenter.Y;
                     ha.coords[2] = dc.Radius;
                 }
                 else
                 {
                     DrawRect dr = di as DrawRect;
                     if (dr != null)
                     {
                         ha           = new HtmlElement_area(root);
                         ha.shape     = EnumAreaShape.rect;
                         ha.coords    = new int[4];
                         ha.coords[0] = dr.Rectangle.X;
                         ha.coords[1] = dr.Rectangle.Y;
                         ha.coords[2] = dr.Rectangle.X + dr.Rectangle.Width;
                         ha.coords[3] = dr.Rectangle.Y + dr.Rectangle.Height;
                     }
                     else
                     {
                         DrawPolygon dp = di as DrawPolygon;
                         if (dp != null)
                         {
                             ha        = new HtmlElement_area(root);
                             ha.shape  = EnumAreaShape.poly;
                             ha.coords = new int[dp.PointCount * 2];
                             for (int k = 0; k < dp.PointCount; k++)
                             {
                                 ha.coords[2 * k]     = dp.PointList[k].X;
                                 ha.coords[2 * k + 1] = dp.PointList[k].Y;
                             }
                         }
                     }
                 }
                 if (ha != null)
                 {
                     ha.SetGuid(di.DrawingId);
                     ha.SetId(di.Name);
                     areas.Add(ha);
                 }
             }
         }
         _currentMap.SetAreas(areas);
         _webpage.UpdateMapAreas(_currentMap);
         MapID             = _currentMap.id;
         this.DialogResult = DialogResult.OK;
     }
 }
Exemplo n.º 23
0
        public void DrawConfiguration(SystemConfig self)
        {
            m_Canvas.Series.Clear();

            DrawCircle circle = (alpha, R) => { return(new double[] { R *Math.Cos(alpha), R *Math.Sin(alpha) }); };
            // plot crystall;
            var phi_max = Math.Asin(0.5 * self.crystalW / self.crystalR);
            int N       = (int)(2.0 * phi_max / 0.001);
            var phis    = Vector <double> .Build.Dense(N, i => - phi_max + i * 0.001);

            phis = phis + Math.PI / 2.0;

            PlotCircle(circle, phis, self.crystalR, "#FF0000", 5);

            // plot source;

            /*            elipse = lambda alpha, size, shift: [size[0] * np.cos(alpha) + shift[0], size[1] * np.sin(alpha) + shift[1]];
             *          b_phi = self.BraggA * np.pi / 180.0;
             *          source_pos = [-self.SrcDist * np.cos(b_phi), -self.SrcDist * np.sin(b_phi) - self.crystalR];
             *          figure_ax.plot(*elipse(np.arange(-np.pi, np.pi, 0.001), [self.SrcSizeW, self.SrcSizeH], source_pos),;
             *          color = "blue");*/

            // plot detector;
            var b_phi = self.BraggA * Math.PI / 180.0;

            double[] source_pos = { -self.SrcDist * Math.Cos(b_phi), -self.SrcDist * Math.Sin(b_phi) + self.crystalR };

            var detector_center = new double[] { self.DstDist *Math.Cos(b_phi), -self.DstDist * Math.Sin(b_phi) + self.crystalR };

            double[] R_position         = { 0, 0, 0 };
            var      detector_norm_line = Extension.Sub(detector_center, R_position);
            var      norm = Extension.vectorLenght(detector_norm_line);

            detector_norm_line = detector_norm_line.Select(x => x / norm).ToArray();

            var detector_half_size = 20.0;

            if (self.waveLimits != null)
            {
                detector_half_size = (Math.Abs(self.waveLimits.max.position) + Math.Abs(self.waveLimits.min.position)) * 1.25;
            }

            N = (int)(2.0 * detector_half_size / 0.1);
            var step = Vector <double> .Build.Dense(N, i => - detector_half_size + i * 0.1);

            var r0        = detector_center;
            var direction = detector_norm_line;

            Func <double, double[]> line = (steps) => { return(new double[] { steps *direction[0] + r0[0], steps *direction[1] + r0[1] }); };

            PlotFunc(line, step, "#00FF00", 5);
            // plot object;
            if (self.ObjectExist)
            {
                var      object_distance = self.Object.GridPosition;
                double[] object_coord    = { ((self.Object.GridLocation == 0) ? -1 : 1) * object_distance * Math.Cos(b_phi),
                                             -object_distance * Math.Sin(b_phi) + self.crystalR };

                double[] object_vector      = { -object_coord[0], self.crystalR - object_coord[1] };
                double   tmp                = object_vector[0];
                double   object_vector_norm = Extension.vectorLenght(object_vector);
                object_vector[0] = -object_vector[1] / object_vector_norm;
                object_vector[1] = tmp / object_vector_norm;

                var ObjectN       = (int)(self.Object.GridWidth / 0.1);
                var object_t_step = Vector <double> .Build.Dense(ObjectN, i => - self.Object.GridWidth / 2.0 + i *0.1);

                Func <double, double[]> object_line = (steps) => { return(new double[] { steps *object_vector[0] + object_coord[0], steps *object_vector[1] + object_coord[1] }); };
                PlotFunc(object_line, object_t_step, "#00FFFF", 3);
            }


            // plot lines;
            var dh = Math.Sqrt(self.crystalR * self.crystalR - self.crystalW * self.crystalW / 4.0);

            double[] cross_point_1 = { -self.crystalW / 2.0, dh };
            double[] cross_point_2 = { self.crystalW / 2.0, dh };

            Func <double, double[], double[], double[]> lpoint = (steps, r0p, directionP) => { return(new double[] { steps *directionP[0] + r0p[0], steps *directionP[1] + r0p[1] }); };

            var detector_cross_1 = lpoint((self.waveLimits != null) ? self.waveLimits.max.position : 10, detector_center, detector_norm_line);
            var detector_cross_2 = lpoint((self.waveLimits != null) ? self.waveLimits.min.position : -10, detector_center, detector_norm_line);

            PlotPoints(new double[] { source_pos[0], cross_point_1[0], detector_cross_1[0] },
                       new double[] { source_pos[1], cross_point_1[1], detector_cross_1[1] }, "#0000FF", 1);

            PlotPoints(new double[] { source_pos[0], cross_point_2[0], detector_cross_2[0] },
                       new double[] { source_pos[1], cross_point_2[1], detector_cross_2[1] }, "#FF0000", 1);

            // plot Roland circle;

            double[] RowlandCenter = { 0.0, -self.crystalR / 2.0 };
            N    = (int)(Math.PI * 2 / 0.001);
            phis = Vector <double> .Build.Dense(N, i => - Math.PI + i * 0.001);

            Func <double, double[]> sh_circle = (alpha) =>
            {
                return(new double[] { self.crystalR / 2.0 * Math.Cos(alpha) - RowlandCenter[0],
                                      self.crystalR / 2.0 * Math.Sin(alpha) - RowlandCenter[1] });
            };

            PlotFunc(sh_circle, phis, "#000000", 2, LineStyle.Dash);


            // plot normal to crystal and start of the system;

            PlotPoints(new double[] { 0.0, 0.0 }, new double[] { self.crystalR, -self.crystalR }, "#000000", 2, LineStyle.Dash);

            m_Canvas.ResetAllAxes();
        }
Exemplo n.º 24
0
    private void Start()
    {
        DrawCircle drawCircleScript = GetComponent <DrawCircle>();

        drawCircleScript.radiusXY = gravityRange;
    }