示例#1
0
        private static bool ImportArticyPins(ArticyFlowObject source, BaseDialogueObject target, bool compileInputScripts, bool compileOutputScripts, Dictionary <ulong, DialoguePin> pinIndex)
        {
            FlowObjectPin articyPin;
            DialoguePin   pin;
            bool          badScripts = false;

            foreach (GraphPin graphPin in source.Inputs)
            {
                articyPin = (FlowObjectPin)graphPin;
                pin       = new DialoguePin(articyPin.Type);
                if (compileInputScripts && !string.IsNullOrWhiteSpace(articyPin.Script))
                {
                    if ((pin.Script = CompileScript(articyPin.Script, Dialogues.InputPinScriptEnvironment, "input pin", articyPin.Id)) == null)
                    {
                        badScripts = true;
                    }
                }
                if (string.IsNullOrEmpty(target.Key))
                {
                    GameDebugger.Log(LogLevel.Debug, "Adding intput pin to '0x{0:X16}'", target.Id);
                }
                else
                {
                    GameDebugger.Log(LogLevel.Debug, "Adding intput pin to '{0}'", target.Key);
                }
                pinIndex.Add(articyPin.Id, pin);
                target.AddInput(pin);
            }

            foreach (GraphPin graphPin in source.Outputs)
            {
                articyPin = (FlowObjectPin)graphPin;
                pin       = new DialoguePin(articyPin.Type);
                if (compileOutputScripts && !string.IsNullOrWhiteSpace(articyPin.Script))
                {
                    if ((pin.Script = CompileScript(articyPin.Script, Dialogues.InstructionScriptEnvironment, "output pin", articyPin.Id)) == null)
                    {
                        badScripts = true;
                    }
                }
                if (string.IsNullOrEmpty(target.Key))
                {
                    GameDebugger.Log(LogLevel.Debug, "Adding output pin to '0x{0:X16}'", target.Id);
                }
                else
                {
                    GameDebugger.Log(LogLevel.Debug, "Adding output pin to '{0}'", target.Key);
                }
                pinIndex.Add(articyPin.Id, pin);
                target.AddOutput(pin);
            }

            return(badScripts);
        }
示例#2
0
        /// <summary>
        /// Looks for dialogue fragments and builds list of next available menu choices
        /// </summary>
        /// <param name="fromPin"></param>
        /// <returns>TRUE if there was a connection to the end of dialogue</returns>
        public bool BuildChoices(DialoguePin fromPin)
        {
            List <DialogueFragment> fragments = new List <DialogueFragment>();
            bool endDialogue = BuildChoices(fromPin, fragments);

            if (endDialogue || fragments.Count == 0)
            {
                endDialogue      = true;
                AvailableChoices = null;
            }
            else
            {
                AvailableChoices = fragments.ToArray();
            }
            return(endDialogue);
        }
示例#3
0
        protected bool BuildChoices(GraphPin inputPin, List <DialogueFragment> fragments)
        {
            DialoguePin pin = inputPin as DialoguePin;

            if (pin == null)
            {
                return(false);
            }

            BaseDialogueObject obj = pin.Node as BaseDialogueObject;

            if (obj == null)
            {
                return(false);
            }

            if (pin.Type == GraphPin.PinType.Output && obj is Dialogue)
            {
                return(true);                // connection to a dialogue output is reached so it's the end of the dialogue
            }
            bool processObject = true;

            if (pin.Script != null)
            {
                dynamic result = pin.Script.Run(this);
                if (pin.Type == GraphPin.PinType.Input)
                {
                    if (!(result is Boolean))
                    {
                        GameDebugger.Log(LogLevel.Warning, "One of input pins script on dialogue object '0x{0:X16}' exits with a non boolean result ({1})", obj.Id, result.GetType().Name);
                        return(true);                 // end the dialogue due to error
                    }
                    if (!result)                      // input pin is a condition. if it returns false, then object is not processed
                    {
                        processObject = false;
                    }
                }
            }

            if (processObject && !(obj is Dialogue) && pin.Type == GraphPin.PinType.Input)
            {
                if (BuildChoices(obj, fragments))
                {
                    return(true);
                }
            }

            foreach (GraphConnection conn in pin.Connections)
            {
                if (conn.Target == pin)
                {
                    continue;                             // ignore incoming connections
                }
                if (BuildChoices(conn.Target, fragments)) // recursion through connections
                {
                    return(true);
                }
            }

            return(false);
        }