public void Trigger()
 {
     Fungus.Variable v = null;
     if (!flowchart)
     {
         flowchart = FindFlowchartWithVariable(variableName, out v);
     }
     else
     {
         v = FindVariable(flowchart, variableName);
     }
     if (v.GetType() == typeof(Fungus.StringVariable))
     {
         flowchart.SetStringVariable(variableName, flowchart.GetStringVariable(variableName) + variableValue);
     }
     if (v.GetType() == typeof(Fungus.FloatVariable))
     {
         flowchart.SetFloatVariable(variableName, flowchart.GetFloatVariable(variableName) + System.Single.Parse(variableValue));
     }
     if (v.GetType() == typeof(Fungus.IntegerVariable))
     {
         flowchart.SetIntegerVariable(variableName, flowchart.GetIntegerVariable(variableName) + System.Int32.Parse(variableValue));
     }
     if (v.GetType() == typeof(Fungus.BooleanVariable))
     {
         flowchart.SetBooleanVariable(variableName, !flowchart.GetBooleanVariable(variableName));
     }
 }
 private void Awake()
 {
     Instance = this;
     talkButton.onClick.AddListener(OnTalkButtonClick);
     MyTools.SetActive(talkButton.gameObject, false);
     Flowchart = FindObjectOfType <Fungus.Flowchart>();
 }
예제 #3
0
    public void UpdateFlowchart(Fungus.Flowchart flowchart, Employee emp)
    {
        Fungus.StringVariable  option = (Fungus.StringVariable)flowchart.GetVariable("option");
        Fungus.BooleanVariable done   = (Fungus.BooleanVariable)flowchart.GetVariable("done");
        Fungus.BooleanVariable lunch  = (Fungus.BooleanVariable)flowchart.GetVariable("lunch");

        if (curr_state == State.LUNCH)
        {
            lunch.Value = true;
        }
        bool can_interact = (emp.GetMinDaysBetweenInteraction() >= emp.days_since_interaction);

        if (option.Evaluate(Fungus.CompareOperator.NotEquals, "default") && can_interact)
        {
            bool not_done = true;
            if (option.Evaluate(Fungus.CompareOperator.Equals, "bad"))
            {
                not_done = emp.SetCurrQuestion("bad");
            }
            else if (option.Evaluate(Fungus.CompareOperator.Equals, "good"))
            {
                not_done = emp.SetCurrQuestion("good");
            }
            if (not_done)
            {
                employee_manager.SetFlowchart(emp.curr_question, flowchart.FindBlock("Question").CommandList);
            }
            option.Value = "default";
            done.Value   = !not_done;
            emp.days_since_interaction = 0;
        }
    }
예제 #4
0
    void Start()
    {
        ch     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <CharacterHandler>();
        player = ch.GetPlayer();

        flow = GameObject.Find("Fungus").GetComponent <Fungus.Flowchart>();
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
#if UNITY_EDITOR
        currentMap = SceneManager.GetSceneByName(editorOverride);
#endif

        loadDelay = new WaitForSeconds(0.1f);
        party     = GetComponentInChildren <Party>();

        questFlags = GameObject.Find("QuestFlags").GetComponent <Fungus.Flowchart>();
        inventory  = GameObject.Find("Inventory").GetComponent <Fungus.Flowchart>();
        systemChat = GameObject.Find("SystemChat").GetComponent <Fungus.Flowchart>();

        if (SceneManager.sceneCount > 1)
        {
            SceneManager.LoadScene("Core");
        }

        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Debug.LogError("WARNING: multiple instances of GameMaster created!");
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        flowchart = Services.gameController.flowchart;

        hype.variable   = flowchart.GetVariable("Hype");
        bubbly.variable = flowchart.GetVariable("Bubbly");
        chill.variable  = flowchart.GetVariable("Chill");
    }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     // Since the intro will play, just set it to be active regardless what!
     //m_introDisplayGO.SetActive(true);
     if (!m_dialogueFlowchart)
     {
         m_dialogueFlowchart = FindObjectOfType <Fungus.Flowchart>();
     }
 }
예제 #8
0
 // Use this for initialization
 void Start()
 {
     if (GM == null)
     {
         GM = GameObject.Find("GameMaster").GetComponent <GameMaster>();
     }
     Fungus.Flowchart          fc  = GetComponent <Fungus.Flowchart>();
     Fungus.GameObjectVariable fGO = null;
     fGO       = fc.GetVariable("Self") as Fungus.GameObjectVariable;
     fGO.Value = this.gameObject;
 }
예제 #9
0
    // Start is called before the first frame update
    void Start()
    {
        sceneController = FindObjectOfType <SceneController>();

        if (flowchart == null && flowchartName != null && flowchartName.Trim().Length != 0)
        {
            flowchart = GameObject.Find(flowchartName).GetComponent <Fungus.Flowchart>();
        }

        flowchart.ExecuteBlock(blockName);
    }
