public void StopEvent(bool interupted = false)
        {
            //Debug.Log("Stop Cinematic");
            DialogueEvent trigger = current_event;
            current_event = null;
            current_message = null;
            talk_bubble_inst.SetActive(false);
            DialoguePanel.Get().Hide();
            DialogueZoomPanel.Get().Hide();

            if (trigger != null && trigger.camera_lock_on != null)
            {
                FollowCamera pcam = FollowCamera.Get();
                pcam.UnlockCamera();
            }

            if (trigger != null && trigger.zoomed_in)
            {
                //TheGame.Instance.UnlockGameplay();
            }

            if (!interupted && trigger != null)
            {
                trigger.TriggerEffects();
                if (OnDialogueEnd != null)
                {
                    OnDialogueEnd.Invoke(trigger);
                }
                if (trigger.OnEnd != null)
                {
                    trigger.OnEnd.Invoke();
                }
            }
        }
        public void StartEvent(DialogueEvent dialogue_event)
        {

            if (current_event != dialogue_event)
            {
                StopEvent(true);
                //Debug.Log("Start Cinematic: " + cinematic_trigger.gameObject.name);
                current_event = dialogue_event;
                current_message = null;
                dialogue_index = -1;
                cinematic_timer = 0f;
                dialogue_timer = 0f;
                interact_timer = 0f;

                if (current_event.camera_lock_on != null)
                {
                    FollowCamera pcam = FollowCamera.Get();
                    pcam.LockCameraOn(current_event.camera_lock_on);
                }

                if (OnDialogueStart != null)
                {
                    OnDialogueStart.Invoke(dialogue_event);
                }
                if (dialogue_event.OnStart != null)
                {
                    dialogue_event.OnStart.Invoke();
                }
            }
        }
Beispiel #3
0
        void Start()
        {
            choices_list = DialogueChoice.GetAllOf(this);
            events_list  = DialogueEvent.GetAllOf(this);

            if (portrait_zoomed_prefab)
            {
                GameObject portrait = Instantiate(portrait_zoomed_prefab);
                portrait_instance = portrait.GetComponent <CinematicActorPortrait>();
                portrait.SetActive(false);
            }

            if (NarrativeManager.Get() != null)
            {
                GameObject tbtn = Instantiate(NarrativeManager.Get().talk_button_prefab, transform.position, Quaternion.identity);
                tbtn.GetComponent <ButtonDisplayTalk>().actor = this;
            }
        }
