public void ChangeText()
        {
            var text = new VectorText("Unchanged", Vector2D.Half)
            {
                Text = "Changed"
            };

            Assert.AreEqual("Changed", text.Text);
        }
        public override string GetDropdownValueName(object property)
        {
            if (!(property is Vector2Int))
            {
                return(string.Empty);
            }
            Vector2Int res = (Vector2Int)property;

            return(VectorText.ToText(res));
        }
 public override void LoadOption()
 {
     if (dropdown == null)
     {
         return;
     }
     if (!OptionsController.TryGetOptionValue(optionName, out string optionValue) ||
         !VectorText.TryToVector2Int(optionValue, out Vector2Int result))
     {
         return;
     }
     dropdown.SetValueWithoutNotify(properties.IndexOf(result));
 }
Example #4
0
 // this finds the object in which the point is lying in, uses the bounding box idea to basically calculate if it is in between the box
 // this could do with some tweaking but its big and scary
 // the general idea is to loop through every object and check if it lies in between the box, if not ignore
 // the concept is repeated for all the object types, but they all do the same thing
 public void findSelected(VectorPoint seletedPoint)
 {
     foreach (KeyValuePair <string, VectorObject> obj in objects)
     {
         if (obj.Value is VectorBox)
         {
             VectorBox box = obj.Value as VectorBox;
             if (box.position.x <= seletedPoint.x && box.position.x + box.size.x >= seletedPoint.x)
             {
                 if (box.position.y <= seletedPoint.y && box.position.y + box.size.y >= seletedPoint.y)
                 {
                     outlinedObject = obj.Key;
                 }
             }
         }
         else if (obj.Value is VectorLine)
         {
             VectorLine line = obj.Value as VectorLine;
             if (line.minX + line.position.x <= seletedPoint.x && line.maxX + line.position.x >= seletedPoint.x)
             {
                 if (line.minY + line.position.y <= seletedPoint.y && line.maxY + line.position.y >= seletedPoint.y)
                 {
                     outlinedObject = obj.Key;
                 }
             }
         }
         else if (obj.Value is VectorEllipse)
         {
             VectorEllipse ellipse = obj.Value as VectorEllipse;
             if (ellipse.position.x - ellipse.radii.x <= seletedPoint.x && ellipse.position.x + ellipse.radii.x >= seletedPoint.x)
             {
                 if (ellipse.position.y - ellipse.radii.y <= seletedPoint.y && ellipse.position.y + ellipse.radii.y >= seletedPoint.y)
                 {
                     outlinedObject = obj.Key;
                 }
             }
         }
         else if (obj.Value is VectorText)
         {
             VectorText text = obj.Value as VectorText;
             if (text.position.x <= seletedPoint.x && text.position.x + text.width >= seletedPoint.x)
             {
                 if (text.position.y - text.fontSize <= seletedPoint.y && text.position.y >= seletedPoint.y)
                 {
                     outlinedObject = obj.Key;
                 }
             }
         }
     }
 }
Example #5
0
        private void Update()
        {
            if (ColorZoneManager.Singleton != null && spriteRenderer != null)
            {
                spriteRenderer.color = ColorZoneManager.Singleton.current.playerColor;
            }

            if (freeze)
            {
                rb.velocity = Vector2.zero;
                return;
            }

            rb.velocity = new Vector2(InputManager.GetMapAxisRaw("Horizontal"), InputManager.GetMapAxisRaw("Vertical")) * speed * SpeedMultiplier;
            InfoDisplayer.DisplayValue("pos", VectorText.ToText(new Vector2(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y))));
        }
Example #6
0
        private void drawText(SKCanvas canvas, VectorText text, bool outline)
        {
            // make the paint style
            SKPaint paint = new SKPaint();

            paint.Color    = SKColor.Parse(text.colour);
            paint.TextSize = text.fontSize;

            // draw the text
            canvas.DrawText(text.text, convertXCoord(text.position.x), convertYCoord(text.position.y), paint);

            // this is used in the selection of objects, via the object tool as we need to know the length
            float size = paint.MeasureText(text.text + ",");

            text.width = size;

            // if applicable, calculate the bounding box and draw it
            if (outline)
            {
                // experimental outline style, not really sure if it works super good
                canvas.DrawLine(convertXCoord(text.position.x), convertYCoord(text.position.y), convertXCoord(text.position.x) + size, convertYCoord(text.position.y), outlinePaint);
                canvas.DrawLine(convertXCoord(text.position.x), convertYCoord(text.position.y) - text.fontSize, convertXCoord(text.position.x) + size, convertYCoord(text.position.y) - text.fontSize, outlinePaint);
            }
        }
