AddEncounter() публичный Метод

public AddEncounter ( EncounterNodeData encounter ) : void
encounter EncounterNodeData
Результат void
Пример #1
0
        public override NodeData Clone(GameMasterNode nodeFile)
        {
            EncounterNodeData newNodeData = new EncounterNodeData();

            newNodeData.NodeFile        = nodeFile;
            newNodeData.mEncounterType  = mEncounterType;
            newNodeData.mInEdge         = mInEdge;
            newNodeData.mOutEdgeStrings = new List <string>();
            newNodeData.mIsStartNode    = mIsStartNode;

            if (NodeFile.Owner != null && NodeFile.Owner.NodeType == GameMasterNodeType.ARC)
            {
                ArcNodeData ownerArcData = NodeFile.Owner.NodeData as ArcNodeData;
                ownerArcData.AddEncounter(newNodeData);
                nodeFile.Owner = NodeFile.Owner;
            }

            return(newNodeData);
        }
Пример #2
0
        public override bool AddOutEdge(GameMasterNode nodeFile)
        {
            if (nodeFile.NodeType != GameMasterNodeType.ENCOUNTER)
            {
                return(false);
            }

            EncounterNodeData encounterData = nodeFile.NodeData as EncounterNodeData;
            string            inEdge        = encounterData.InEdge;

            if (encounterData.IsStartNode)
            {
                // Cannot add start nodes to an encounter. they should be added to arc
                return(false);
            }

            List <string> outEdges = GetOutEdges();

            if (outEdges.Contains(nodeFile.Id))
            {
                // This item is already part of the out edges
                return(false);
            }

            if (!mOutEdgeStrings.Contains(inEdge))
            {
                // This out edge isn't already in the list of possible out edges, see if we can add it.
                switch (mEncounterType)
                {
                case "generator":
                    // Cannot add more than one edge to generator
                    return(false);

                case "random_out_edge":
                    JObject randomOutEdgesDictionary = (JObject)NodeFile.Json["random_out_edge_info"]["out_edges"];
                    randomOutEdgesDictionary.Add(inEdge, JObject.Parse(@"{""weight"":1 }"));
                    mOutEdgeStrings.Add(inEdge);
                    break;

                case "collection_quest":
                    return(false);

                case "dialog_tree":
                    // We can't add to a dialog tree, you have to specify a node.
                    return(false);

                case "counter":
                    // Cannot add to a counter because it either does fail or success
                    return(false);

                default:
                    NodeFile.Json.Remove("out_edge");
                    mOutEdgeStrings.Add(inEdge);
                    NodeFile.Json.Add("out_edge", JsonConvert.SerializeObject(mOutEdgeStrings));
                    break;
                }
            }

            if (nodeFile.Owner != NodeFile.Owner)
            {
                // make sure encounter is added to this tree
                ArcNodeData ownerArcData = NodeFile.Owner.NodeData as ArcNodeData;
                ownerArcData.AddEncounter(encounterData);
                nodeFile.Owner = NodeFile.Owner;
            }

            NodeFile.IsModified = true;
            return(true);
        }