예제 #10
0
파일: NPC.cs 프로젝트: Fuinaru/Game
 void Start()
 {
     if (transform.tag == "chart")
     {
         flowchart = GetComponent <Fungus.Flowchart>();
         character = m_character;
         if (m_img != null)
         {
             img = m_img;
         }
     }
 }
    public static Fungus.Variable FindVariable(Fungus.Flowchart flowchart, string variableName)
    {
        List <Fungus.Variable> vars = flowchart.Variables;

        for (int i = 0; i < vars.Count; ++i)
        {
            if (vars[i].Key == variableName)
            {
                return(vars[i]);
            }
        }
        return(null);
    }
예제 #12
0
    void Start()
    {
        if (fovKick)
        {
            fp = GameObject.Find("Player Camera").GetComponent <FovPopper>();
        }
        mgr     = GameObject.Find("Hotspot Manager").GetComponent <HotspotManager>();
        gameMgr = GameObject.Find("Game Manager").GetComponent <GameManager>();

        if (flowchart == null)
        {
            flowchart = GameObject.Find("Flowchart").GetComponent <Fungus.Flowchart>();
        }
    }
예제 #13
0
    public void GetPartyFlowchart()
    {
        flowchartGameObject = GameObject.FindGameObjectWithTag("Flowchart");

        if (flowchart == null)
        {
            flowchart = flowchartGameObject.GetComponent <Fungus.Flowchart>();
            FungusVariableManager.Initialize();
            FungusVariableManager.StoreStructToFlowchart();
        }
        else
        {
            GameObject.Destroy(flowchartGameObject);
        }
    }
예제 #14
0
    // Use this for initialization
    void Start()
    {
        Time.timeScale = 1f;
        MouseLock.instance.lockMouse();

        fc = GameObject.Find("Flowchart").GetComponent <Fungus.Flowchart> ();

        hasCheat = "F";
        canCheat = UserDataManager.instance.GetCheat();

        // check if player has found tablet
        if (UserDataManager.instance.GetCow() == "T")
        {
            tabletIcon.SetActive(true);
        }
    }
 public static Fungus.Flowchart FindFlowchartWithVariable(string variableName, out Fungus.Variable foundVariable)
 {
     Fungus.Flowchart   flowchart = null;
     Fungus.Flowchart[] flows     = GameObject.FindObjectsOfType <Fungus.Flowchart>();
     foundVariable = null;
     for (var f = 0; f < flows.Length && foundVariable == null; ++f)
     {
         flowchart     = flows[f]; // check to see if the variable in question is in this flowchart
         foundVariable = FindVariable(flowchart, variableName);
     }
     if (!flowchart)
     {
         Debug.LogError("Could not find flowchart with variable \"" + variableName + "\"");
     }
     return(flowchart);
 }
    void CheckForUsableObject(int direction)
    {
        //making sure this can't be triggered during a fight or character is otherwise locked down
        if (!canAct || !canMove)
        {
            return;
        }

        Vector2 checkDir = Vector2.zero;

        RaycastHit2D[] hitList = new RaycastHit2D[5];

        switch (direction)
        {
        case StaticData.DIR_UP:
            checkDir.y = 1;
            break;

        case StaticData.DIR_DOWN:
            checkDir.y = -1;
            break;

        case StaticData.DIR_RIGHT:
            checkDir.x = 1;
            break;

        case StaticData.DIR_LEFT:
            checkDir.x = -1;
            break;
        }

        int hitCount = rb.Cast(checkDir, hitList, grid / 2);

        if (hitCount > 5)
        {
            Debug.LogError("Do not have more than 5 items stacked on one tile!  Bad designer, no twinkie!");
        }
        for (int i = 0; i < hitCount; i++)
        {
            Fungus.Flowchart fc = hitList[i].collider.gameObject.GetComponent <Fungus.Flowchart>();
            if (fc != null)
            {
                fc.ExecuteBlockDisableMove("InteractStart");
                break;
            } //end if
        }     //end for
    }         //end method
예제 #17
0
    public static void Initialize()
    {
        flowchart = Services.gameController.flowchart;

        _hype.variable             = flowchart.GetVariable("Hype");
        _bubbly.variable           = flowchart.GetVariable("Bubbly");
        _chill.variable            = flowchart.GetVariable("Chill");
        _metKelly.variable         = flowchart.GetVariable("MetKelly");
        _kellySolved.variable      = flowchart.GetVariable("KellySolved");
        _metMeg.variable           = flowchart.GetVariable("MetMeg");
        _megSolved.variable        = flowchart.GetVariable("MegSolved");
        _metCori.variable          = flowchart.GetVariable("MetCori");
        _coriSolved.variable       = flowchart.GetVariable("CoriSolved");
        _metLeon.variable          = flowchart.GetVariable("MetLeon");
        _leonSolved.variable       = flowchart.GetVariable("LeonSolved");
        _metCody.variable          = flowchart.GetVariable("MetCody");
        _codySolved.variable       = flowchart.GetVariable("CodySolved");
        _metJamie.variable         = flowchart.GetVariable("MetJamie");
        _jamieSolved.variable      = flowchart.GetVariable("JamieSolved");
        _coriProblem.variable      = flowchart.GetVariable("CoriProblem");
        _leonProblem.variable      = flowchart.GetVariable("LeonProblem");
        _codyProblem.variable      = flowchart.GetVariable("CodyProblem");
        _encounterCounter.variable = flowchart.GetVariable("EncounterCounter");
    }
