コード例 #1
0
        private static void GetItemNames(StoryNode node, ref List <string> Names)
        {
            foreach (InventoryOperation operation in node.OnEnter)
            {
                if (!Names.Contains(operation.ItemName))
                {
                    Names.Add(operation.ItemName);
                }
            }

            foreach (Option opt in node.Options)
            {
                foreach (InventoryOperation operation in opt.OnSelect)
                {
                    if (!Names.Contains(operation.ItemName))
                    {
                        Names.Add(operation.ItemName);
                    }
                }

                foreach (InventoryConditional conditional in opt.Conditionals)
                {
                    if (!Names.Contains(conditional.InventoryItem))
                    {
                        Names.Add(conditional.InventoryItem);
                    }
                }

                if (!(opt.Node is ReferenceNode))
                {
                    GetItemNames(opt.Node, ref Names);
                }
            }
        }
コード例 #2
0
        private static void GetItemNames(StoryNode node, ref List<string> Names)
        {
            foreach (InventoryOperation operation in node.OnEnter) {
                if (!Names.Contains(operation.ItemName)) {
                    Names.Add(operation.ItemName);
                }
            }

            foreach (Option opt in node.Options) {
                foreach (InventoryOperation operation in opt.OnSelect) {
                    if (!Names.Contains(operation.ItemName)) {
                        Names.Add(operation.ItemName);
                    }
                }

                foreach (InventoryConditional conditional in opt.Conditionals) {
                    if (!Names.Contains(conditional.InventoryItem)) {
                        Names.Add(conditional.InventoryItem);
                    }
                }

                if (!(opt.Node is ReferenceNode)) {
                    GetItemNames(opt.Node, ref Names);
                }
            }
        }
コード例 #3
0
        public TreeNode GetNode(StoryNode node)
        {
            if (node is ReferenceNode) return GetNode(((ReferenceNode)node).Reference);

            if(ReverseNodeMapping.ContainsKey(node)) {
                return ReverseNodeMapping[node];
            } else {
                throw new Exception("Failed to find Storynode in Reverse Node Mapping");
            }
        }
コード例 #4
0
 public void EnterStoryNode(StoryNode node)
 {
     CurrentNode = node;
     node.Selected(Items);
 }
コード例 #5
0
 public ReferenceNode(StoryNode reference)
 {
     this.Reference = reference;
 }
コード例 #6
0
 public ReferenceNode()
 {
     Reference = null;
 }
コード例 #7
0
 public StoryChangedEventArgs(StoryNode node)
 {
     this.NewStoryNode = node;
 }
コード例 #8
0
 private void TriggerStoryNodeChanged(StoryNode newnode)
 {
     if(OnStoryNodeChanged != null) {
         OnStoryNodeChanged(this, new StoryChangedEventArgs(newnode));
     }
 }
コード例 #9
0
 public ReferenceNode(StoryNode reference)
 {
     this.Reference = reference;
 }
コード例 #10
0
 public ReferenceNode()
 {
     Reference = null;
 }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: CloneDeath/AdventureQuest
        private void NewAdventure()
        {
            LastFileAccess = null;
            saveToolStripMenuItem.Enabled = false;

            CurrentAdventure = new Adventure();
            StoryNode root = new StoryNode();
            CurrentAdventure.RootStoryNodes.Add(root);
            CurrentAdventure.StartingPoint = root;
            CurrentAdventureChanged();
            Dirty = false;
        }
