private void DrawTargetingStage() { DrawOverrideNameSubsection(npcObject); EditorGUILayout.LabelField("Targeting", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>(); BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>(); bool hasOnTriggerEnter = ((conversationTrigger != null) && (conversationTrigger.trigger == DialogueTriggerEvent.OnTriggerEnter)) || ((barkTrigger != null) && (barkTrigger.trigger == DialogueTriggerEvent.OnTriggerEnter)); bool hasOnUse = ((conversationTrigger != null) && (conversationTrigger.trigger == DialogueTriggerEvent.OnUse)) || ((barkTrigger != null) && (barkTrigger.trigger == DialogueTriggerEvent.OnUse)); bool needsColliders = hasOnTriggerEnter || hasOnUse; bool hasAppropriateColliders = false; if (hasOnTriggerEnter) { hasAppropriateColliders = DrawTargetingOnTriggerEnter(); } if (hasOnUse) { hasAppropriateColliders = DrawTargetingOnUse() || hasAppropriateColliders; } if (!needsColliders) { EditorGUILayout.HelpBox("The NPC doesn't need any targeting components. Click Next to proceed.", MessageType.Info); } if (GUILayout.Button("Select NPC", GUILayout.Width(100))) { Selection.activeGameObject = npcObject; } EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, (hasAppropriateColliders || !needsColliders), false); }
private bool DrawBarkTriggerSection() { EditorGUILayout.BeginHorizontal(); BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>(); bool hasBarkTrigger = EditorGUILayout.Toggle((barkTrigger != null), GUILayout.Width(ToggleWidth)); EditorGUILayout.LabelField("NPC barks when triggered", EditorStyles.boldLabel); EditorGUILayout.EndHorizontal(); if (hasBarkTrigger) { EditorWindowTools.StartIndentedSection(); if (barkTrigger == null) { barkTrigger = npcObject.AddComponent <BarkTrigger>(); } EditorGUILayout.HelpBox("Select the conversation containing the NPC's bark lines, the order in which to display them, and when barks should be triggered.", string.IsNullOrEmpty(barkTrigger.conversation) ? MessageType.Info : MessageType.None); barkTrigger.conversation = DrawConversationPopup(barkTrigger.conversation); barkTrigger.barkOrder = (BarkOrder)EditorGUILayout.EnumPopup("Order of Lines", barkTrigger.barkOrder); barkTrigger.trigger = DrawTriggerPopup(barkTrigger.trigger); EditorWindowTools.EndIndentedSection(); } else { DestroyImmediate(barkTrigger); } return(hasBarkTrigger); }
void Start() { Random.seed = System.DateTime.Now.Millisecond * 10373289; renderer = this.GetComponent<SpriteRenderer> (); if (renderer == null) { this.GetComponentInChildren<SpriteRenderer> (); } player = GameObject.FindObjectOfType<PlayerController> (); barkTrigger = this.GetComponent<BarkTrigger> (); //InvokeRepeating ("Toggle", 3f, 0.5f); isStanding = true; }
private void DrawReviewStage() { EditorGUILayout.LabelField("Review", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); EditorGUILayout.HelpBox("Your NPC is ready! Below is a summary of your NPC's configuration.", MessageType.Info); ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>(); if (conversationTrigger != null) { EditorGUILayout.LabelField(string.Format("Conversation: '{0}'{1} {2}", conversationTrigger.conversation, conversationTrigger.once ? " (once)" : string.Empty, conversationTrigger.trigger)); } else { EditorGUILayout.LabelField("Conversation: None"); } BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>(); if (barkTrigger != null) { EditorGUILayout.LabelField(string.Format("Triggered Bark: '{0}' ({1}) {2}", barkTrigger.conversation, barkTrigger.barkOrder, barkTrigger.trigger)); } else { EditorGUILayout.LabelField("Triggered Bark: None"); } BarkOnIdle barkOnIdle = npcObject.GetComponentInChildren <BarkOnIdle>(); if (barkOnIdle != null) { EditorGUILayout.LabelField(string.Format("Timed Bark: '{0}' ({1}) every {2}-{3} seconds", barkOnIdle.conversation, barkOnIdle.barkOrder, barkOnIdle.minSeconds, barkOnIdle.maxSeconds)); } else { EditorGUILayout.LabelField("Timed Bark: No"); } PersistentPositionData persistentPositionData = npcObject.GetComponentInChildren <PersistentPositionData>(); EditorGUILayout.LabelField(string.Format("Save Position: {0}", (persistentPositionData != null) ? "Yes" : "No")); EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, true, true); }
private void DrawReviewStage() { EditorGUILayout.LabelField("Review", EditorStyles.boldLabel); EditorWindowTools.StartIndentedSection(); EditorGUILayout.HelpBox("Your NPC is ready! Below is a summary of your NPC's configuration.\n\nNPC configuration can sometimes be complex. This wizard can't anticipate every possible character design. If your NPC doesn't behave the way you expect, please examine the components on the NPC and make adjustments as necessary.", MessageType.Info); ConversationTrigger conversationTrigger = npcObject.GetComponentInChildren <ConversationTrigger>(); if (conversationTrigger != null) { EditorGUILayout.LabelField(string.Format("Conversation: '{0}'{1} {2}", conversationTrigger.conversation, conversationTrigger.once ? " (once)" : string.Empty, conversationTrigger.trigger)); } else { EditorGUILayout.LabelField("Conversation: None"); } BarkTrigger barkTrigger = npcObject.GetComponentInChildren <BarkTrigger>(); if (barkTrigger != null) { EditorGUILayout.LabelField(string.Format("Triggered Bark: '{0}' ({1}) {2}", barkTrigger.conversation, barkTrigger.barkOrder, barkTrigger.trigger)); } else { EditorGUILayout.LabelField("Triggered Bark: None"); } BarkOnIdle barkOnIdle = npcObject.GetComponentInChildren <BarkOnIdle>(); if (barkOnIdle != null) { EditorGUILayout.LabelField(string.Format("Timed Bark: '{0}' ({1}) every {2}-{3} seconds", barkOnIdle.conversation, barkOnIdle.barkOrder, barkOnIdle.minSeconds, barkOnIdle.maxSeconds)); } else { EditorGUILayout.LabelField("Timed Bark: No"); } PersistentPositionData persistentPositionData = npcObject.GetComponentInChildren <PersistentPositionData>(); EditorGUILayout.LabelField(string.Format("Save Position: {0}", (persistentPositionData != null) ? "Yes" : "No")); EditorWindowTools.EndIndentedSection(); DrawNavigationButtons(true, true, true); }
void Start() { renderer = this.GetComponent<SpriteRenderer> (); if (renderer == null) { this.GetComponentInChildren<SpriteRenderer> (); } enemy = GameObject.FindObjectOfType<NPCController> (); barkTrigger = this.GetComponent<BarkTrigger> (); isStanding = true; player = GetComponent<Player> (); if (player == null) { player = GetComponentInParent<Player> (); } if (player == null) { player = GetComponentInChildren<Player> (); } if (player != null) { speed = player.walkSpeedScale; animator = player.GetComponent<Animator> (); } else { speed = 2f; } }