예제 #18
0
        protected virtual void DrawFlowchartView(Flowchart flowchart)
        {
            Block[] blocks = flowchart.GetComponentsInChildren <Block>(true);

            foreach (Block block in blocks)
            {
                flowchart.scrollViewRect.xMin = Mathf.Min(flowchart.scrollViewRect.xMin, block.nodeRect.xMin - 400);
                flowchart.scrollViewRect.xMax = Mathf.Max(flowchart.scrollViewRect.xMax, block.nodeRect.xMax + 400);
                flowchart.scrollViewRect.yMin = Mathf.Min(flowchart.scrollViewRect.yMin, block.nodeRect.yMin - 400);
                flowchart.scrollViewRect.yMax = Mathf.Max(flowchart.scrollViewRect.yMax, block.nodeRect.yMax + 400);
            }

            // Calc rect for script view
            Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.zoom, this.position.height / flowchart.zoom);

            EditorZoomArea.Begin(flowchart.zoom, scriptViewRect);

            DrawGrid(flowchart);

            GLDraw.BeginGroup(scriptViewRect);

            if (Event.current.button == 0 &&
                Event.current.type == EventType.MouseDown &&
                !mouseOverVariables)
            {
                flowchart.selectedBlock = null;
                if (!EditorGUI.actionKey)
                {
                    flowchart.ClearSelectedCommands();
                }
                Selection.activeGameObject = flowchart.gameObject;
            }

            // Draw connections
            foreach (Block block in blocks)
            {
                DrawConnections(flowchart, block, false);
            }
            foreach (Block block in blocks)
            {
                DrawConnections(flowchart, block, true);
            }

            GUIStyle windowStyle = new GUIStyle();

            windowStyle.stretchHeight = true;

            BeginWindows();

            windowBlockMap.Clear();
            for (int i = 0; i < blocks.Length; ++i)
            {
                Block block = blocks[i];

                float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.blockName)).x + 10;
                float nodeWidthB = 0f;
                if (block.eventHandler != null)
                {
                    nodeWidthB = nodeStyle.CalcSize(new GUIContent(block.eventHandler.GetSummary())).x + 10;
                }

                block.nodeRect.width  = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120);
                block.nodeRect.height = 40;

                if (Event.current.button == 0)
                {
                    if (Event.current.type == EventType.MouseDrag && dragWindowId == i)
                    {
                        block.nodeRect.x += Event.current.delta.x;
                        block.nodeRect.y += Event.current.delta.y;

                        forceRepaintCount = 6;
                    }
                    else if (Event.current.type == EventType.MouseUp &&
                             dragWindowId == i)
                    {
                        Vector2 newPos = new Vector2(block.nodeRect.x, block.nodeRect.y);

                        block.nodeRect.x = startDragPosition.x;
                        block.nodeRect.y = startDragPosition.y;

                        Undo.RecordObject(block, "Node Position");

                        block.nodeRect.x = newPos.x;
                        block.nodeRect.y = newPos.y;

                        dragWindowId      = -1;
                        forceRepaintCount = 6;
                    }
                }

                Rect windowRect = new Rect(block.nodeRect);
                windowRect.x += flowchart.scrollPos.x;
                windowRect.y += flowchart.scrollPos.y;

                GUILayout.Window(i, windowRect, DrawWindow, "", windowStyle);

                GUI.backgroundColor = Color.white;

                windowBlockMap.Add(block);
            }

            EndWindows();

            // Draw Event Handler labels
            foreach (Block block in blocks)
            {
                if (block.eventHandler != null)
                {
                    string handlerLabel            = "";
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType());
                    if (info != null)
                    {
                        handlerLabel = "<" + info.EventHandlerName + "> ";
                    }

                    GUIStyle handlerStyle = new GUIStyle(EditorStyles.whiteLabel);
                    handlerStyle.wordWrap      = true;
                    handlerStyle.margin.top    = 0;
                    handlerStyle.margin.bottom = 0;
                    handlerStyle.alignment     = TextAnchor.MiddleCenter;

                    Rect rect = new Rect(block.nodeRect);
                    rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width);
                    rect.x     += flowchart.scrollPos.x;
                    rect.y     += flowchart.scrollPos.y - rect.height;

                    GUI.Label(rect, handlerLabel, handlerStyle);
                }
            }


            // Draw play icons beside all executing blocks
            if (Application.isPlaying)
            {
                foreach (Block b in blocks)
                {
                    if (b.IsExecuting())
                    {
                        b.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
                        b.activeCommand.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
                        forceRepaintCount = 6;
                    }

                    if (b.executingIconTimer > Time.realtimeSinceStartup)
                    {
                        Rect rect = new Rect(b.nodeRect);

                        rect.x     += flowchart.scrollPos.x - 37;
                        rect.y     += flowchart.scrollPos.y + 3;
                        rect.width  = 34;
                        rect.height = 34;

                        if (!b.IsExecuting())
                        {
                            float alpha = (b.executingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
                            alpha     = Mathf.Clamp01(alpha);
                            GUI.color = new Color(1f, 1f, 1f, alpha);
                        }

                        if (GUI.Button(rect, FungusEditorResources.texPlayBig as Texture, new GUIStyle()))
                        {
                            SelectBlock(flowchart, b);
                        }

                        GUI.color = Color.white;
                    }
                }
            }

            PanAndZoom(flowchart);

            GLDraw.EndGroup();

            EditorZoomArea.End();
        }
