Пример #1
0
        public void IncreaseNodeLevel(INodeElement _element)
        {
            var node = GetNode(_element);

            IncreaseNodeLevel(node);
            return;
        }
 public bool IsEqual(INodeElement other)
 {
     if (!(other is FileNodeElement otherFile))
     {
         return(false);
     }
     return(FilesAreEqual(FilePath, otherFile.FilePath));
 }
Пример #3
0
        private void loadNodeEditor(INodeElement ne)
        {
            pnlNodeEditor.Controls.Clear();
            NodeEditor edit;

            edit = new NodeEditor(ne);
            pnlNodeEditor.Controls.Add(edit);
        }
Пример #4
0
 public Node(INodeElement _element, int _maxLevel, Dependency[] _dependencies, int _cost)
 {
     element      = (ScriptableObject)_element;
     maxLevel     = _maxLevel;
     dependencies = _dependencies;
     cost         = _cost;
     level        = 0;
     isAvailable  = false;
 }
Пример #5
0
        /// <summary>
        /// Assign a gnom view to the current instance.
        /// </summary>
        /// <param name="view"></param>
        public GnomController(IGnomTree view)
        {
            this.View = view;
            this.field = this.View[FieldId];

            // TODO: extract in resource provider
            var text2 = new TextElement("Current moves: 0");
            text2.Style.PaddingTop = 3;
            this.View[MessageBoxId].AddChild(text2);
        }
        public static void ApplyNodeStyleToConsole(INodeElement node)
        {
            if (node.IsSelected)
            {
                Console.ForegroundColor = ConsoleColor.White;
            }
            else
            {
                Console.ForegroundColor = node.Style.Color;
            }

            Console.SetCursorPosition(node.Style.AbsPaddingLeft, node.Style.AbsPaddingTop);
        }
Пример #7
0
        private void tvModel_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            ModelTreeNode tn;

            if (e.Node is ModelTreeNode)
            {
                tn = (ModelTreeNode)e.Node;
                if (tn.NodeObject != null)
                {
                    INodeElement ne = tn.NodeObject;
                    loadNodeEditor(ne);
                }
            }
        }
        private static void DrawTreeRec(INodeElement node, int x, int y)
        {
            InitializeAbsolutePadding(node, x, y);
            ApplyNodeStyleToConsole(node);

            var renderedElement = node.ToStringArray();

            DrawStringArray(renderedElement, node.Style.AbsPaddingTop, node.Style.AbsPaddingLeft);

            foreach (var childNode in node.Children)
            {
                DrawTreeRec(childNode, node.Style.AbsPaddingLeft + 1, node.Style.AbsPaddingTop + 1);
            }
        }
Пример #9
0
        private bool TryExtractDependencies(ITreeRequirement requirement, out List <Dependency> _dependencies)
        {
            List <Dependency> dependencies = new List <Dependency>();

            foreach (var kvp in requirement.Dependencies)
            {
                INodeElement dependencyElement = AllDependencies.SingleOrDefault(x => x.ElementName == kvp.Key);
                if (dependencyElement == null)
                {
                    Debug.LogError($"couldn't find json dependency {kvp.Key} in dependency database");
                    continue;
                }

                dependencies.Add(new Dependency(dependencyElement, kvp.Value));
            }

            _dependencies = dependencies;
            return(_dependencies != null && _dependencies.Count > 0);
        }
Пример #10
0
        public static IPressable AddMatrixToGnom(INodeElement field, string[,] matrix)
        {
            var result = new TextElement[matrix.GetLength(0), matrix.GetLength(1)];
            for (int i = 0; i < matrix.GetLength(0); i++)
            {
                for (int j = 0; j < matrix.GetLength(1); j++)
                {
                    result[i, j] = new TextElement(matrix[i, j])
                    {
                        Style = new Style()
                        {
                            PaddingLeft = j * 2,
                            PaddingTop = i * 2,
                            Color = ConsoleColor.Green
                        }
                    };

                    if (i > 0)
                    {
                        result[i, j].LinkTo(ConsoleKey.UpArrow, result[i - 1, j]);
                    }

                    if (j > 0)
                    {
                        result[i, j].LinkTo(ConsoleKey.LeftArrow, result[i, j - 1]);
                    }
                }
            }

            result[result.GetLength(0) - 1, 0].IsSelected = true;

            foreach (var node in result)
            {
                field.AddChild(node);
            }

            return result[result.GetLength(0) - 1, 0];
        }
