コード例 #1
0
ファイル: FlowchartWindow.cs プロジェクト: rstruk/ProjetLaby
        public static Block CreateBlock(Flowchart flowchart, Vector2 position)
        {
            Block newBlock = flowchart.CreateBlock(position);
            Undo.RegisterCreatedObjectUndo(newBlock, "New Block");
            ShowBlockInspector(flowchart);
            flowchart.selectedBlock = newBlock;
            flowchart.ClearSelectedCommands();

            return newBlock;
        }
コード例 #2
0
ファイル: BlockInspector.cs プロジェクト: rstruk/ProjetLaby
        public void DrawCommandUI(Flowchart flowchart, Command inspectCommand)
        {
            ResizeScrollView(flowchart);

            GUILayout.Space(7);

            activeBlockEditor.DrawButtonToolbar();

            commandScrollPos = GUILayout.BeginScrollView(commandScrollPos);

            if (inspectCommand != null)
            {
                if (activeCommandEditor == null ||
                    inspectCommand != activeCommandEditor.target)
                {
                    // See if we have a cached version of the command editor already,
                    var editors = (from e in cachedCommandEditors where (e != null && e.target == inspectCommand) select e);

                    if (editors.Count() > 0)
                    {
                        // Use cached editor
                        activeCommandEditor = editors.First();
                    }
                    else
                    {
                        // No cached editor, so create a new one.
                        activeCommandEditor = Editor.CreateEditor(inspectCommand) as CommandEditor;
                        cachedCommandEditors.Add(activeCommandEditor);
                    }
                }
                if (activeCommandEditor != null)
                {
                    activeCommandEditor.DrawCommandInspectorGUI();
                }
            }

            GUILayout.EndScrollView();

            GUILayout.EndArea();

            // Draw the resize bar after everything else has finished drawing
            // This is mainly to avoid incorrect indenting.
            Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f);
            GUI.color = new Color(0.64f, 0.64f, 0.64f);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.height = 1;
            GUI.color = new Color32(132, 132, 132, 255);
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            resizeRect.y += 3;
            GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
            GUI.color = Color.white;

            Repaint();
        }
コード例 #3
0
ファイル: NPCControl.cs プロジェクト: Patchthesock/RoosClues
    void OnEnable()
    {
        // Set Interfaces
        controller.SetNavMeshDirectionable(this);
        controller.SetTransformable(this);
        controller.SetFlowchartable(this);

        // Set Components
        m_transform = this.GetComponent<Transform>();
        m_flowchart = this.GetComponent<Flowchart>();
        m_navMesh = this.GetComponent<NavMeshAgent>();

        // Add to NPC State Control
        NPCStateControl.m_NPCStateControl.AddMe(controller);
    }
コード例 #4
0
ファイル: Checkpoint.cs プロジェクト: Hanteus/Awoken
    // Use this for initialization
    void Start()
    {
        fc = GameObject.FindGameObjectWithTag ( "Flowchart" ).GetComponent<Flowchart> ();

        g = GameObject.FindGameObjectWithTag ( "GameController" ).GetComponent<GameController> ();

        objectName = this.gameObject.name;

        switch ( objectName ) {
            case "CheckpointDoor":
                placeHolderBlockName = "PH CheckPointDoor";
                break;

            case "CheckpointEnigma":
                placeHolderBlockName = "PH CheckPointEnigma";
                break;
        }
    }
コード例 #5
0
        public virtual void DrawBlockName(Flowchart flowchart)
        {
            serializedObject.Update();

            SerializedProperty blockNameProperty = serializedObject.FindProperty("blockName");
            Rect blockLabelRect = new Rect(45, 5, 120, 16);
            EditorGUI.LabelField(blockLabelRect, new GUIContent("Block Name"));
            Rect blockNameRect = new Rect(45, 21, 180, 16);
            EditorGUI.PropertyField(blockNameRect, blockNameProperty, new GUIContent(""));

            // Ensure block name is unique for this Flowchart
            var block = target as Block;
            string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block);
            if (uniqueName != block.BlockName)
            {
                blockNameProperty.stringValue = uniqueName;
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #6
0
ファイル: StopBlock.cs プロジェクト: KRUR/NotJustASheep
        public override void OnEnter()
        {
            if (blockName.Value == "")
            {
                Continue();
            }

            if (flowchart == null)
            {
                flowchart = GetFlowchart();
            }

            Block block = flowchart.FindBlock(blockName.Value);
            if (block == null ||
                !block.IsExecuting())
            {
                Continue();
            }

            block.Stop();

            Continue();
        }
コード例 #7
0
ファイル: BlockEditor.cs プロジェクト: nullsquid/Diviner
        public static void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart)
        {
            if (flowchart == null)
            {
                return;
            }

            Block block = property.objectReferenceValue as Block;

            // Build dictionary of child blocks
            List<GUIContent> blockNames = new List<GUIContent>();

            int selectedIndex = 0;
            blockNames.Add(nullLabel);
            Block[] blocks = flowchart.GetComponentsInChildren<Block>(true);
            for (int i = 0; i < blocks.Length; ++i)
            {
                blockNames.Add(new GUIContent(blocks[i].blockName));

                if (block == blocks[i])
                {
                    selectedIndex = i + 1;
                }
            }

            selectedIndex = EditorGUILayout.Popup(label, selectedIndex, blockNames.ToArray());
            if (selectedIndex == 0)
            {
                block = null; // Option 'None'
            }
            else
            {
                block = blocks[selectedIndex - 1];
            }

            property.objectReferenceValue = block;
        }
コード例 #8
0
ファイル: BlockEditor.cs プロジェクト: nullsquid/Diviner
        public static Block BlockField(Rect position, GUIContent nullLabel, Flowchart flowchart, Block block)
        {
            if (flowchart == null)
            {
                return null;
            }

            Block result = block;

            // Build dictionary of child blocks
            List<GUIContent> blockNames = new List<GUIContent>();

            int selectedIndex = 0;
            blockNames.Add(nullLabel);
            Block[] blocks = flowchart.GetComponentsInChildren<Block>();
            for (int i = 0; i < blocks.Length; ++i)
            {
                blockNames.Add(new GUIContent(blocks[i].name));

                if (block == blocks[i])
                {
                    selectedIndex = i + 1;
                }
            }

            selectedIndex = EditorGUI.Popup(position, selectedIndex, blockNames.ToArray());
            if (selectedIndex == 0)
            {
                result = null; // Option 'None'
            }
            else
            {
                result = blocks[selectedIndex - 1];
            }

            return result;
        }
