Ejemplo n.º 1
0
        /// <summary>
        /// Adds a line.
        /// </summary>
        /// <param name="pkt1">Point that the line is attached to.</param>
        /// <param name="pkt2">Other point that the line is attached to.</param>
        public void AddLine(Pkt pkt1, Pkt pkt2)
        {
            // DRAWING LINES USING LINE RENDERER:
            GameObject line = new GameObject();

            line.name  = pkt1.ID + ";" + pkt2.ID;
            line.tag   = "Line";
            line.layer = LAYER_LINE;

            // ADDING/CONFIGURING THE RENDERER COMPONENT
            LineRenderer renderer = line.AddComponent <LineRenderer>();

            renderer.useWorldSpace    = true;
            renderer.sortingLayerName = "Line";
            renderer.material         = lineMaterial;

            renderer.startColor = colors.LineClear;
            renderer.endColor   = colors.LineClear;
            renderer.startWidth = 1.5f;
            renderer.endWidth   = 1.5f;

            Vector3[] pos = { pkt1.Position, pkt2.Position };
            line.transform.parent = pkt1.Circle.transform;
            renderer.SetPositions(pos);

            pkt1.AddLine(line);
            pkt2.AddLine(line);
        }
Ejemplo n.º 2
0
//----------------------------------------INPUT / INTERACTION METHODS----------------------------------\\
        private void OnInteractionStart(Vector2 inputPosition)
        {
            Pkt g = IdentifyClickedItem();

            if (g != null) // BRUKER TRYKKER NED KNAPP PÅ ET OBJEKT
            {
                g.Position    = inputPosition;
                heldWithMouse = true;
                held          = g;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws the circles at spesified positions one the board.
        /// The points are specified by the "points" array.
        /// </summary>
        /// <param name="points">Points in the plane.</param>
        public Pkt[] AddCircles(Vector2[] points, Vector2 initialPosition)
        {
            Pkt[] circles = new Pkt[points.Length];

            for (int i = 0; i < points.Length; i++)
            {
                circles[i] = AddCircle(i, points[i], initialPosition);
            }

            for (int i = 1; i <= points.Length; i++)
            {
                if (i == points.Length)
                {
                    AddLine(circles[i - 1], circles[0]);
                }
                else
                {
                    AddLine(circles[i - 1], circles[i]);
                }
            }

            return(circles);
        }
Ejemplo n.º 4
0
//----------------------------------------METHODS FOR LINEHANDELING----------------------\\
        /// <summary>
        /// Clears the level.
        /// </summary>
        private void ClearLevel()
        {
            heldWithMouse = false;
            levelIsWon    = false;
            held          = null;
        }
Ejemplo n.º 5
0
 private void OnInteractionStop()
 {
     heldWithMouse = false;
     held          = null;
 }