Пример #11
0
 private bool TryExtractNode(ITreeRequirement _requirement, out INodeElement _element)
 {
     _element = AllNodeElements.SingleOrDefault(x => x.ElementName == _requirement.Name);
     return(_element != null);
 }
    /// <summary>
    /// マウスの左ボタンが離されたときの処理
    /// ドラッグ状態を解除し、選択ノードをnullにする
    /// </summary>
    public void OnMouseUp(Vector2 position)
    {
        if (CurrentElement != null && selectedElement != CurrentElement)
        {
            successDelegate(selectedElement, CurrentElement);
        }

        finishedDelegate();
        isDrugging = false;
        selectedElement = null;
    }
 /// <summary>
 /// マウスの左ボタンが押下されたときの処理
 /// 押下されたとき、そこにノードがあればドラッグ状態にする
 /// </summary>
 /// <param name='position'>
 /// 押下されたときの座標
 /// </param>
 public void OnMouseDown(Vector2 position)
 {
     if (CurrentElement != null)
     {
         isDrugging = true;
         selectedElement = CurrentElement;
         Rect rect = selectedElement.GetViewRect();
         drugOffset.x = position.x - rect.x;
         drugOffset.y = position.y - rect.y;
     }
 }
Пример #14
0
 public Dependency(INodeElement _requirement, int _level)
 {
     this.requirement = (ScriptableObject)_requirement;
     this.level       = _level;
 }
 public static void InitializeAbsolutePadding(INodeElement node, int x, int y)
 {
     node.Style.AbsPaddingLeft = node.Style.PaddingLeft + x;
     node.Style.AbsPaddingTop = node.Style.PaddingTop + y;
 }
 /// <summary>
 /// 遷移元/遷移先フェーズを設定してエッジを作成する
 /// </summary>
 /// <param name='source'>
 /// 遷移元フェーズ ビューモデル
 /// </param>
 /// <param name='destination'>
 /// 遷移先フェーズ ビューモデル
 /// </param>
 public abstract void CreateEdge(INodeElement source, INodeElement destination);
Пример #17
0
        private static void UpdateIdMap(INodeElement nextRoot, int row, IDictionary<string, INodeElement> idMap)
        {
            if (idMap.ContainsKey(nextRoot.Id))
            {
                throw new InvalidOperationException("Duplicate Ids in gnom resource at row {0}. Id name: {1}".Format(row + 1, nextRoot.Id));
            }

            idMap.Add(nextRoot.Id, nextRoot);
        }
Пример #18
0
        // ISSUE: RemoveElement doesn't remove the element's id from the GnomTree id map
        public INodeElement RemoveElement(INodeElement element)
        {
            if (this.Children.Contains(element))
            {
                this.Children.Remove(element);
            }

            return this;
        }
Пример #19
0
        public INodeElement AddChild(INodeElement element)
        {
            element.Parent = this;

            this.Children.Add(element);
            return this;
        }
Пример #20
0
        public Node GetNode(INodeElement _element)
        {
            var node = Graph.SingleOrDefault(x => x.Element.Equals(_element));

            return(node);
        }
 /// <summary>
 /// マウスの左ボタンが押下されたときの処理
 /// 押下されたとき、そこにノードがあればドラッグ状態にする
 /// そうでなければ、エッジ作成モードから抜ける
 /// </summary>
 /// <param name='position'>
 /// 押下されたときの座標
 /// </param>
 public void OnMouseDown(Vector2 position)
 {
     if (CurrentElement != null)
     {
         isDrugging = true;
         selectedElement = CurrentElement;
     }
     else
     {
         finishedDelegate();
     }
 }
Пример #22
0
        private static void UpdateClassMap(INodeElement nextRoot, IDictionary<string, IList<INodeElement>> classMap)
        {
            if (!classMap.ContainsKey(nextRoot.Class))
            {
                classMap[nextRoot.Class] = new List<INodeElement>();
            }

            classMap[nextRoot.Class].Add(nextRoot);
        }
 /// <summary>
 /// マウスの左ボタンが離されたときの処理
 /// ドラッグ状態を解除し、選択ノードをnullにする
 /// </summary>
 public void OnMouseUp(Vector2 position)
 {
     isDrugging = false;
     selectedElement = null;
 }