コード例 #9
0
            internal Block PasteBlock(Flowchart flowchart)
            {
                var newBlock = FlowchartWindow.CreateBlock(flowchart, Vector2.zero);

                // Copy all command serialized properties
                // Copy references to match duplication behavior
                foreach (var command in commands)
                {
                    var newCommand = Undo.AddComponent(flowchart.gameObject, command.type) as Command;
                    CopyProperties(command.serializedObject, newCommand);
                    newCommand.ItemId = flowchart.NextItemId();
                    newBlock.CommandList.Add(newCommand);
                }

                // Copy event handler
                if (eventHandler != null)
                {
                    var newEventHandler = Undo.AddComponent(flowchart.gameObject, eventHandler.type) as EventHandler;
                    CopyProperties(eventHandler.serializedObject, newEventHandler);
                    newEventHandler.ParentBlock = newBlock;
                    newBlock._EventHandler = newEventHandler;     
                }

                // Copy block properties, but do not copy references because those were just assigned
                CopyProperties(
                    block,
                    newBlock,
                    SerializedPropertyType.ObjectReference,
                    SerializedPropertyType.Generic,
                    SerializedPropertyType.ArraySize
                );

                newBlock.BlockName = flowchart.GetUniqueBlockKey(block.FindProperty("blockName").stringValue + " (Copy)");

                return newBlock;
            }
コード例 #10
0
        /// <summary>
        /// Go into the Flowchart and figure out which characters are referenced there.
        /// </summary>
        /// <returns>A list of the GameObjects of characters in the flowchart.</returns>
        /// <param name="flowchart">The Flowchart.</param>

        List<GameObject> GetCharactersInFlowchart(Flowchart flowchart)
        {

            List<GameObject> possiblePersonaObjects = new List<GameObject>();

            if (flowchart == null)
            {
                Debug.LogError("Flowchart == null");
                return possiblePersonaObjects;
            }

            // FIXME: This doesn't work when there is no executing block
            // if we have a currently executing block
            List<Block> blocks = flowchart.GetExecutingBlocks();

            // FIXME: For some reason we now have to add ourselves to the list
            GameObject flowChartRootParent = ExtractRootParentFrom(flowchart);
            if (flowChartRootParent) possiblePersonaObjects.Add(flowChartRootParent);

            // FIXME: Fungus Update bug

            // go through each executing block
            foreach (Block block in blocks)
            {
                // get the command list
//                List<Command> commands = block.commandList;
                List<Command> commands = block.CommandList;
                // go through the command list
                foreach (Command command in commands)
                {
                    // if this is a say command
                    if (command.GetType().ToString() == "Fungus.Say")
                    {
                        // force type to Say
                        Say sayCommand = (Say)command;
                        // get the gameobject attached to this character
                        if (sayCommand == null)
                        {
                            Debug.LogError("sayCommand == null");
                            continue;
                        }
                        // GameObject persona = sayCommand.character.gameObject.transform.parent.gameObject;
//                        GameObject persona = ExtractRootParentFrom(sayCommand.character.gameObject);
                        GameObject persona = ExtractRootParentFrom(sayCommand._Character.gameObject);

                        // if this one isn't already in the list
                        if (!possiblePersonaObjects.Contains(persona))
                        {
                            // add it to the list of possible people we're talking to
                            possiblePersonaObjects.Add(persona);
                        }

                    } // if type
                } // foreach Command
            } // foreach(Block

            // if this list doesn't contain the player
            if (!possiblePersonaObjects.Contains(this.gameObject))
            {
                //          print("Force-add Player");
                possiblePersonaObjects.Add(this.gameObject);
            }

            return possiblePersonaObjects;

        }
コード例 #11
0
		public virtual void SetCharacter(Character character, Flowchart flowchart = null)
		{
			if (character == null)
			{
				if (characterImage != null)
				{
					characterImage.gameObject.SetActive(false);
				}
				if (nameText != null)
				{
					nameText.text = "";
				}
				speakingCharacter = null;
			}
			else
			{
				Character prevSpeakingCharacter = speakingCharacter;
				speakingCharacter = character;
				
				// Dim portraits of non-speaking characters
				foreach (Stage s in Stage.activeStages)
				{
					if (s.dimPortraits)
					{
						foreach (Character c in s.charactersOnStage)
						{
							if (prevSpeakingCharacter != speakingCharacter)
							{
								if (c != speakingCharacter)
								{
									Portrait.SetDimmed(c, s, true);
								}
								else
								{
									Portrait.SetDimmed(c, s, false);
								}
							}
						}
					}
				}
				
				string characterName = character.nameText;
				
				if (characterName == "")
				{
					// Use game object name as default
					characterName = character.name;
				}
				
				if (flowchart != null)
				{
					characterName = flowchart.SubstituteVariables(characterName);
				}
				
				SetCharacterName(characterName, character.nameColor);
			}
		}
コード例 #12
0
ファイル: BlockEditor.cs プロジェクト: nullsquid/Diviner
        protected virtual void DrawEventHandlerGUI(Flowchart flowchart)
        {
            // Show available Event Handlers in a drop down list with type of current
            // event handler selected.
            List<System.Type> eventHandlerTypes = EditorExtensions.FindDerivedTypes(typeof(EventHandler)).ToList();

            Block block = target as Block;
            System.Type currentType = null;
            if (block.eventHandler != null)
            {
                currentType = block.eventHandler.GetType();
            }

            string currentHandlerName = "<None>";
            if (currentType != null)
            {
                EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(currentType);
                if (info != null)
                {
                    currentHandlerName = info.EventHandlerName;
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("Execute On Event"));
            if (GUILayout.Button(new GUIContent(currentHandlerName), EditorStyles.popup))
            {
                SetEventHandlerOperation noneOperation = new SetEventHandlerOperation();
                noneOperation.block = block;
                noneOperation.eventHandlerType = null;

                GenericMenu eventHandlerMenu = new GenericMenu();
                eventHandlerMenu.AddItem(new GUIContent("None"), false, OnSelectEventHandler, noneOperation);

                // Add event handlers with no category first
                foreach (System.Type type in eventHandlerTypes)
                {
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
                    if (info.Category.Length == 0)
                    {
                        SetEventHandlerOperation operation = new SetEventHandlerOperation();
                        operation.block = block;
                        operation.eventHandlerType = type;

                        eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation);
                    }
                }

                // Add event handlers with a category afterwards
                foreach (System.Type type in eventHandlerTypes)
                {
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
                    if (info.Category.Length > 0)
                    {
                        SetEventHandlerOperation operation = new SetEventHandlerOperation();
                        operation.block = block;
                        operation.eventHandlerType = type;
                        string typeName = info.Category + "/" + info.EventHandlerName;
                        eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation);
                    }
                }

                eventHandlerMenu.ShowAsContext();
            }
            EditorGUILayout.EndHorizontal();

            if (block.eventHandler != null)
            {
                EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block.eventHandler) as EventHandlerEditor;
                if (eventHandlerEditor != null)
                {
                    eventHandlerEditor.DrawInspectorGUI();
                    DestroyImmediate(eventHandlerEditor);
                }
            }
        }