예제 #19
0
        public virtual void DrawVariablesGUI()
        {
            serializedObject.Update();

            Flowchart t = target as Flowchart;

            if (t.variables.Count == 0)
            {
                t.variablesExpanded = true;
            }

            if (!t.variablesExpanded)
            {
                if (GUILayout.Button("Variables (" + t.variables.Count + ")", GUILayout.Height(24)))
                {
                    t.variablesExpanded = true;
                }

                // Draw disclosure triangle
                Rect lastRect = GUILayoutUtility.GetLastRect();
                lastRect.x += 5;
                lastRect.y += 5;
                EditorGUI.Foldout(lastRect, false, "");
            }
            else
            {
                Rect listRect = new Rect();

                if (t.variables.Count > 0)
                {
                    // Remove any null variables from the list
                    // Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class)
                    for (int i = t.variables.Count - 1; i >= 0; i--)
                    {
                        if (t.variables[i] == null)
                        {
                            t.variables.RemoveAt(i);
                        }
                    }

                    ReorderableListGUI.Title("Variables");
                    VariableListAdaptor adaptor = new VariableListAdaptor(variablesProp, 0);

                    ReorderableListFlags flags = ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton;

                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                    listRect = GUILayoutUtility.GetLastRect();
                }
                else
                {
                    GUILayoutUtility.GetRect(300, 24);
                    listRect    = GUILayoutUtility.GetLastRect();
                    listRect.y += 20;
                }

                float plusWidth  = 32;
                float plusHeight = 24;

                Rect  buttonRect   = listRect;
                float buttonHeight = 24;
                buttonRect.x      = 4;
                buttonRect.y     -= buttonHeight - 1;
                buttonRect.height = buttonHeight;
                if (!Application.isPlaying)
                {
                    buttonRect.width -= 30;
                }

                if (GUI.Button(buttonRect, "Variables"))
                {
                    t.variablesExpanded = false;
                }

                // Draw disclosure triangle
                Rect lastRect = buttonRect;
                lastRect.x += 5;
                lastRect.y += 5;
                EditorGUI.Foldout(lastRect, true, "");

                Rect plusRect = listRect;
                plusRect.x     += plusRect.width - plusWidth;
                plusRect.y     -= plusHeight - 1;
                plusRect.width  = plusWidth;
                plusRect.height = plusHeight;

                if (!Application.isPlaying &&
                    GUI.Button(plusRect, addTexture))
                {
                    GenericMenu        menu  = new GenericMenu();
                    List <System.Type> types = FindAllDerivedTypes <Variable>();

                    // Add variable types without a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category != "")
                        {
                            continue;
                        }

                        AddVariableInfo addVariableInfo = new AddVariableInfo();
                        addVariableInfo.flowchart    = t;
                        addVariableInfo.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, addVariableInfo);
                    }

                    // Add types with a category
                    foreach (System.Type type in types)
                    {
                        VariableInfoAttribute variableInfo = VariableEditor.GetVariableInfo(type);
                        if (variableInfo == null ||
                            variableInfo.Category == "")
                        {
                            continue;
                        }

                        AddVariableInfo info = new AddVariableInfo();
                        info.flowchart    = t;
                        info.variableType = type;

                        GUIContent typeName = new GUIContent(variableInfo.Category + "/" + variableInfo.VariableType);

                        menu.AddItem(typeName, false, AddVariable, info);
                    }

                    menu.ShowAsContext();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #20
0
        public virtual void DrawCommandInspectorGUI()
        {
            Command t = target as Command;

            if (t == null)
            {
                return;
            }

            Flowchart flowchart = t.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(t.GetType());

            if (commandInfoAttr == null)
            {
                return;
            }

            GUILayout.BeginVertical(GUI.skin.box);

            if (t.enabled)
            {
                if (flowchart.colorCommands)
                {
                    GUI.backgroundColor = t.GetButtonColor();
                }
                else
                {
                    GUI.backgroundColor = Color.white;
                }
            }
            else
            {
                GUI.backgroundColor = Color.grey;
            }
            GUILayout.BeginHorizontal(GUI.skin.button);

            string commandName = commandInfoAttr.CommandName;

            GUILayout.Label(commandName, GUILayout.MinWidth(80), GUILayout.ExpandWidth(true));

            GUILayout.FlexibleSpace();

            GUILayout.Label(new GUIContent("(" + t.itemId + ")"));

            GUILayout.Space(10);

            GUI.backgroundColor = Color.white;
            bool enabled = t.enabled;

            enabled = GUILayout.Toggle(enabled, new GUIContent());

            if (t.enabled != enabled)
            {
                Undo.RecordObject(t, "Set Enabled");
                t.enabled = enabled;
            }

            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;

            EditorGUILayout.Separator();

            DrawCommandGUI();

            EditorGUILayout.Separator();

            if (t.errorMessage.Length > 0)
            {
                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.normal.textColor = new Color(1, 0, 0);
                EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
            }

            GUILayout.EndVertical();

            // Display help text
            CommandInfoAttribute infoAttr = CommandEditor.GetCommandInfo(t.GetType());

            if (infoAttr != null)
            {
                EditorGUILayout.HelpBox(infoAttr.HelpText, MessageType.Info, true);
            }
        }
예제 #21
0
        protected virtual void DrawWindow(int windowId)
        {
            Block     block     = windowBlockMap[windowId];
            Flowchart flowchart = block.GetFlowchart();

            if (flowchart == null)
            {
                return;
            }

            // Select block when node is clicked
            if (Event.current.button == 0 &&
                Event.current.type == EventType.MouseDown &&
                !mouseOverVariables)
            {
                // Check if might be start of a window drag
                if (Event.current.button == 0 &&
                    Event.current.alt == false)
                {
                    dragWindowId        = windowId;
                    startDragPosition.x = block.nodeRect.x;
                    startDragPosition.y = block.nodeRect.y;
                }

                if (windowId < windowBlockMap.Count)
                {
                    Undo.RecordObject(flowchart, "Select");

                    SelectBlock(flowchart, block);

                    GUIUtility.keyboardControl = 0;                     // Fix for textarea not refeshing (change focus)
                }
            }

            bool selected = (flowchart.selectedBlock == block);

            GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle);

            if (block.eventHandler != null)
            {
                nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff;
            }
            else
            {
                // Count the number of unique connections (excluding self references)
                List <Block> uniqueList      = new List <Block>();
                List <Block> connectedBlocks = block.GetConnectedBlocks();
                foreach (Block connectedBlock in connectedBlocks)
                {
                    if (connectedBlock == block ||
                        uniqueList.Contains(connectedBlock))
                    {
                        continue;
                    }
                    uniqueList.Add(connectedBlock);
                }

                if (uniqueList.Count > 1)
                {
                    nodeStyleCopy.normal.background = selected ? FungusEditorResources.texChoiceNodeOn : FungusEditorResources.texChoiceNodeOff;
                }
                else
                {
                    nodeStyleCopy.normal.background = selected ? FungusEditorResources.texProcessNodeOn : FungusEditorResources.texProcessNodeOff;
                }
            }

            nodeStyleCopy.normal.textColor = Color.black;

            // Make sure node is wide enough to fit the node name text
            float width = nodeStyleCopy.CalcSize(new GUIContent(block.blockName)).x;

            block.nodeRect.width = Mathf.Max(block.nodeRect.width, width);

            GUI.backgroundColor = Color.white;
            GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height));

            if (block.description.Length > 0)
            {
                GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox);
                descriptionStyle.wordWrap = true;
                GUILayout.Label(block.description, descriptionStyle);
            }

            if (Event.current.type == EventType.ContextClick)
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent("Duplicate"), false, DuplicateBlock, block);
                menu.AddItem(new GUIContent("Delete"), false, DeleteBlock, block);

                menu.ShowAsContext();
            }
        }
