예제 #1
0
    void ConnectNodes(Node start, Node end, NodeLine line)
    {
        if (line.isConnected(end))
        {
            Debug.Log("Successfull connection");
            // get average accuraccy from line

            startNode = endNode;
            endNode   = null;

            accuraccyList.Add(currentLine.GetAverageAccuraccy());
            currentLine.StopTrackingAccuraccy();
            currentLine.useLine();
            currentLine = null;

            if (start.IsDeadEnd()) // MUST BE AFTER useLine()
            {
                start.MarkNodeCleared();
            }
        }
        else
        {
            Debug.Log("line not connected to end node");
        }
    }
        void EstablishNodeLines()
        {
            _listOfNodeLines.Clear();

            for (int i = 0; i < _binaryTree.NumOfNodes - 1; ++i)
            {
                if (_listOfDrawLocations[i].Node.Left != null)
                {
                    NodeLine     newLine             = new NodeLine();
                    DrawLocation currentDrawLocation = _listOfDrawLocations.Find(item => (item.Node == _listOfDrawLocations[i].Node.Left));

                    // Line start and end positions are translated to the center of each node

                    newLine.Start.X = _listOfDrawLocations[i].DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.Start.Y = _listOfDrawLocations[i].DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);
                    newLine.End.X   = currentDrawLocation.DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.End.Y   = currentDrawLocation.DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);

                    _listOfNodeLines.Add(newLine);
                }
                if (_listOfDrawLocations[i].Node.Right != null)
                {
                    NodeLine     newLine             = new NodeLine();
                    DrawLocation currentDrawLocation = _listOfDrawLocations.Find(item => (item.Node == _listOfDrawLocations[i].Node.Right));

                    newLine.Start.X = _listOfDrawLocations[i].DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.Start.Y = _listOfDrawLocations[i].DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);
                    newLine.End.X   = currentDrawLocation.DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.End.Y   = currentDrawLocation.DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);

                    _listOfNodeLines.Add(newLine);
                }
            }
        }
예제 #3
0
    private void DrawLine(MapNode sourceNode, MapNode destinationNode)
    {
        NodeLine line = (NodeLine)Instantiate(nodeLinePrefab) as NodeLine;

        line.transform.SetParent(sourceNode.transform, false);
        line.transform.SetAsFirstSibling();
        line.DrawNewLineBetween(sourceNode.gameObject, destinationNode.gameObject);
    }
예제 #4
0
	public void MakeDifficultyLine(Transform a, Transform b) {
		if(difficultyLine != null) {
			difficultyLine.B = b;
		} else {
			difficultyLine = NodeLine.CreateNewLine(a,b,Color.green,Color.green);
		}
		if(modeLine != null) {
			MakeModeLine(modeLine.B);
		}
	}
예제 #5
0
	void StartConnection(NodeConnectionArgs args) {
		List<NodeConnection> toUnregsiter = new List<NodeConnection>();
		foreach(NodeConnection nc in connections.Keys) {
			if(nc.NodeInConnection(args.StartNode)) {
				toUnregsiter.Add(nc);
			}
		}
		foreach(NodeConnection nc in toUnregsiter) {
			UnregsiterConnection(nc);
		}
		if(activeLine != null) {
			Destroy (activeLine.gameObject);
		}
		activeLine = NodeLine.CreateNewLine(args.StartNode.transform,UICursor.instance.transform,args.StartNode.ParentNode.NodeColor,Color.green);
		activeDragNode = args.StartNode;
	}
예제 #6
0
 private static void AddNodeLine()
 {
     if (m_nodeList.Count == 2)
     {
         NodeLine line = new NodeLine();
         if (m_nodeList[0].state == NodeState.In)
         {
             line.childNode  = m_nodeList[0];
             line.parentNode = m_nodeList[1];
         }
         else
         {
             line.childNode  = m_nodeList[1];
             line.parentNode = m_nodeList[0];
         }
         m_nodeLineList.Add(line);
         m_nodeList.Clear();
     }
 }
예제 #7
0
 public void OnHandleEnterLine(NodeLine line)
 {
     if (playing && startNode != null)
     {
         if (line.isConnected(startNode))
         {
             Debug.Log("got current line");
             currentLine = line;
             currentLine.StartTrackingAccuraccy();
         }
         else
         {
             Debug.Log("line not connected to node");
         }
     }
     else
     {
         Debug.Log("playing: " + playing + " startnode: " + startNode);
     }
 }
