//TODO doesnt really belong here
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.clickCount != 2)
        {
            return;
        }
        var creationPoint = Vector3.zero;
        var mousePos      = eventData.pressPosition;

        if (Nodes.Count > 0)
        {
            // this is basically reduce with a conditional either passing min or next, to find the min closest node
            // could replace with for loop...
            var closestNode = Nodes.Aggregate((min, next) => Vector3.Distance(min.transform.position, mousePos) < Vector3.Distance(next.transform.position, mousePos) ? min : next);
            // get distance to closest node
            var distToClosest = Vector3.Distance(Camera.main.transform.position, closestNode.transform.position);
            creationPoint = BaseView <NodeModel> .ProjectCurrentDrag(distToClosest);
        }

        //todo creation of a new node or element needs to be redesigned -
        // process will be in general -
        // create an empty gameobject
        // add a Model to it
        // Model will create a view which will also be added to the root GO
        // the view will call a method on the model to construct UI elements
        // which will be added to the scene and form some tree structure under the root

        var newnode = InstantiateNode <NumberRange>(creationPoint);
    }
Example #2
0
 public IntermediateState(SortedSet <TreeNode> set, int number)
 {
     this.Number = number;
     this.Nodes  = set;
     this.hash   = Nodes.Aggregate(
         0,
         (h, n) => h ^ n.GetHashCode());
 }
Example #3
0
        public override string GenerateCode(string offset = "")
        {
            var code = $"class {_start.Childs[1].ValueWithoutWhitespaces} : {_start.Childs[0].ValueWithoutWhitespaces}";

            for (var i = 2; i < _start.Childs.Count; i++)
            {
                code += $", {_start.Childs[i].ValueWithoutWhitespaces}";
            }
            code += "\n{\n";
            code  = Nodes.Aggregate(code, (current, cur) => current + cur.GenerateCode("\t"));
            code += @"} //";
            code += $"{_end.Childs[0].Value}";
            code += "\n\n";
            return(code);
        }