예제 #22
0
 // Start is called before the first frame update
 void Start()
 {
     base.Start();
     fc = GameObject.Find("Flowchart").GetComponent <Fungus.Flowchart>();
 }
예제 #23
0
파일: Writer.cs 프로젝트: alexisbell/Fungus
        protected virtual IEnumerator ProcessTokens(List <TextTagParser.Token> tokens, Action onComplete)
        {
            // Reset control members
            boldActive              = false;
            italicActive            = false;
            colorActive             = false;
            colorText               = "";
            currentPunctuationPause = punctuationPause;
            currentWritingSpeed     = writingSpeed;

            exitFlag  = false;
            isWriting = true;

            foreach (TextTagParser.Token token in tokens)
            {
                switch (token.type)
                {
                case TextTagParser.TokenType.Words:
                    yield return(StartCoroutine(DoWords(token.paramList)));

                    break;

                case TextTagParser.TokenType.BoldStart:
                    boldActive = true;
                    break;

                case TextTagParser.TokenType.BoldEnd:
                    boldActive = false;
                    break;

                case TextTagParser.TokenType.ItalicStart:
                    italicActive = true;
                    break;

                case TextTagParser.TokenType.ItalicEnd:
                    italicActive = false;
                    break;

                case TextTagParser.TokenType.ColorStart:
                    if (CheckParamCount(token.paramList, 1))
                    {
                        colorActive = true;
                        colorText   = token.paramList[0];
                    }
                    break;

                case TextTagParser.TokenType.ColorEnd:
                    colorActive = false;
                    break;

                case TextTagParser.TokenType.Wait:
                    yield return(StartCoroutine(DoWait(token.paramList)));

                    break;

                case TextTagParser.TokenType.WaitForInputNoClear:
                    yield return(StartCoroutine(DoWaitForInput(false)));

                    break;

                case TextTagParser.TokenType.WaitForInputAndClear:
                    yield return(StartCoroutine(DoWaitForInput(true)));

                    break;

                case TextTagParser.TokenType.WaitOnPunctuationStart:
                    TryGetSingleParam(token.paramList, 0, punctuationPause, out currentPunctuationPause);
                    break;

                case TextTagParser.TokenType.WaitOnPunctuationEnd:
                    currentPunctuationPause = punctuationPause;
                    break;

                case TextTagParser.TokenType.Clear:
                    text = "";
                    break;

                case TextTagParser.TokenType.SpeedStart:
                    TryGetSingleParam(token.paramList, 0, writingSpeed, out currentWritingSpeed);
                    break;

                case TextTagParser.TokenType.SpeedEnd:
                    currentWritingSpeed = writingSpeed;
                    break;

                case TextTagParser.TokenType.Exit:
                    exitFlag = true;
                    break;

                case TextTagParser.TokenType.Message:
                    if (CheckParamCount(token.paramList, 1))
                    {
                        Flowchart.BroadcastFungusMessage(token.paramList[0]);
                    }
                    break;

                case TextTagParser.TokenType.VerticalPunch:
                {
                    float vintensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out vintensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(0, vintensity, 0), time);
                }
                break;

                case TextTagParser.TokenType.HorizontalPunch:
                {
                    float hintensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out hintensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(hintensity, 0, 0), time);
                }
                break;

                case TextTagParser.TokenType.Punch:
                {
                    float intensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out intensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(intensity, intensity, 0), time);
                }
                break;

                case TextTagParser.TokenType.Flash:
                    float flashDuration;
                    TryGetSingleParam(token.paramList, 0, 0.2f, out flashDuration);
                    Flash(flashDuration);
                    break;

                case TextTagParser.TokenType.Audio:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.PlayOneShot(audioSource.clip);
                    }
                }
                break;

                case TextTagParser.TokenType.AudioLoop:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Play();
                        audioSource.loop = true;
                    }
                }
                break;

                case TextTagParser.TokenType.AudioPause:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Pause();
                    }
                }
                break;

                case TextTagParser.TokenType.AudioStop:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Stop();
                    }
                }
                break;
                }

                if (exitFlag)
                {
                    break;
                }
            }

            inputFlag         = false;
            exitFlag          = false;
            isWaitingForInput = false;
            isWriting         = false;

            NotifyEnd();

            if (onComplete != null)
            {
                onComplete();
            }
        }