예제 #8
0
        void EstablishNodeLines()
        {
            _listOfNodeLines.Clear();

            for (int i = 0; i < _faultTree.NumOfNodes - 1; ++i)
            {
                FaultTreeNode child = _listOfDrawLocations[i].Node.Child;
                while (child != null)
                {
                    NodeLine     newLine             = new NodeLine();
                    DrawLocation currentDrawLocation = _listOfDrawLocations.Find(item => (item.Node == child));
                    //     DrawLocation currentDrawLocation = _listOfDrawLocations.Find(item => (item.Node == _listOfDrawLocations[i].Node.Child));
                    // Line start and end positions are translated to the center of each node

                    newLine.Start.X = _listOfDrawLocations[i].DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.Start.Y = _listOfDrawLocations[i].DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);
                    newLine.End.X   = currentDrawLocation.DrawPosition.X + (_nodeDrawSize.Width / 2.0f);
                    newLine.End.Y   = currentDrawLocation.DrawPosition.Y + (_nodeDrawSize.Height / 2.0f);
                    _listOfNodeLines.Add(newLine);
                    child = child.Sibling;
                }
            }
        }
        private void Intersctions(IList<ILine> lines, PolyLine<Line > poly )
        {
            IList<IPoint> points;Node node2 ; Node node1; NodeLine nodeline ;
            foreach (ILine line in lines)
            {
                points  = poly.PointsIntersects(line);
                if (points.Count == 2)
                {
                    node1 = new Node(points[0].X, points[0].Y, points[0].Z);
                    node2 = new Node(points[1].X, points[1].Y, points[1].Z);

                   nodeline = new NodeLine(node1, node2);
                   _presenter._creator.CreateBeam(nodeline);
                }

            }
        }
예제 #10
0
 public abstract (bool success, string validationError) VisitNodeLine(NodeLine nodeLine);
예제 #11
0
 public void ConnectToLine(NodeLine line)
 {
     lines.Add(line);
     currentLinesLeft += line.lineUsesLeft;
 }
예제 #12
0
    void LoadLevel(string name)
    {
        lines         = new List <NodeLine>();
        nodes         = new List <Node>();
        accuraccyList = new List <float>();

        DestroyLevelObjects();
        float depth = levelObjects.transform.position.z;

        // do level loading

        string       path   = Application.persistentDataPath + "/" + name;
        StreamReader reader = new StreamReader(path);
        string       line   = reader.ReadLine();

        while (!reader.EndOfStream && !string.IsNullOrEmpty(line))
        {
            string[] words = line.Split(' ');

            GameObject node = GameObject.Instantiate(nodePrefab, levelObjects) as GameObject;
            node.name = words[0];
            node.transform.position = new Vector3(float.Parse(words[1]), float.Parse(words[2]), depth);
            nodes.Add(node.GetComponent <Node>());
            // Do Something with the input.

            line = reader.ReadLine();
        }
        line = reader.ReadLine();
        while (!string.IsNullOrEmpty(line))
        {
            int node1Index = 0, node2Index = 0;

            string[] words = line.Split(' ');

            GameObject nodeLineObject = GameObject.Instantiate(linePrefab, levelObjects) as GameObject;
            nodeLineObject.name = "line" + lines.Count;
            NodeLine nodeLine = nodeLineObject.GetComponent <NodeLine>();

            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].name == words[0])
                {
                    node1Index = i;
                }
                if (nodes[i].name == words[1])
                {
                    node2Index = i;
                }
            }
            nodeLine.Initialize(0.03f, nodes[node1Index], nodes[node2Index]);
            lines.Add(nodeLine);
            // Do Something with the input.

            if (!reader.EndOfStream)
            {
                line = reader.ReadLine();
            }
            else
            {
                break;
            }
        }

        Debug.Log(path);

        for (int i = 0; i < nodes.Count; i++)
        {
            nodes[i].SaveFinalState();
        }
        for (int i = 0; i < lines.Count; i++)
        {
            lines[i].SaveFinalState();
        }
    }
예제 #13
0
 public void OnHandleLeaveLine(NodeLine line)
 {
 }