コード例 #13
0
        void StoppedDialogue(Flowchart flowchart)
        {

            // get a list of all the characters in this flowchart
            List<GameObject> personae = GetCharactersInFlowchart(flowchart);
            // if there are any listeners
            if (StoppedDialogueWithListener != null)
            {   // tell them all the objects we've stopped discussing with
                StoppedDialogueWithListener(this.gameObject, personae);
            }

        }
コード例 #14
0
ファイル: MissionController.cs プロジェクト: LoYiLun/Regulus
    void OnCollisionEnter(UnityEngine.Collision Mission)
    {
//Level 01 - Rose
        if (L1M1_FirstGetWater)
        {
            if (Mission.gameObject.name == "Well")
            {
                L1M1_FirstFeedRose = true;
                WateringCan.GetComponent <Renderer> ().material = Resources.Load("Universe01", typeof(Material)) as Material;

                Flowchart.BroadcastFungusMessage("GotWater");
            }
        }

        if (L1M1_FirstFeedRose == false)
        {
            if (Mission.gameObject.name == "WateringCan")
            {
                MissionObj = WateringCan;
                AnimationController.GetItem = true;
                L1M1_FirstGetWater          = true;
                W_Collider.enabled          = !W_Collider.enabled;
                WateringCan.GetComponent <Renderer> ().material = Resources.Load("Characters/Asher0528/Materials/M_WateringCan", typeof(Material)) as Material;

                Flowchart.BroadcastFungusMessage("GotWaterCan");
            }
        }

        if (L1M1_FirstFeedRose)
        {
            if (Mission.gameObject.name == "Rose" && MissionObj == WateringCan)
            {
                //WateringCan.SetActive (false);
                L1M2_FindWind      = true;
                L1M1_FirstGetWater = false;
                WateringCan.GetComponent <Renderer> ().material = Resources.Load("Characters/Asher0528/Materials/M_WateringCan", typeof(Material)) as Material;

                Flowchart.BroadcastFungusMessage("RoseGotWater");
            }
        }

        if (L1M2_FindWind)
        {
            if (Mission.gameObject.name == "House" && L1M2_GiveWind != true) //去房子找屏風
            {
                MissionObj = GlassJog;                                       //找到玻璃罐
                ItemTarget = Player;
                ItemHead   = GameObject.Find("Head");
                ItemGoUp   = 0.6f;
                AnimationController.GetItem = true;
                L1M2_GiveWind = true;
                L1M2_FindWind = false;

                Flowchart.BroadcastFungusMessage("FindWind");                //觸發屏風對話
            }
        }

        if (L1M2_GiveWind)
        {
            if (Mission.gameObject.name == "Rose" && MissionObj == GlassJog)
            {
                GlassJog.transform.parent    = null;
                GlassJog.transform.position += new Vector3(0, 0.5f, 0);
                GlassJog.transform.rotation  = Quaternion.Euler(90, 0, 0);
                ItemTarget = Rose;
                ItemHead   = Rose;
                ItemGoUp   = 0.2f;
                AnimationController.GetItem = true;
                L1M3_LastGetWater           = true;
                L1M1_FirstFeedRose          = false;
                L1M2_GiveWind = false;

                Flowchart.BroadcastFungusMessage("GiveWind");                //觸發給屏風對話
            }
        }

        if (L1M3_LastGetWater)
        {
            if (Mission.gameObject.name == "Well")
            {
                MissionObj = WateringCan;
                WateringCan.GetComponent <Renderer> ().material = Resources.Load("Universe01", typeof(Material)) as Material;
                L1M3_LastFeedRose = true;
                L1M3_LastGetWater = false;
            }
        }

        if (L1M3_LastFeedRose)
        {
            if (Mission.gameObject.name == "Rose" && MissionObj == WateringCan)
            {
                WateringCan.transform.parent = null;
                ItemTarget = Rose;
                ItemHead   = Rose;
                ItemGoUp   = 0.2f;
                AnimationController.GetItem = true;
                WateringCan.GetComponent <Renderer> ().material = Resources.Load("Characters/Asher0528/Materials/M_WateringCan", typeof(Material)) as Material;
                L1M3_LastFeedRose = false;

                Flowchart.BroadcastFungusMessage("LastFeedWater");
            }
        }

// Level 02 - King

        if (L2M1_FindKing == false)           // 找國王
        {
            if (Mission.gameObject.name == "King")
            {
                L2M2_FindWater = true;
                L2M1_FindKing  = true;
            }
        }

        if (L2M2_FindWater)           // 幫國王找水
        {
            if (Mission.gameObject.name == "WaterBottle")
            {
                MissionObj                  = WaterBottle;
                WB_Collider.enabled         = !WB_Collider.enabled;
                ItemTarget                  = Player;
                ItemHead                    = GameObject.Find("Head");
                ItemGoUp                    = 0.4f;
                AnimationController.GetItem = true;
                L2M2_GiveWater              = true;
                L2M2_FindWater              = false;
            }
        }

        if (L2M2_GiveWater)           // 給國王喝水
        {
            if (Mission.gameObject.name == "King" && MissionObj == WaterBottle)
            {
                WaterBottle.transform.parent = null;
                ItemTarget = King;
                ItemHead   = King;
                ItemGoUp   = 0.35f;
                AnimationController.GetItem = true;
                L2M3_FindCalender           = true;
                L2M2_GiveWater = false;
            }
        }

        if (L2M3_FindCalender)         // 幫國王找日曆
        {
            if (Mission.gameObject.name == "Calender")
            {
                MissionObj = Calender;
                ItemTarget = Player;
                ItemHead   = GameObject.Find("Head");
                ItemGoUp   = 0.4f;
                AnimationController.GetItem = true;
                L2M3_GiveCalender           = true;
                L2M3_FindCalender           = false;
            }
        }

        if (L2M3_GiveCalender)         // 給國王日曆
        {
            if (Mission.gameObject.name == "King" && MissionObj == Calender)
            {
                ItemTarget = King;
                ItemHead   = King;
                ItemGoUp   = 0.6f;
                AnimationController.GetItem = true;
                L2M3_GiveCalender           = false;
            }
        }

        //Mission Bottom
    }
