Exemple #1
0
        private void LoadBranch(string guid)
        {
            currentBranch = guidBranches[guid].GetData() as ScenimaticBranch;
            if (currentBranch != null)
            {
                Dictionary <string, string> replaceWords = new Dictionary <string, string>();
                for (int i = 1; i < currentBranch.connectionInputs.Count; ++i)
                {
                    var conn = currentBranch.connectionInputs[i];
                    replaceWords.Add("{" + conn.variableName + "}", guidPassedVariables[conn.connectedToGUIDs[0]]);
                }

                foreach (var evnt in currentBranch.events)
                {
                    var eventType = evnt.eventType;
                    switch (eventType)
                    {
                    case ScenimaticEvent.ScenimaticEventType.Dialog:
                        foreach (var replace in replaceWords)
                        {
                            evnt.text = evnt.text.Replace(replace.Key, replace.Value);
                        }
                        eventQueue.Enqueue(evnt);
                        break;

                    case ScenimaticEvent.ScenimaticEventType.Query:
                        eventQueue.Enqueue(evnt);
                        break;

                    default:
                        Debug.Log("Unknown event type: " + eventType);
                        break;
                    }
                }

                dialogPanel.Show();
                NextEventInQueue();
            }
            else
            {
                Debug.Log("over!");
                Gateway  exit         = scriptEnd.data;
                string[] outputParams = new string[exit.connections.Count - 1];
                for (int i = 0; i < outputParams.Length; ++i)
                {
                    outputParams[i] = guidPassedVariables[exit.connections[i + 1].connectedToGUIDs[0]];
                    Debug.Log("OutputParam: " + outputParams[i]);
                }

                dialogPanel.Hide();
            }
        }
Exemple #2
0
        public void LoadScenimatic(string path)
        {
            ClearPanels();
            currentBranch = null;
            eventPath     = path;
            StreamReader reader     = new StreamReader(eventPath);
            string       fileString = reader.ReadToEnd();

            reader.Close();

            ScenimaticScript script = JsonUtility.FromJson <ScenimaticScript>(fileString);

            scriptStart = script.inputNode;
            scriptEnd   = script.outputNode;
            // this is not ideal. It will force users to have their sprite atlas in a resource folder.
            dialogPanel.spriteAtlas = Resources.Load <SpriteAtlas>(script.spriteAtlas);

            guidBranches          = new Dictionary <string, ISerializedEntity>();
            guidConnectionOutputs = new Dictionary <string, Connection>();
            guidConnectionInputs  = new Dictionary <string, Connection>();

            foreach (var branch in script.branches)
            {
                guidBranches.Add(branch.data.GetMainControlFlowInputGUID(), branch);
                foreach (var conn in branch.data.connectionOutputs)
                {
                    guidConnectionOutputs.Add(conn.GUID, conn);
                }
                foreach (var conn in branch.data.connectionInputs)
                {
                    guidConnectionInputs.Add(conn.GUID, conn);
                }
            }

            guidBranches.Add(scriptEnd.data.connections[0].GUID, scriptEnd);

            foreach (var conn in scriptStart.data.connections)
            {
                guidConnectionOutputs.Add(conn.GUID, conn);
            }
            foreach (var conn in scriptEnd.data.connections)
            {
                guidConnectionInputs.Add(conn.GUID, conn);
            }
        }
Exemple #3
0
 public void LoadBranch(GraphEntityData branchData)
 {
     this.entityData = branchData;
     if (branchData is EventBranchObjectData)
     {
         gateway = null;
         var serializedBranch = (ScenimaticSerializedNode)
                                ((EventBranchObjectData)branchData).serializedNode;
         branch = serializedBranch.data;
     }
     else
     {
         branch = null;
         var serializedGateway =
             ((ScriptGatewayNodeData)branchData).serializedNode;
         gateway = serializedGateway.data;
     }
     Repaint();
 }