예제 #24
0
        protected virtual void DrawMultiLineProperty(Rect rect, GUIContent label, SerializedProperty referenceProp, SerializedProperty valueProp, Flowchart flowchart)
        {
            const int popupWidth = 100;

            Rect controlRect = rect;
            Rect valueRect   = controlRect;

            valueRect.width = controlRect.width - 5;
            Rect popupRect = controlRect;

            if (referenceProp.objectReferenceValue == null)
            {
                EditorGUI.PropertyField(valueRect, valueProp, label);
                popupRect.x     = rect.width - popupWidth + 5;
                popupRect.width = popupWidth;
            }
            else
            {
                popupRect = EditorGUI.PrefixLabel(rect, label);
            }

            EditorGUI.PropertyField(popupRect, referenceProp, new GUIContent(""));
        }
예제 #25
0
파일: Writer.cs 프로젝트: tomcat7607/fungus
        protected virtual IEnumerator ProcessTokens(List <TextTagToken> tokens, bool stopAudio, Action onComplete)
        {
            // Reset control members
            boldActive              = false;
            italicActive            = false;
            colorActive             = false;
            sizeActive              = false;
            colorText               = "";
            sizeValue               = 16f;
            currentPunctuationPause = punctuationPause;
            currentWritingSpeed     = writingSpeed;

            exitFlag  = false;
            isWriting = true;

            TokenType previousTokenType = TokenType.Invalid;

            for (int i = 0; i < tokens.Count; ++i)
            {
                // Pause between tokens if Paused is set
                while (Paused)
                {
                    yield return(null);
                }

                var token = tokens[i];

                // Notify listeners about new token
                WriterSignals.DoTextTagToken(this, token, i, tokens.Count);

                // Update the read ahead string buffer. This contains the text for any
                // Word tags which are further ahead in the list.
                readAheadString.Length = 0;
                for (int j = i + 1; j < tokens.Count; ++j)
                {
                    var readAheadToken = tokens[j];

                    if (readAheadToken.type == TokenType.Words &&
                        readAheadToken.paramList.Count == 1)
                    {
                        readAheadString.Append(readAheadToken.paramList[0]);
                    }
                    else if (readAheadToken.type == TokenType.WaitForInputAndClear)
                    {
                        break;
                    }
                }

                switch (token.type)
                {
                case TokenType.Words:
                    yield return(StartCoroutine(DoWords(token.paramList, previousTokenType)));

                    break;

                case TokenType.BoldStart:
                    boldActive = true;
                    break;

                case TokenType.BoldEnd:
                    boldActive = false;
                    break;

                case TokenType.ItalicStart:
                    italicActive = true;
                    break;

                case TokenType.ItalicEnd:
                    italicActive = false;
                    break;

                case TokenType.ColorStart:
                    if (CheckParamCount(token.paramList, 1))
                    {
                        colorActive = true;
                        colorText   = token.paramList[0];
                    }
                    break;

                case TokenType.ColorEnd:
                    colorActive = false;
                    break;

                case TokenType.SizeStart:
                    if (TryGetSingleParam(token.paramList, 0, 16f, out sizeValue))
                    {
                        sizeActive = true;
                    }
                    break;

                case TokenType.SizeEnd:
                    sizeActive = false;
                    break;

                case TokenType.Wait:
                    yield return(StartCoroutine(DoWait(token.paramList)));

                    break;

                case TokenType.WaitForInputNoClear:
                    yield return(StartCoroutine(DoWaitForInput(false)));

                    break;

                case TokenType.WaitForInputAndClear:
                    yield return(StartCoroutine(DoWaitForInput(true)));

                    break;

                case TokenType.WaitForVoiceOver:
                    yield return(StartCoroutine(DoWaitVO()));

                    break;

                case TokenType.WaitOnPunctuationStart:
                    TryGetSingleParam(token.paramList, 0, punctuationPause, out currentPunctuationPause);
                    break;

                case TokenType.WaitOnPunctuationEnd:
                    currentPunctuationPause = punctuationPause;
                    break;

                case TokenType.Clear:
                    textAdapter.Text = "";
                    break;

                case TokenType.SpeedStart:
                    TryGetSingleParam(token.paramList, 0, writingSpeed, out currentWritingSpeed);
                    break;

                case TokenType.SpeedEnd:
                    currentWritingSpeed = writingSpeed;
                    break;

                case TokenType.Exit:
                    exitFlag = true;
                    break;

                case TokenType.Message:
                    if (CheckParamCount(token.paramList, 1))
                    {
                        Flowchart.BroadcastFungusMessage(token.paramList[0]);
                    }
                    break;

                case TokenType.VerticalPunch:
                {
                    float vintensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out vintensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(0, vintensity, 0), time);
                }
                break;

                case TokenType.HorizontalPunch:
                {
                    float hintensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out hintensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(hintensity, 0, 0), time);
                }
                break;

                case TokenType.Punch:
                {
                    float intensity;
                    float time;
                    TryGetSingleParam(token.paramList, 0, 10.0f, out intensity);
                    TryGetSingleParam(token.paramList, 1, 0.5f, out time);
                    Punch(new Vector3(intensity, intensity, 0), time);
                }
                break;

                case TokenType.Flash:
                    float flashDuration;
                    TryGetSingleParam(token.paramList, 0, 0.2f, out flashDuration);
                    Flash(flashDuration);
                    break;

                case TokenType.Audio:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.PlayOneShot(audioSource.clip);
                    }
                }
                break;

                case TokenType.AudioLoop:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Play();
                        audioSource.loop = true;
                    }
                }
                break;

                case TokenType.AudioPause:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Pause();
                    }
                }
                break;

                case TokenType.AudioStop:
                {
                    AudioSource audioSource = null;
                    if (CheckParamCount(token.paramList, 1))
                    {
                        audioSource = FindAudio(token.paramList[0]);
                    }
                    if (audioSource != null)
                    {
                        audioSource.Stop();
                    }
                }
                break;
                }

                previousTokenType = token.type;

                if (exitFlag)
                {
                    break;
                }
            }

            inputFlag         = false;
            exitFlag          = false;
            isWaitingForInput = false;
            isWriting         = false;

            NotifyEnd(stopAudio);

            if (onComplete != null)
            {
                onComplete();
            }
        }