Example #7
0
        public static Screen Unconvert(string path)
        {
            // creates an xml doc and loads it
            XmlDocument doc    = new XmlDocument();
            Screen      screen = new Screen();

            doc.Load(path);
            if (doc.HasChildNodes) // ensures we have a screen element
            {
                // gets the stuff from the screen node
                XmlElement xml = (XmlElement)doc.ChildNodes[0];
                screen.current_colour   = xml.GetAttributeNode("colour").InnerXml;
                screen.translateX       = float.Parse(xml.GetAttributeNode("translateX").InnerXml);
                screen.translateY       = float.Parse(xml.GetAttributeNode("translateY").InnerXml);
                screen.outlinedObject   = xml.GetAttributeNode("outlined").InnerXml;
                screen.stroke_thickness = float.Parse(xml.GetAttributeNode("stroke").InnerXml);
                screen.font_size        = float.Parse(xml.GetAttributeNode("fontSize").InnerXml);
                screen.current_fill_in  = bool.Parse(xml.GetAttributeNode("currentFillIn").InnerXml);
                if (xml.HasChildNodes)
                {
                    // loops through all the objects and creates objects then adds them to the screen class, mostly self explanatory and repetitive code
                    for (int i = 0; i < xml.ChildNodes.Count; i++)
                    {
                        XmlElement  child    = (XmlElement)xml.ChildNodes[i];
                        string[]    xandy    = child.GetAttributeNode("position").InnerXml.Split(',');
                        float       x        = float.Parse(xandy[0]);
                        float       y        = float.Parse(xandy[1]);
                        VectorPoint position = new VectorPoint(x, y);
                        string      colour   = child.GetAttributeNode("colour").InnerXml;
                        string      uid      = child.GetAttributeNode("uid").InnerXml;
                        switch (child.Name)
                        {
                        case "line":
                            VectorLine line = new VectorLine(position);
                            line.minX            = float.Parse(child.GetAttributeNode("minX").InnerXml);
                            line.minY            = float.Parse(child.GetAttributeNode("minY").InnerXml);
                            line.maxX            = float.Parse(child.GetAttributeNode("maxX").InnerXml);
                            line.maxY            = float.Parse(child.GetAttributeNode("maxY").InnerXml);
                            line.colour          = colour;
                            line.strokeThickness = float.Parse(child.GetAttributeNode("stroke").InnerXml);

                            for (int u = 0; u < child.ChildNodes.Count; u++)
                            {
                                XmlElement point = (XmlElement)child.ChildNodes[u];
                                xandy = point.GetAttributeNode("position").InnerXml.Split(',');
                                x     = float.Parse(xandy[0]);
                                y     = float.Parse(xandy[1]);
                                line.addPoint(new VectorPoint(x, y));
                            }
                            screen.addObject(uid, line);
                            break;

                        case "box":
                            xandy = child.GetAttributeNode("size").InnerXml.Split(',');
                            x     = float.Parse(xandy[0]);
                            y     = float.Parse(xandy[1]);
                            VectorPoint size   = new VectorPoint(x, y);
                            bool        fillin = bool.Parse(child.GetAttributeNode("fillin").InnerXml);
                            float       stroke = float.Parse(child.GetAttributeNode("stroke").InnerXml);
                            VectorBox   box    = new VectorBox(position, size, fillin);
                            box.strokeThickness = stroke;
                            screen.addObject(uid, box);
                            break;

                        case "ellipse":
                            xandy = child.GetAttributeNode("radii").InnerXml.Split(',');
                            x     = float.Parse(xandy[0]);
                            y     = float.Parse(xandy[1]);
                            VectorPoint radii = new VectorPoint(x, y);
                            fillin = bool.Parse(child.GetAttributeNode("fillin").InnerXml);
                            stroke = float.Parse(child.GetAttributeNode("stroke").InnerXml);
                            VectorEllipse ellipse = new VectorEllipse(position, radii, fillin);
                            ellipse.strokeThickness = stroke;
                            screen.addObject(uid, ellipse);
                            break;

                        case "text":
                            string     text     = child.GetAttributeNode("text").InnerXml;
                            float      fontsize = float.Parse(child.GetAttributeNode("fontSize").InnerXml);
                            VectorText obj      = new VectorText(position, text);
                            obj.colour   = colour;
                            obj.fontSize = fontsize;
                            screen.addObject(uid, obj);
                            break;
                        }
                    }
                }
            }
            return(screen);
        }
Example #8
0
 public static void drawVectorTextLine(string text, GizmoCoords coords)
 {
     VectorText.processTextLine(text, (a, b, crd) =>
                                gizmoLine(crd.transformPoint(new Vector3(-a.x, a.y, 0.0f)), crd.transformPoint(new Vector3(-b.x, b.y, 0.0f))),
                                coords);
 }
Example #9
0
 public static void drawVectorText(string text, GizmoCoords coords, TextAnchor anchor, TextAnchor alignment)
 {
     VectorText.processText(text, anchor, alignment, (a, b, crd) => {
         gizmoLine(crd.transformPoint(new Vector3(-a.x, a.y, 0.0f)), crd.transformPoint(new Vector3(-b.x, b.y, 0.0f)));
     }, coords);
 }
Example #10
0
        public static void ChangeResolution(string resolution)
        {
            Vector2Int res = VectorText.ToVector2Int(resolution);

            Screen.SetResolution(res.x, res.y, Screen.fullScreen);
        }
Example #11
0
 public static string GetDefaultResolution() =>
 VectorText.ToText(new Vector2(Screen.width, Screen.height));
Example #12
0
		public void ChangeText()
		{
			var text = new VectorText("Unchanged", Vector2D.Half) { Text = "Changed" };
			Assert.AreEqual("Changed", text.Text);
		}
 public override void SetValue(object propertie) =>
 base.SetValue(VectorText.ToText((Vector2Int)propertie));