Beispiel #4
0
        public bool IsMet(GameObject triggerer)
        {
            bool condition_met = false;

            if (type == NarrativeConditionType.None)
            {
                condition_met = true;
            }

            if (type == NarrativeConditionType.CustomInt)
            {
                int i1 = NarrativeData.Get().GetCustomInt(target_id);
                int i2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomInt(other_target_id) : value_int;
                condition_met = CompareInt(i1, i2);
            }

            if (type == NarrativeConditionType.CustomFloat)
            {
                float f1 = NarrativeData.Get().GetCustomFloat(target_id);
                float f2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomFloat(other_target_id) : value_float;
                condition_met = CompareFloat(f1, f2);
            }

            if (type == NarrativeConditionType.CustomString)
            {
                string s1 = NarrativeData.Get().GetCustomString(target_id);
                string s2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomString(other_target_id) : value_string;
                condition_met = CompareString(s1, s2);
            }

            if (type == NarrativeConditionType.IsVisible)
            {
                GameObject targ = target.GetTargetObject(triggerer);
                condition_met = (targ != null && targ.activeSelf);
                if (targ != null)
                {
                    condition_met = targ.activeSelf;
                }
                if (oper2 == NarrativeConditionOperator2.IsFalse)
                {
                    condition_met = !condition_met;
                }
            }

            if (type == NarrativeConditionType.HoldItem)
            {
                GameObject targ = target.GetTargetObject(triggerer);
                if (targ && targ.GetComponent <CharacterHoldItem>())
                {
                    CharacterHoldItem character = targ.GetComponent <CharacterHoldItem>();
                    CarryItem         item      = character.GetHeldItem();
                    condition_met = (item != null && (item.item_type == value_string || value_string == ""));
                }
                if (oper2 == NarrativeConditionOperator2.IsFalse)
                {
                    condition_met = !condition_met;
                }
            }

            if (type == NarrativeConditionType.InsideRegion)
            {
                GameObject targ = target.GetTargetObject(triggerer);
                if (targ && value_object)
                {
                    if (value_object.GetComponent <Region>())
                    {
                        condition_met = value_object.GetComponent <Region>().IsInside(targ);
                    }
                }
                if (oper2 == NarrativeConditionOperator2.IsFalse)
                {
                    condition_met = !condition_met;
                }
            }

            if (type == NarrativeConditionType.QuestStarted)
            {
                if (value_object && value_object.GetComponent <NarrativeQuest>())
                {
                    NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>();
                    condition_met = NarrativeData.Get().IsQuestStarted(quest.quest_id);
                    if (oper2 == NarrativeConditionOperator2.IsFalse)
                    {
                        condition_met = !condition_met;
                    }
                }
            }

            if (type == NarrativeConditionType.QuestStartedActive)
            {
                if (value_object && value_object.GetComponent <NarrativeQuest>())
                {
                    NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>();
                    condition_met = NarrativeData.Get().IsQuestActive(quest.quest_id);
                    if (oper2 == NarrativeConditionOperator2.IsFalse)
                    {
                        condition_met = !condition_met;
                    }
                }
            }

            if (type == NarrativeConditionType.QuestCompleted)
            {
                if (value_object && value_object.GetComponent <NarrativeQuest>())
                {
                    NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>();
                    condition_met = NarrativeData.Get().IsQuestCompleted(quest.quest_id);
                    if (oper2 == NarrativeConditionOperator2.IsFalse)
                    {
                        condition_met = !condition_met;
                    }
                }
            }

            if (type == NarrativeConditionType.DialogueTriggered)
            {
                GameObject targ = target.GetTargetObject();
                if (targ && targ.GetComponent <DialogueEvent>())
                {
                    DialogueEvent cinema = targ.GetComponent <DialogueEvent>();
                    condition_met = cinema.GetTriggerCount() >= 1;
                    if (oper2 == NarrativeConditionOperator2.IsFalse)
                    {
                        condition_met = !condition_met;
                    }
                }
            }

            if (type == NarrativeConditionType.CustomFunction)
            {
                if (custom_condition != null)
                {
                    if (custom_condition.GetComponent <CustomContidion>() != null)
                    {
                        condition_met = custom_condition.GetComponent <CustomContidion>().IsMet();
                    }
                    if (oper2 == NarrativeConditionOperator2.IsFalse)
                    {
                        condition_met = !condition_met;
                    }
                }
            }

            return(condition_met);
        }
        void Update()
        {
            if (NarrativeManager.Get().IsPaused())
                return;

            interact_timer += Time.deltaTime;

            if (current_event != null)
            {
                cinematic_timer += Time.deltaTime;
                dialogue_timer += Time.deltaTime;

                //Stop dialogue
                if (current_message != null)
                {
                    bool auto_stop = !current_event.zoomed_in || (current_actor == null);
                    if (auto_stop)
                    {
                        if (dialogue_timer > current_message.duration + current_message.pause)
                        {
                            StopDialogue();
                        }
                        else if (dialogue_timer > current_message.duration)
                        {
                            HideDialogue();
                        }
                    }
                }

                //Skip to next
                if (Input.GetKeyDown(talk_button) && CanInteract())
                {
                    SkipDialogue();
                }

                //Next Dialogue
                if (current_message == null)
                {
                    int index = 0;
                    foreach (DialogueMessage dialogue in current_event.GetDialogues())
                    {
                        if (current_message == null && index > dialogue_index)
                        {
                            dialogue_index = index;
                            if (dialogue.AreConditionsMet())
                                StartDialogue(dialogue);
                        }
                        index++;
                    }

                    //If still null, stop cinematic
                    if (current_message == null)
                        StopEvent();
                }
                
                //Follow dialogue
                UpdateTalkBubble();
            }

            if (current_event == null && cinematic_queue.Count > 0)
            {
                DialogueEvent next = cinematic_queue[0];
                cinematic_queue.RemoveAt(0);
                StartEvent(next);
            }
        }
 public bool IsInCinematicQueue(DialogueEvent dialogue_event)
 {
     return cinematic_queue.Contains(dialogue_event);
 }
 public void AddCinematicToQueue(DialogueEvent dialogue_event)
 {
     if (!IsInCinematicQueue(dialogue_event))
         cinematic_queue.Add(dialogue_event);
 }