コード例 #15
0
ファイル: BlockEditor.cs プロジェクト: pewkazilla/cursedom
        protected virtual void DrawEventHandlerGUI(Flowchart flowchart)
        {
            // Show available Event Handlers in a drop down list with type of current
            // event handler selected.
            Block block = target as Block;

            System.Type currentType = null;
            if (block._EventHandler != null)
            {
                currentType = block._EventHandler.GetType();
            }

            string currentHandlerName = "<None>";

            if (currentType != null)
            {
                EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(currentType);
                if (info != null)
                {
                    currentHandlerName = info.EventHandlerName;
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(new GUIContent("Execute On Event"));
            if (GUILayout.Button(new GUIContent(currentHandlerName), EditorStyles.popup))
            {
                SetEventHandlerOperation noneOperation = new SetEventHandlerOperation();
                noneOperation.block            = block;
                noneOperation.eventHandlerType = null;

                GenericMenu eventHandlerMenu = new GenericMenu();
                eventHandlerMenu.AddItem(new GUIContent("None"), false, OnSelectEventHandler, noneOperation);

                // Add event handlers with no category first
                foreach (System.Type type in eventHandlerTypes)
                {
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
                    if (info != null &&
                        info.Category.Length == 0)
                    {
                        SetEventHandlerOperation operation = new SetEventHandlerOperation();
                        operation.block            = block;
                        operation.eventHandlerType = type;

                        eventHandlerMenu.AddItem(new GUIContent(info.EventHandlerName), false, OnSelectEventHandler, operation);
                    }
                }

                // Add event handlers with a category afterwards
                foreach (System.Type type in eventHandlerTypes)
                {
                    EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(type);
                    if (info != null &&
                        info.Category.Length > 0)
                    {
                        SetEventHandlerOperation operation = new SetEventHandlerOperation();
                        operation.block            = block;
                        operation.eventHandlerType = type;
                        string typeName = info.Category + "/" + info.EventHandlerName;
                        eventHandlerMenu.AddItem(new GUIContent(typeName), false, OnSelectEventHandler, operation);
                    }
                }


                eventHandlerMenu.ShowAsContext();
            }
            EditorGUILayout.EndHorizontal();

            if (block._EventHandler != null)
            {
                EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block._EventHandler) as EventHandlerEditor;
                if (eventHandlerEditor != null)
                {
                    eventHandlerEditor.DrawInspectorGUI();
                    DestroyImmediate(eventHandlerEditor);
                }
            }
        }
コード例 #16
0
 public static Flowchart <T, R> AndTheRule <T, R>(this Flowchart <T, R> chart, Func <T, bool> rule)
 {
     chart.LastShape().LastArrow().Rule = rule;
     return(chart);
 }
コード例 #17
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        protected virtual void DrawFlowchartView(Flowchart flowchart)
        {
            Block[] blocks = flowchart.GetComponents<Block>();

            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;
            }

            // The center of the Flowchart depends on the block positions and window dimensions, so we calculate it 
            // here in the FlowchartWindow class and store it on the Flowchart object for use later.
            CalcFlowchartCenter(flowchart, blocks);

            // 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();
        }
コード例 #18
0
        protected static List <KeyValuePair <System.Type, CommandInfoAttribute> > GetFilteredSupportedCommands(Flowchart flowchart)
        {
            List <KeyValuePair <System.Type, CommandInfoAttribute> > filteredAttributes = BlockEditor.GetFilteredCommandInfoAttribute(CommandTypes);

            filteredAttributes.Sort(BlockEditor.CompareCommandAttributes);

            filteredAttributes = filteredAttributes.Where(x => flowchart.IsCommandSupported(x.Value)).ToList();

            return(filteredAttributes);
        }
コード例 #19
0
 public static Flowchart <T, R> YieldingResult <T, R>(this Flowchart <T, R> chart, R result)
 {
     chart.LastShape().Result = result;
     return(chart);
 }
コード例 #20
0
ファイル: sixButton.cs プロジェクト: oomtball/IM-game_project
    // Use this for initialization

    void Awake()
    {
        flowchartManager = GameObject.FindGameObjectWithTag("flowchartController").GetComponent <Flowchart>();
        talkFlowchart    = GameObject.FindGameObjectWithTag("talkFlowchart").GetComponent <Flowchart>();
        player           = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>();
    }
コード例 #21
0
 void Start()
 {
     transform.tag    = "ItemUse";//更改自身tag
     itemUseFlowchart = GetComponent <Flowchart>();
 }
コード例 #22
0
ファイル: Talkable2.cs プロジェクト: peggy87222/zomb
 void OnTriggerEnter()
 {
     Flowchart.BroadcastFungusMessage("對講機");
 }
コード例 #23
0
		private void ResizeScrollView(Flowchart flowchart)
		{
			Rect cursorChangeRect = new Rect(0, flowchart.blockViewHeight + 1, Screen.width, 4f);

			EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical);
			
			if (Event.current.type == EventType.mouseDown && cursorChangeRect.Contains(Event.current.mousePosition))
			{
				resize = true;
			}

			if (resize)
			{
				Undo.RecordObject(flowchart, "Resize view");
				flowchart.blockViewHeight = Event.current.mousePosition.y;
			}
			
			ClampBlockViewHeight(flowchart);
			
			// Stop resizing if mouse is outside inspector window.
			// This isn't standard Unity UI behavior but it is robust and safe.
			if (resize && Event.current.type == EventType.mouseDrag)
			{
				Rect windowRect = new Rect(0, 0, Screen.width, Screen.height);
				if (!windowRect.Contains(Event.current.mousePosition))
				{
					resize = false;
				}
			}

			if (Event.current.type == EventType.MouseUp)
			{
				resize = false;
			}
		}
コード例 #24
0
 public static Flowchart <T, R> AndTheAction <T, R>(this Flowchart <T, R> chart, Action <T> action)
 {
     chart.LastShape().LastArrow().Action = action;
     return(chart);
 }
コード例 #25
0
 // Start is called before the first frame update
 void Start()
 {
     flowchart = GameObject.Find("Flowchart").GetComponent <Flowchart>();
     flowchart.SetStringVariable("Location", Globals.getCurrentLevelString());
 }
コード例 #26
0
 public static Shape <T, R> LastShape <T, R>(this Flowchart <T, R> chart)
 {
     return(chart.Shapes[chart.Shapes.Count - 1]);
 }
コード例 #27
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
 protected virtual void PanAndZoom(Flowchart flowchart)
 {
     // Right click to drag view
     bool drag = false;
     
     // Pan tool
     if (UnityEditor.Tools.current == Tool.View && UnityEditor.Tools.viewTool == ViewTool.Pan &&
         Event.current.button == 0 && Event.current.type == EventType.MouseDrag)
     {
         drag = true;
     }
     
     // Right or middle button drag
     if (Event.current.button > 0 && Event.current.type == EventType.MouseDrag)
     {
         drag = true;
     }
     
     // Alt + left mouse drag
     if (Event.current.alt &&
         Event.current.button == 0 && Event.current.type == EventType.MouseDrag)
     {
         drag = true;
     }
     
     if (drag)
     {
         flowchart.scrollPos += Event.current.delta;
         forceRepaintCount = 6;
     }
     
     bool zoom = false;
     
     // Scroll wheel
     if (Event.current.type == EventType.ScrollWheel)
     {
         zoom = true;
     }
     
     // Zoom tool
     if (UnityEditor.Tools.current == Tool.View && UnityEditor.Tools.viewTool == ViewTool.Zoom &&
         Event.current.button == 0 && Event.current.type == EventType.MouseDrag)
     {
         zoom = true;
     }
     
     if (zoom)
     {
         flowchart.zoom -= Event.current.delta.y * 0.01f;
         flowchart.zoom = Mathf.Clamp(flowchart.zoom, minZoomValue, maxZoomValue);
         forceRepaintCount = 6;
     }
 }