예제 #26
0
        static public void VariableField(SerializedProperty property,
                                         GUIContent label,
                                         Flowchart flowchart,
                                         string defaultText,
                                         Func <Variable, bool> filter,
                                         Func <string, int, string[], int> drawer = null)
        {
            List <string>   variableKeys    = new List <string>();
            List <Variable> variableObjects = new List <Variable>();

            variableKeys.Add(defaultText);
            variableObjects.Add(null);

            List <Variable> variables     = flowchart.variables;
            int             index         = 0;
            int             selectedIndex = 0;

            Variable selectedVariable = property.objectReferenceValue as Variable;

            // When there are multiple Flowcharts in a scene with variables, switching
            // between the Flowcharts can cause the wrong variable property
            // to be inspected for a single frame. This has the effect of causing private
            // variable references to be set to null when inspected. When this condition
            // occurs we just skip displaying the property for this frame.
            if (selectedVariable != null &&
                selectedVariable.gameObject != flowchart.gameObject)
            {
                return;
            }

            foreach (Variable v in variables)
            {
                if (filter != null)
                {
                    if (!filter(v))
                    {
                        continue;
                    }
                }

                variableKeys.Add(v.key);
                variableObjects.Add(v);

                index++;

                if (v == selectedVariable)
                {
                    selectedIndex = index;
                }
            }

            Flowchart[] fsList = GameObject.FindObjectsOfType <Flowchart>();
            foreach (Flowchart fs in fsList)
            {
                if (fs == flowchart)
                {
                    continue;
                }

                List <Variable> publicVars = fs.GetPublicVariables();
                foreach (Variable v in publicVars)
                {
                    if (filter != null)
                    {
                        if (!filter(v))
                        {
                            continue;
                        }
                    }

                    variableKeys.Add(fs.name + " / " + v.key);
                    variableObjects.Add(v);

                    index++;

                    if (v == selectedVariable)
                    {
                        selectedIndex = index;
                    }
                }
            }

            if (drawer == null)
            {
                selectedIndex = EditorGUILayout.Popup(label.text, selectedIndex, variableKeys.ToArray());
            }
            else
            {
                selectedIndex = drawer(label.text, selectedIndex, variableKeys.ToArray());
            }

            property.objectReferenceValue = variableObjects[selectedIndex];
        }