コード例 #12
0
        public override void Refresh()
        {
            StoryNode selectednode = this.SelectedStoryNode;

            ReverseNodeMapping.Clear();
            if (Adventure == null) return;

            /* Remove Old Nodes */
            List<TreeNode> ToRemove = new List<TreeNode>();
            foreach(TreeNode node in this.Nodes) {
                bool Found = false;
                foreach(StoryNode storynode in Adventure.RootStoryNodes) {
                    if(node.Tag == storynode) {
                        Found = true;
                        break;
                    }
                }
                if (!Found) {
                    ToRemove.Add(node);
                }
            }
            foreach(TreeNode node in ToRemove) {
                this.Nodes.Remove(node);
            }

            /* Add/Update Existing Nodes */
            foreach(StoryNode storyNode in Adventure.RootStoryNodes) {
                TreeNode child = null;
                foreach(TreeNode node in this.Nodes) {
                    if(node.Tag == storyNode) {
                        child = node;
                        break;
                    }
                }

                if (child == null){
                    this.Nodes.Add(CreateTreeNode(storyNode));
                } else {
                    this.BindData(child, storyNode);
                    UpdateNode(child);
                }
            }

            if(selectednode != null && ReverseNodeMapping.ContainsKey(selectednode)) {
                this.SelectedStoryNode = selectednode;
            }

            /* Ensure all reference nodes reference an existing node */
            List<KeyValuePair<StoryNode, TreeNode>> ToUpdate = new List<KeyValuePair<StoryNode, TreeNode>>();
            foreach (KeyValuePair<StoryNode, TreeNode> kvp in ReverseNodeMapping) {
                if (kvp.Key is ReferenceNode) {
                    ReferenceNode node = kvp.Key as ReferenceNode;
                    if (!ReverseNodeMapping.ContainsKey(node.Reference)) {
                        ToUpdate.Add(kvp);
                    }
                }
            }
            if (ToUpdate.Count > 0) {
                foreach (KeyValuePair<StoryNode, TreeNode> node in ToUpdate) {
                    ReferenceNode refNode = node.Key as ReferenceNode;

                    if (ReverseNodeMapping.ContainsKey(refNode.Reference)) {
                        continue; // Already updated...
                    }
                    StoryNode parentNode = (StoryNode)node.Value.Parent.Tag;

                    bool FoundOne = false;
                    foreach (Option opt in parentNode.Options) {
                        if (opt.Node == refNode) {
                            opt.Node = refNode.Reference;
                            node.Value.Tag = opt.Node;
                            ReverseNodeMapping[opt.Node] = node.Value;
                            FoundOne = true;
                            break;
                        }
                    }

                    if (!FoundOne) {
                        throw new Exception("Failed to find reference node to non existant story node");
                    }
                }
                Refresh();
            }
        }
コード例 #13
0
        private TreeNode CreateTreeNode(StoryNode storyNode)
        {
            TreeNode node = new TreeNode(storyNode.Name);
            this.BindData(node, storyNode);

            /* Context Menu Strip */
            ContextMenuStrip NodeOptions = new ContextMenuStrip();
            NodeOptions.Tag = node;
            ToolStripItem ExpandAll = NodeOptions.Items.Add("Expand All");
            ExpandAll.Tag = node;
            ExpandAll.Click += new EventHandler(ExpandAll_Click);

            ToolStripItem CollapseAll = NodeOptions.Items.Add("Collapse All");
            CollapseAll.Tag = node;
            CollapseAll.Click += new EventHandler(CollapseAll_Click);

            node.ContextMenuStrip = NodeOptions;

            /* Children */
            if(!(storyNode is ReferenceNode)) {
                foreach(Option option in storyNode.Options) {
                    node.Nodes.Add(CreateTreeNode(option.Node));
                }
            }
            return node;
        }
コード例 #14
0
        private void BindData(TreeNode node, StoryNode data)
        {
            node.Text = data.Name;
            node.Tag = data;

            if(!ReverseNodeMapping.ContainsKey(data)) {
                ReverseNodeMapping.Add(data, node);
            } else {
                ReverseNodeMapping[data] = node;
            }

            if(data == Adventure.StartingPoint) {
                node.ForeColor = Color.Green;
            } else if(data is ReferenceNode) {
                node.ForeColor = Color.Blue;
            } else {
                node.ForeColor = Color.Black;
            }
        }