コード例 #28
0
ファイル: ExplorationTrigger.cs プロジェクト: Quintavius/Buto
 // Use this for initialization
 void Start()
 {
     flowchart = FindObjectOfType <Flowchart>();
     player    = GameObject.FindGameObjectWithTag("Player").GetComponent <ExplorationNav>();
 }
コード例 #29
0
ファイル: BlockEditor.cs プロジェクト: nullsquid/Diviner
        public virtual void DrawBlockGUI(Flowchart flowchart)
        {
            serializedObject.Update();

            // Execute any queued cut, copy, paste, etc. operations from the prevous GUI update
            // We need to defer applying these operations until the following update because
            // the ReorderableList control emits GUI errors if you clear the list in the same frame
            // as drawing the control (e.g. select all and then delete)
            if (Event.current.type == EventType.Layout)
            {
                foreach (Action action in actionList)
                {
                    if (action != null)
                    {
                        action();
                    }
                }
                actionList.Clear();
            }

            Block block = target as Block;

            SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");

            if (block == flowchart.selectedBlock)
            {
                SerializedProperty descriptionProp = serializedObject.FindProperty("description");
                EditorGUILayout.PropertyField(descriptionProp);

                DrawEventHandlerGUI(flowchart);

                UpdateIndentLevels(block);

                // Make sure each command has a reference to its parent block
                foreach (Command command in block.commandList)
                {
                    if (command == null) // Will be deleted from the list later on
                    {
                        continue;
                    }
                    command.parentBlock = block;
                }

                ReorderableListGUI.Title("Commands");
                CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
                adaptor.nodeRect = block.nodeRect;

                ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;

                if (block.commandList.Count == 0)
                {
                    EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
                }
                else
                {
                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                }

                // EventType.contextClick doesn't register since we moved the Block Editor to be inside
                // a GUI Area, no idea why. As a workaround we just check for right click instead.
                if (Event.current.type == EventType.mouseUp &&
                    Event.current.button == 1)
                {
                    ShowContextMenu();
                    Event.current.Use();
                }

                if (GUIUtility.keyboardControl == 0) //Only call keyboard shortcuts when not typing in a text field
                {
                    Event e = Event.current;

                    // Copy keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Copy")
                    {
                        if (flowchart.selectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Copy")
                    {
                        actionList.Add(Copy);
                        e.Use();
                    }

                    // Cut keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Cut")
                    {
                        if (flowchart.selectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Cut")
                    {
                        actionList.Add(Cut);
                        e.Use();
                    }

                    // Paste keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Paste")
                    {
                        CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
                        if (commandCopyBuffer.HasCommands())
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Paste")
                    {
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Duplicate keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate")
                    {
                        if (flowchart.selectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Duplicate")
                    {
                        actionList.Add(Copy);
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Delete keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Delete")
                    {
                        if (flowchart.selectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Delete")
                    {
                        actionList.Add(Delete);
                        e.Use();
                    }

                    // SelectAll keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "SelectAll")
                    {
                        e.Use();
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "SelectAll")
                    {
                        actionList.Add(SelectAll);
                        e.Use();
                    }
                }

            }

            // Remove any null entries in the command list.
            // This can happen when a command class is deleted or renamed.
            for (int i = commandListProperty.arraySize - 1; i >= 0; --i)
            {
                SerializedProperty commandProperty = commandListProperty.GetArrayElementAtIndex(i);
                if (commandProperty.objectReferenceValue == null)
                {
                    commandListProperty.DeleteArrayElementAtIndex(i);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #30
0
ファイル: NPC.cs プロジェクト: Xnethers/Topic
 // Use this for initialization
 void Start()
 {
     _flowchart = GameObject.FindObjectOfType <Flowchart>();
     _outline   = GetComponent <Outline>();
     _player    = GameObject.FindGameObjectWithTag("Player").transform;
 }
コード例 #31
0
ファイル: BlockEditor.cs プロジェクト: pewkazilla/cursedom
        protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay)
        {
            yield return(new WaitForSeconds(delay));

            flowchart.ExecuteBlock(targetBlock, commandIndex);
        }
コード例 #32
0
 // Use this for initialization
 void Start()
 {
     flowchartManager = GameObject.FindGameObjectWithTag("flowchartController").GetComponent <Flowchart>();
     talkFlowchart    = GameObject.FindGameObjectWithTag("talkFlowchart").GetComponent <Flowchart>();
 }
コード例 #33
0
 GameObject ExtractRootParentFrom(Flowchart flowchart)
 {
     return ExtractRootParentFrom(flowchart.gameObject);
 }
コード例 #34
0
 // Use this for initialization
 void Start()
 {
     state = GameObject.Find("StateMachine").GetComponent <Animator>();
     flow  = FindObjectOfType <Flowchart>();
 }
コード例 #35
0
        /// <summary>
        /// Starts the flowchart.
        /// </summary>
        /// <param name="other">The other GameObject we're dialoguing with.</param>

        void StartFlowchart(GameObject other)
        {
            // find this flowchart in this character
            Flowchart flowchart = GetFlowchart(other.gameObject);

            // if we found this persona's flowchart
            if (flowchart != null)
            {
                // remember who we're interacting with
                currentInterlocutor = other;
                // remember which flowchart we're interacting with
                currentFlowchart = flowchart;
                //                // start this specific flowchart
                //                flowchart.SendFungusMessage("DialogEnter");
                // check to see if there's an InteractionEnter event waiting for us
                Handler_InteractionEnter interactionEnterEvent = currentFlowchart.GetComponent<Handler_InteractionEnter>();
                // did we find it?
                if (interactionEnterEvent != null)
                {
                    interactionEnterEvent.ExecuteBlock();
                }
                // Started a dialog using this flowchart
                StartedDialogue(flowchart);
            }

        }
コード例 #36
0
ファイル: BlockEditor.cs プロジェクト: pewkazilla/cursedom
        public virtual void DrawBlockGUI(Flowchart flowchart)
        {
            serializedObject.Update();

            // Execute any queued cut, copy, paste, etc. operations from the prevous GUI update
            // We need to defer applying these operations until the following update because
            // the ReorderableList control emits GUI errors if you clear the list in the same frame
            // as drawing the control (e.g. select all and then delete)
            if (Event.current.type == EventType.Layout)
            {
                foreach (Action action in actionList)
                {
                    if (action != null)
                    {
                        action();
                    }
                }
                actionList.Clear();
            }

            var block = target as Block;

            SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");

            if (block == flowchart.SelectedBlock)
            {
                // Custom tinting
                SerializedProperty useCustomTintProp = serializedObject.FindProperty("useCustomTint");
                SerializedProperty tintProp          = serializedObject.FindProperty("tint");

                EditorGUILayout.BeginHorizontal();

                useCustomTintProp.boolValue = GUILayout.Toggle(useCustomTintProp.boolValue, " Custom Tint");
                if (useCustomTintProp.boolValue)
                {
                    EditorGUILayout.PropertyField(tintProp, GUIContent.none);
                }

                EditorGUILayout.EndHorizontal();

                SerializedProperty descriptionProp = serializedObject.FindProperty("description");
                EditorGUILayout.PropertyField(descriptionProp);

                DrawEventHandlerGUI(flowchart);

                block.UpdateIndentLevels();

                // Make sure each command has a reference to its parent block
                foreach (var command in block.CommandList)
                {
                    if (command == null) // Will be deleted from the list later on
                    {
                        continue;
                    }
                    command.ParentBlock = block;
                }

                ReorderableListGUI.Title("Commands");
                CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
                adaptor.nodeRect = block._NodeRect;

                ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;

                if (block.CommandList.Count == 0)
                {
                    EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
                }
                else
                {
                    ReorderableListControl.DrawControlFromState(adaptor, null, flags);
                }

                // EventType.contextClick doesn't register since we moved the Block Editor to be inside
                // a GUI Area, no idea why. As a workaround we just check for right click instead.
                if (Event.current.type == EventType.MouseUp &&
                    Event.current.button == 1)
                {
                    ShowContextMenu();
                    Event.current.Use();
                }

                if (GUIUtility.keyboardControl == 0) //Only call keyboard shortcuts when not typing in a text field
                {
                    Event e = Event.current;

                    // Copy keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Copy")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Copy")
                    {
                        actionList.Add(Copy);
                        e.Use();
                    }

                    // Cut keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Cut")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Cut")
                    {
                        actionList.Add(Cut);
                        e.Use();
                    }

                    // Paste keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Paste")
                    {
                        CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
                        if (commandCopyBuffer.HasCommands())
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Paste")
                    {
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Duplicate keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Duplicate")
                    {
                        actionList.Add(Copy);
                        actionList.Add(Paste);
                        e.Use();
                    }

                    // Delete keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "Delete")
                    {
                        if (flowchart.SelectedCommands.Count > 0)
                        {
                            e.Use();
                        }
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "Delete")
                    {
                        actionList.Add(Delete);
                        e.Use();
                    }

                    // SelectAll keyboard shortcut
                    if (e.type == EventType.ValidateCommand && e.commandName == "SelectAll")
                    {
                        e.Use();
                    }

                    if (e.type == EventType.ExecuteCommand && e.commandName == "SelectAll")
                    {
                        actionList.Add(SelectAll);
                        e.Use();
                    }
                }
            }

            // Remove any null entries in the command list.
            // This can happen when a command class is deleted or renamed.
            for (int i = commandListProperty.arraySize - 1; i >= 0; --i)
            {
                SerializedProperty commandProperty = commandListProperty.GetArrayElementAtIndex(i);
                if (commandProperty.objectReferenceValue == null)
                {
                    commandListProperty.DeleteArrayElementAtIndex(i);
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #37
0
        void OnInteractionExitPlayer(GameObject other)
        {
            // if we're dead, ignore the rest
            if (Dead) return;

            // ignore anyone who is not a Persona
            if (IsPlayer && other.tag != "Persona")
            {
                return;
            }

            // make sure this is the actual person we were interacting with
            if (other != currentInterlocutor)
            {
                return;
            }

            // FIXME: When slowing down to a stop, Personae disrupt the dialog they have just initiated

            StopCurrentFlowchart();

            currentInterlocutor = null;
            currentFlowchart = null;
        }
コード例 #38
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
 protected virtual void SelectBlock(Flowchart flowchart, Block block)
 {
     // Select the block and also select currently executing command
     ShowBlockInspector(flowchart);
     flowchart.selectedBlock = block;
     flowchart.ClearSelectedCommands();
     if (block.activeCommand != null)
     {
         flowchart.AddSelectedCommand(block.activeCommand);
     }
 }
コード例 #39
0
    // Update is called once per frame
    void Update()
    {
        //communications input has its own input to allow it to work while paused
        //though it also needs to be disallowed on death/unconsciousness

        if (!playStatus.unconscious && !playStatus.slain)
        {
            b3New = false;
            for (int i = 0; i < playIn.button3Control.Count; i++)
            {
                if (Input.GetAxis(playIn.button3Control[i]) > 0f)
                {
                    b3New = true;
                }
            }

            b4New = false;
            for (int i = 0; i < playIn.button4Control.Count; i++)
            {
                if (Input.GetAxis(playIn.button4Control[i]) > 0f)
                {
                    b4New = true;
                }
            }
        }

        dialogueInstantiated = flow.GetBooleanVariable("dlgInstantiated");
        inspectInstantiated  = flow.GetBooleanVariable("insInstantiated");
        interactInstantiated = flow.GetBooleanVariable("intInstantiated");
        menuInstantiated     = flow.GetBooleanVariable("menuInstantiated");


        if ((b3New && b3release) || Input.GetMouseButtonDown(0))
        {
            if (playStatus.sheathed && MouseIntersects(dlgBtnContinueRect))
            {
                flow.SetBooleanVariable("dlgContinue", true);
            }
            if (playStatus.sheathed && MouseIntersects(dlgBtnEndRect))
            {
                flow.SetBooleanVariable("dlgEnd", true);
            }
            if (playStatus.sheathed && MouseIntersects(dlgBtnInterruptRect))
            {
                flow.SetBooleanVariable("dlgInterrupt", true);
            }
            if (playStatus.sheathed && MouseIntersects(dlgBtnPauseGameRect))
            {
                if (!PauseMenu.menuPaused)
                {
                    if (PauseMenu.paused)
                    {
                        pauseMenu.MiniResumeGame();
                        flow.SetBooleanVariable("dlgPauseGame", false);
                    }
                    else
                    {
                        pauseMenu.MiniPauseGame();
                        flow.SetBooleanVariable("dlgPauseGame", true);
                    }
                }
            }

            b3release = false;
        }

        if ((b4New && b4release) || Input.GetMouseButtonDown(0))
        {
            if (playStatus.sheathed && MouseIntersects(intBtnContinueRect))
            {
                flow.SetBooleanVariable("intContinue", true);
            }
            if (playStatus.sheathed && MouseIntersects(intBtnEndRect))
            {
                flow.SetBooleanVariable("intEnd", true);
            }
            if (playStatus.sheathed && MouseIntersects(intBtnPauseGameRect))
            {
                if (!PauseMenu.menuPaused)
                {
                    if (PauseMenu.paused)
                    {
                        pauseMenu.Resume();
                        flow.SetBooleanVariable("intPauseGame", false);
                    }
                    else
                    {
                        pauseMenu.Pause();
                        flow.SetBooleanVariable("intPauseGame", true);
                    }
                }
            }

            if (playStatus.sheathed && MouseIntersects(insBtnContinueRect))
            {
                flow.SetBooleanVariable("insContinue", true);
            }
            if (playStatus.sheathed && MouseIntersects(insBtnEndRect))
            {
                flow.SetBooleanVariable("insEnd", true);
            }

            b4release = false;
        }


        if (!b3New)
        {
            b3release = true;
        }
        if (!b4New)
        {
            b4release = true;
        }

        if (!playStatus.sheathed)   //skip through text while unsheathed
        {
            flow.SetBooleanVariable("dlgContinue", true);
            flow.SetBooleanVariable("intContinue", true);
            flow.SetBooleanVariable("insContinue", true);
        }
        else     //highlight buttons on hover

        {
            if (dialogueInstantiated)
            {
                if (MouseIntersects(dlgBtnContinueRect))
                {
                    dlgBtnContinue.color = new Color(1, 1, 1, 0.8f);
                    helperText.text      = playIn.button3Control[0];
                }
                else
                {
                    dlgBtnContinue.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(dlgBtnEndRect))
                {
                    dlgBtnEnd.color = new Color(1, 1, 1, 0.8f);
                    helperText.text = playIn.button3Control[0];
                }
                else
                {
                    dlgBtnEnd.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(dlgBtnInterruptRect))
                {
                    dlgBtnInterrupt.color = new Color(1, 1, 1, 0.8f);
                    helperText.text       = playIn.button3Control[0];
                }
                else
                {
                    dlgBtnInterrupt.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(dlgBtnPauseGameRect))
                {
                    dlgBtnPauseGame.color = new Color(1, 1, 1, 0.8f);
                    helperText.text       = playIn.button3Control[0];
                }
                else
                {
                    dlgBtnPauseGame.color = new Color(1, 1, 1, 0.6f);
                }
            }

            if (interactInstantiated)
            {
                if (MouseIntersects(intBtnContinueRect))
                {
                    intBtnContinue.color = new Color(1, 1, 1, 0.8f);
                    helperText.text      = playIn.button4Control[0];
                }
                else
                {
                    intBtnContinue.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(intBtnEndRect))
                {
                    intBtnEnd.color = new Color(1, 1, 1, 0.8f);
                    helperText.text = playIn.button4Control[0];
                }
                else
                {
                    intBtnEnd.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(intBtnPauseGameRect))
                {
                    intBtnPauseGame.color = new Color(1, 1, 1, 0.8f);
                    helperText.text       = playIn.button4Control[0];
                }
                else
                {
                    intBtnPauseGame.color = new Color(1, 1, 1, 0.6f);
                }
            }

            if (inspectInstantiated)
            {
                if (MouseIntersects(insBtnContinueRect))
                {
                    insBtnContinue.color = new Color(1, 1, 1, 0.8f);
                    helperText.text      = playIn.button4Control[0];
                }
                else
                {
                    insBtnContinue.color = new Color(1, 1, 1, 0.6f);
                }
                if (MouseIntersects(insBtnEndRect))
                {
                    insBtnEnd.color = new Color(1, 1, 1, 0.8f);
                    helperText.text = playIn.button4Control[0];
                }
                else
                {
                    insBtnEnd.color = new Color(1, 1, 1, 0.6f);
                }
            }
        }

        if (!(MouseIntersects(dlgBtnContinueRect) || MouseIntersects(dlgBtnEndRect) || MouseIntersects(dlgBtnInterruptRect) || MouseIntersects(dlgBtnPauseGameRect) ||
              MouseIntersects(intBtnContinueRect) || MouseIntersects(intBtnEndRect) || MouseIntersects(intBtnPauseGameRect) ||
              MouseIntersects(insBtnContinueRect) || MouseIntersects(insBtnEndRect)))
        {
            helperText.text = "";
        }


        if (!dialogueInstantiated)
        {
            flow.SetBooleanVariable("dlgContinue", false);
            flow.SetBooleanVariable("dlgEnd", false);
            flow.SetBooleanVariable("dlgInterrupt", false);
            flow.SetBooleanVariable("dlgPauseGame", false);
        }
        if (!interactInstantiated)
        {
            flow.SetBooleanVariable("intContinue", false);
            flow.SetBooleanVariable("intEnd", false);
            flow.SetBooleanVariable("intPauseGame", false);
        }
        if (!inspectInstantiated)
        {
            flow.SetBooleanVariable("insContinue", false);
            flow.SetBooleanVariable("insEnd", false);
        }

        if (flow.GetBooleanVariable("intEnd") || flow.GetBooleanVariable("dlgEnd") || flow.GetBooleanVariable("insEnd"))
        {
            flow.SetBooleanVariable("dlgInstantiated", false);
            flow.SetBooleanVariable("insInstantiated", false);
            flow.SetBooleanVariable("intInstantiated", false);
            flow.StopAllBlocks();
            Flowchart.BroadcastFungusMessage("nothing");
        }

        if (!PauseMenu.paused)
        {
            flow.SetBooleanVariable("dlgPauseGame", false);
            flow.SetBooleanVariable("intPauseGame", false);
        }

        if ((flow.GetBooleanVariable("dlgContinue") || flow.GetBooleanVariable("insContinue") || flow.GetBooleanVariable("intContinue")) && !flow.GetBooleanVariable("sayFinished") && playStatus.sheathed)
        {
            flow.SetBooleanVariable("dlgContinue", false);
            flow.SetBooleanVariable("intContinue", false);
            flow.SetBooleanVariable("insContinue", false);
            //do something to make the text print instantly
            dlgWriter.instantComplete = true;
            dlgWriter.inputFlag       = true;
            intWriter.instantComplete = true;
            intWriter.inputFlag       = true;
            insWriter.instantComplete = true;
            insWriter.inputFlag       = true;
            resetOnce = true;
        }
        else if (flow.GetBooleanVariable("sayFinished") && resetOnce)
        {
            dlgWriter.instantComplete = false;
            dlgWriter.inputFlag       = false;
            intWriter.instantComplete = false;
            intWriter.inputFlag       = false;
            insWriter.instantComplete = false;
            insWriter.inputFlag       = false;
            resetOnce = false;
        }
    }
コード例 #40
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        protected virtual void DrawConnections(Flowchart flowchart, Block block, bool highlightedOnly)
        {
            if (block == null)
            {
                return;
            }

            List<Block> connectedBlocks = new List<Block>();

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

            foreach (Command command in block.commandList)
            {
                if (command == null)
                {
                    continue;
                }

                bool commandIsSelected = false;
                foreach (Command selectedCommand in flowchart.selectedCommands)
                {
                    if (selectedCommand == command)
                    {
                        commandIsSelected = true;
                        break;
                    }
                }

                bool highlight = command.isExecuting || (blockIsSelected && commandIsSelected);

                if (highlightedOnly && !highlight ||
                    !highlightedOnly && highlight)
                {
                    continue;
                }

                connectedBlocks.Clear();
                command.GetConnectedBlocks(ref connectedBlocks);

                foreach (Block blockB in connectedBlocks)
                {
                    if (blockB == null ||
                        block == blockB ||
                        blockB.GetFlowchart() != flowchart)
                    {
                        continue;
                    }

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

                    Rect endRect = new Rect(blockB.nodeRect);
                    endRect.x += flowchart.scrollPos.x;
                    endRect.y += flowchart.scrollPos.y;

                    DrawRectConnection(startRect, endRect, highlight);
                }
            }
        }
コード例 #41
0
		protected virtual void ClampBlockViewHeight(Flowchart flowchart)
		{
			// Screen.height seems to temporarily reset to 480 for a single frame whenever a command like 
			// Copy, Paste, etc. happens. Only clamp the block view height when one of these operations is not occuring.

			if (Event.current.commandName != "")
			{
				clamp = false;
			}
			
			if (clamp)
			{
				// Make sure block view is always clamped to visible area
				float height = flowchart.blockViewHeight;
				height = Mathf.Max(200, height);
				height = Mathf.Min(Screen.height - 200,height);
				flowchart.blockViewHeight = height;
			}
			
			if (Event.current.type == EventType.Repaint)
			{
				clamp = true;
			}
		}
コード例 #42
0
 // Use this for initialization
 void Start()
 {
     Main = GameObject.Find("對話").GetComponent <Flowchart>();
 }
コード例 #43
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        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();
        }
コード例 #44
0
 protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay)
 {
     yield return new WaitForSeconds(delay);
     flowchart.ExecuteBlock(targetBlock, commandIndex);
 }
コード例 #45
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        public virtual void CalcFlowchartCenter(Flowchart flowchart, Block[] blocks)
        {
            if (flowchart == null ||
                blocks.Count() == 0)
            {
                return;
            }

            Vector2 min = blocks[0].nodeRect.min;
            Vector2 max = blocks[0].nodeRect.max;

            foreach (Block block in blocks)
            {
                min.x = Mathf.Min(min.x, block.nodeRect.center.x);
                min.y = Mathf.Min(min.y, block.nodeRect.center.y);
                max.x = Mathf.Max(max.x, block.nodeRect.center.x);
                max.y = Mathf.Max(max.y, block.nodeRect.center.y);
            }

            Vector2 center = (min + max) * -0.5f;

            center.x += position.width * 0.5f;
            center.y += position.height * 0.5f;

            flowchart.centerPosition = center;
        }
コード例 #46
0
ファイル: BlockEditor.cs プロジェクト: pewkazilla/cursedom
        public static void BlockField(SerializedProperty property, GUIContent label, GUIContent nullLabel, Flowchart flowchart)
        {
            if (flowchart == null)
            {
                return;
            }

            var block = property.objectReferenceValue as Block;

            // Build dictionary of child blocks
            List <GUIContent> blockNames = new List <GUIContent>();

            int selectedIndex = 0;

            blockNames.Add(nullLabel);
            var blocks = flowchart.GetComponents <Block>();

            for (int i = 0; i < blocks.Length; ++i)
            {
                blockNames.Add(new GUIContent(blocks[i].BlockName));

                if (block == blocks[i])
                {
                    selectedIndex = i + 1;
                }
            }

            selectedIndex = EditorGUILayout.Popup(label, selectedIndex, blockNames.ToArray());
            if (selectedIndex == 0)
            {
                block = null; // Option 'None'
            }
            else
            {
                block = blocks[selectedIndex - 1];
            }

            property.objectReferenceValue = block;
        }
コード例 #47
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        protected virtual void DrawGrid(Flowchart flowchart)
        {
            float width = this.position.width / flowchart.zoom;
            float height = this.position.height / flowchart.zoom;

            // Match background color of scene view
            if (EditorGUIUtility.isProSkin)
            {
                GUI.color = new Color32(71, 71, 71, 255); 
            }
            else
            {
                GUI.color = new Color32(86, 86, 86, 255); 
            }
            GUI.DrawTexture( new Rect(0,0, width, height), EditorGUIUtility.whiteTexture );

            GUI.color = Color.white;
            Color color = new Color32(96, 96, 96, 255);

            float gridSize = 128f;
            
            float x = flowchart.scrollPos.x % gridSize;
            while (x < width)
            {
                GLDraw.DrawLine(new Vector2(x, 0), new Vector2(x, height), color, 1f);
                x += gridSize;
            }
            
            float y = (flowchart.scrollPos.y % gridSize);
            while (y < height)
            {
                if (y >= 0)
                {
                    GLDraw.DrawLine(new Vector2(0, y), new Vector2(width, y), color, 1f);
                }
                y += gridSize;
            }
        }
コード例 #48
0
 void Start()
 {
     transform.tag = "NPC";//更改自身tag
     npcFlowchart  = GetComponent <Flowchart>();
 }
コード例 #49
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
 protected virtual void DeleteBlock(Flowchart flowchart, Block block)
 {
     foreach (Command command in block.commandList)
     {
         Undo.DestroyObjectImmediate(command);
     }
     
     Undo.DestroyObjectImmediate(block);
     flowchart.ClearSelectedCommands();
 }
コード例 #50
0
ファイル: Pause.cs プロジェクト: DoucheBagMIKE/DarkZeldaUnity
	// Use this for initialization
	void Start () {
        flowchart = FindObjectOfType<Flowchart>();
        textbox = GameObject.FindGameObjectWithTag("Textbox");
	
	}
コード例 #51
0
ファイル: FlowchartWindow.cs プロジェクト: KRUR/NotJustASheep
        protected static void ShowBlockInspector(Flowchart flowchart)
        {
            if (blockInspector == null)
            {
                // Create a Scriptable Object with a custom editor which we can use to inspect the selected block.
                // Editors for Scriptable Objects display using the full height of the inspector window.
                blockInspector = ScriptableObject.CreateInstance<BlockInspector>() as BlockInspector;
                blockInspector.hideFlags = HideFlags.DontSave;
            }

            Selection.activeObject = blockInspector;

            EditorUtility.SetDirty(blockInspector);
        }
コード例 #52
0
ファイル: Level02PlayerEvent.cs プロジェクト: LoYiLun/Trovato
 // Use this for initialization
 void Start()
 {
     box         = 0;
     RedLeaf     = 0;
     Level02main = GameObject.Find("Level02Main").GetComponent <Flowchart>();
 }