예제 #27
0
 void Start()
 {
     myFlowchart   = FindObjectOfType <Flowchart>();
     body          = GetComponent <Rigidbody2D>();
     boxCollider2d = transform.GetComponent <BoxCollider2D>();
 }
예제 #28
0
 public void GetPartyFlowchart()
 {
     flowchartGameObject = GameObject.Find("Party Flowchart");
     Object.DontDestroyOnLoad(flowchartGameObject);
     flowchart = flowchartGameObject.GetComponent <Fungus.Flowchart>();
 }
예제 #29
0
 // Start is called before the first frame update
 void Start()
 {
     chat = GetComponent <Fungus.Flowchart>();
     chat.SendFungusMessage("Start");
 }
예제 #30
0
        protected virtual void DrawOverlay(Flowchart flowchart)
        {
            GUILayout.Space(8);

            GUILayout.BeginHorizontal();

            GUILayout.Space(8);

            if (GUILayout.Button(new GUIContent(addTexture, "Add a new block")))
            {
                Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x,
                                                      50 - flowchart.scrollPos.y);
                CreateBlock(flowchart, newNodePosition);
            }

            GUILayout.Space(8);

            flowchart.zoom = GUILayout.HorizontalSlider(flowchart.zoom, minZoomValue, maxZoomValue, GUILayout.Width(100));

            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();
            GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel);
            if (flowchart.description.Length > 0)
            {
                GUILayout.Label(flowchart.description, EditorStyles.helpBox);
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(440));

            GUILayout.FlexibleSpace();

            flowchart.variablesScrollPos = GUILayout.BeginScrollView(flowchart.variablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f));

            GUILayout.FlexibleSpace();

            GUILayout.Space(8);

            FlowchartEditor flowchartEditor = Editor.CreateEditor(flowchart) as FlowchartEditor;

            flowchartEditor.DrawVariablesGUI();
            DestroyImmediate(flowchartEditor);

            Rect variableWindowRect = GUILayoutUtility.GetLastRect();

            if (flowchart.variablesExpanded &&
                flowchart.variables.Count > 0)
            {
                variableWindowRect.y      -= 20;
                variableWindowRect.height += 20;
            }
            if (Event.current.type == EventType.Repaint)
            {
                mouseOverVariables = variableWindowRect.Contains(Event.current.mousePosition);
            }

            GUILayout.EndScrollView();

            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();
        }