Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        Cursor.visible = true;
        PlayerPrefs.SetInt("Tutorial", 0);
        player          = GameObject.Find("Player").GetComponent <Player>();
        dialogue        = GameObject.Find("Devil NPC").GetComponent <NPCDialogue>();
        questClearPanel = GameObject.Find("UI").transform.Find("QuestClearPanel").gameObject;
        questClearPanel.SetActive(false);

        missions = new List <TextMeshProUGUI>();
        for (int i = 0; i < 3; i++)
        {
            TextMeshProUGUI mission = GameObject.Find("UI").transform.Find("MissionPanel").transform.Find("Mission Text" + (i + 1) + " (TMP)").GetComponent <TextMeshProUGUI>();
            if (i == 0)
            {
                mission.text = "- 악마를 클릭하여 대화하기";
            }
            else
            {
                mission.text = "";
            }
            missions.Add(mission);
        }

        checker = null;
        isClear = false;

        StartCoroutine(Tutorial());
    }
Ejemplo n.º 2
0
 void OnGUI()
 {
     GUI.contentColor = Color.red;
     //prompt to interact with item
     if (containerNear)
     {
         if (collectedEvidence)
         {
             NPCDialogue.InteractionText("Evidence Collected!");
         }
         else if (collectedItem)
         {
             NPCDialogue.InteractionText("Picked Up Item");
         }
         else if (!visited)
         {
             NPCDialogue.InteractionText("Press E to interact");
         }
         else
         {
             NPCDialogue.InteractionText("Nothing here");
         }
     }
     else if (doorNear)
     {
         if (!doorLocked)
         {
             NPCDialogue.InteractionText("Press E to open/close");
         }
         else
         {
             NPCDialogue.InteractionText("Locked, needs a key");
         }
     }
 }
Ejemplo n.º 3
0
 //Set the NPC you can talk to and make it available
 public void SetDialogueAvailable(NPCDialogue npc, Transform[] newTargets)
 {
     NPCToTalk           = npc;
     IsDialogueAvailable = true;
     targets             = newTargets;
     //m_Input.ReleaseControl();
 }
Ejemplo n.º 4
0
 public void SetFinalDialogue(NPCDialogue npcDialogue)
 {
     Debug.Log("SetFinalDialogue");
     _actualNPCDialogue = npcDialogue;
     _finalDialog       = true;
     SetDialog();
 }
Ejemplo n.º 5
0
        private void DialogueTabSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var tab = MainWindow.Instance.dialogueTabSelect;

            if (tab.SelectedItem != null && tab.SelectedItem is TabItem tabItem && tabItem.DataContext != null)
            {
                NPCDialogue selectedTabChar = tabItem.DataContext as NPCDialogue;
                if (selectedTabChar != null)
                {
                    Dialogue = selectedTabChar;
                }
            }

            if (tab.SelectedItem is null)
            {
                MainWindow.Instance.dialogueTabGrid.IsEnabled             = false;
                MainWindow.Instance.dialogueTabGrid.Visibility            = Visibility.Collapsed;
                MainWindow.Instance.dialogueTabGridNoSelection.Visibility = Visibility.Visible;
            }
            else
            {
                MainWindow.Instance.dialogueTabGrid.IsEnabled             = true;
                MainWindow.Instance.dialogueTabGrid.Visibility            = Visibility.Visible;
                MainWindow.Instance.dialogueTabGridNoSelection.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 6
0
    ////每次打开界面的时候获取礼物数据
    //private void OnEnable()
    //{
    //    Debug.LogError("运行了Enable");
    //    JoinViewRefreshGift();
    //    //如果在隐藏中就刷新主界面
    //    if (UIComponent.GetComponentHaveExist<UIImpulseComponent>(UIType.UIImpulse) != null)
    //    {
    //        impulesMainView.ShowView(0);
    //    }
    //}

    void GetNPCID()
    {
        foreach (var item in StaticData.configExcel.ImpulseText)
        {
            bool isSave = false;
            for (int i = 0; i < npcId.Count; i++)
            {
                if (npcId[i].NPCID != item.HeroId)
                {
                    continue;
                }

                npcId[i].dialogue.Add(item.ImpulseTextId);
                isSave = true;
                break;
            }
            if (isSave != true)
            {
                NPCDialogue nPCDialogue = new NPCDialogue();
                nPCDialogue.NPCID = item.HeroId;
                nPCDialogue.dialogue.Add(item.ImpulseTextId);
                npcId.Add(nPCDialogue);
            }
        }
    }
Ejemplo n.º 7
0
 // Use this for initialization
 void Start()
 {
     playerT           = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform> ();
     planetGravityBody = GameObject.FindGameObjectWithTag("Player").GetComponent <GravityBody> ();
     dialogue          = gameObject.GetComponent <NPCDialogue>();
     dialogue.checkConditions(3, 1);
     dialogue.hideText();
 }
Ejemplo n.º 8
0
 public void SetupDialogue(string nPCName, NPCDialogue response)
 {
     //Sets the name, butons and dialogues, while creating a cache of the npc
     nameText.text = nPCName;
     ResetButtons();
     dialogueText.text = response.GetDialogue();
     npc = response;
 }
        public DialogueTabViewModel()
        {
            MainWindow.Instance.dialogueTabSelect.SelectionChanged += DialogueTabSelect_SelectionChanged;
            MainWindow.Instance.dialogueTabButtonAdd.Click         += DialogueTabButtonAdd_Click;
            NPCDialogue empty = new NPCDialogue();

            Dialogue = empty;
            UpdateTabs();

            ContextMenu cmenu = new ContextMenu();

            cmenu.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(NPCResponse), (result) =>
            {
                if (result is NPCResponse npcr)
                {
                    AddResponse(new Dialogue_Response(npcr));
                }
            }));

            MainWindow.Instance.dialogueAddReplyButton.ContextMenu = cmenu;

            ContextMenu cmenu2 = new ContextMenu();

            cmenu2.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(NPCMessage), (result) =>
            {
                if (result is NPCMessage npcm)
                {
                    AddMessage(new Dialogue_Message(npcm));
                }
            }));

            MainWindow.Instance.dialogueAddMessageButton.ContextMenu = cmenu2;

            ContextMenu cmenu3 = new ContextMenu();

            cmenu3.Items.Add(ContextHelper.CreateAddFromTemplateButton(typeof(NPCDialogue), (result) =>
            {
                if (result is NPCDialogue npcd)
                {
                    MainWindow.CurrentProject.data.dialogues.Add(npcd);
                    MetroTabItem tabItem = CreateTab(npcd);
                    MainWindow.Instance.dialogueTabSelect.Items.Add(tabItem);
                    MainWindow.Instance.dialogueTabSelect.SelectedIndex = MainWindow.Instance.dialogueTabSelect.Items.Count - 1;
                }
            }));

            MainWindow.Instance.dialogueTabButtonAdd.ContextMenu = cmenu3;

            var dialogueInputIdControlContext = new ContextMenu();

            dialogueInputIdControlContext.Items.Add(ContextHelper.CreateFindUnusedIDButton((id) =>
            {
                this.ID = id;
                MainWindow.Instance.dialogueInputIdControl.Value = id;
            }, GameIntegration.EGameAssetCategory.NPC));

            MainWindow.Instance.dialogueInputIdControl.ContextMenu = dialogueInputIdControlContext;
        }
Ejemplo n.º 10
0
    //connect our player to the player variable via tag
    //connect our Camera to the mainCam variable via tag
    #endregion
    #region Update
    private void Update()
    {
        //if our interact key is pressed
        if (Input.GetKeyDown(KeyCode.E))
        {
            //create a ray
            Ray interact;
            //this ray is shooting out from the main cameras screen point center of screen
            interact = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2));
            //create hit info
            RaycastHit hitInfo;
            //if this physics raycast hits something within 10 units
            if (Physics.Raycast(interact, out hitInfo, 10))
            {
                #region NPC tag
                //and that hits info is tagged NPC
                if (hitInfo.collider.CompareTag("NPC"))
                {
                    //  HCDialogue dlg = hitInfo.transform.GetComponent<HCDialogue>();
                    NPCDialogue dlg = hitInfo.transform.GetComponent <NPCDialogue>();
                    if (dlg != null)
                    {
                        dlg.OpenDLGWindow();
                        Movement.canMove = false;
                        Cursor.lockState = CursorLockMode.None;
                        Cursor.visible   = true;
                    }
                    //Debug that we hit a NPC
                    Debug.Log("NPC");
                }
                #endregion
                #region Item
                //and that hits info is tagged Item
                if (hitInfo.collider.CompareTag("Item"))
                {
                    //Debug that we hit an Item
                    Debug.Log("Item");
                    ItemHandler handler = hitInfo.transform.GetComponent <ItemHandler>();
                    if (handler != null)
                    {
                        handler.OnCollection();
                    }
                }

                #endregion
                #region Gate tag
                //and that hits info is tagged NPC
                if (hitInfo.collider.CompareTag("Gate"))
                {
                    //Debug that we hit a NPC
                    Debug.Log("Gate");
                }
                #endregion
            }
        }
    }
        private void DialogueTabButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            NPCDialogue item = new NPCDialogue();

            MainWindow.CurrentProject.data.dialogues.Add(item);
            MetroTabItem tabItem = CreateTab(item);

            MainWindow.Instance.dialogueTabSelect.Items.Add(tabItem);
            MainWindow.Instance.dialogueTabSelect.SelectedIndex = MainWindow.Instance.dialogueTabSelect.Items.Count - 1;
        }
Ejemplo n.º 12
0
    void Start()
    {
        button = buttonObject.GetComponent <Button>();
        NPC    = this.GetComponent <NPCDialogue>();
        buttonObject.SetActive(false);

        mainCamera       = GameObject.Find("Main Camera").GetComponent <CameraControl>();
        originalDialogue = NPC.dialogue;
        dialogueLength   = originalDialogue.Count;
    }
Ejemplo n.º 13
0
        public NPCDialogue ParseDialogue()
        {
            NPCDialogue d = new NPCDialogue()
            {
                guid = asset.Has("GUID") ? asset.ReadString("GUID") : Guid.NewGuid().ToString("N"),
                id   = asset.ReadUInt16("ID")
            };

            d.messages = new List <NPCMessage>(asset.ReadByte("Messages"));
            for (byte mId = 0; mId < d.messages.Capacity; mId++)
            {
                d.messages.Add(new NPCMessage());
                d.messages[mId].pages = new List <string>(asset.ReadByte($"Message_{mId}_Pages"));
                for (byte pId = 0; pId < d.messages[mId].pages.Capacity; pId++)
                {
                    string page = local?.ReadString($"Message_{mId}_Page_{pId}");
                    if (page == null)
                    {
                        App.Logger.Log($"Page {pId} in message {mId} not found.");
                    }

                    d.messages[mId].pages.Add(page);
                }
                d.messages[mId].conditions = ParseConditions($"Message_{mId}_");
                d.messages[mId].rewards    = ParseRewards($"Message_{mId}_");
                d.messages[mId].prev       = asset.ReadUInt16($"Message_{mId}_Prev");
            }
            d.responses = new List <NPCResponse>(asset.ReadByte("Responses"));
            for (byte rId = 0; rId < d.responses.Capacity; rId++)
            {
                d.responses.Add(new NPCResponse());
                byte b = asset.ReadByte($"Response_{rId}_Messages");
                d.responses[rId].visibleIn = new int[b];
                for (byte i = 0; i < b; i++)
                {
                    d.responses[rId].visibleIn[i] = asset.Has($"Response_{rId}_Message_{i}") ? 1 : 0;
                }
                d.responses[rId].mainText = local?.ReadString($"Response_{rId}");
                if (d.responses[rId].mainText == null)
                {
                    break;
                }

                d.responses[rId].openDialogueId = asset.ReadUInt16($"Response_{rId}_Dialogue");
                d.responses[rId].openQuestId    = asset.ReadUInt16($"Response_{rId}_Quest");
                d.responses[rId].openVendorId   = asset.ReadUInt16($"Response_{rId}_Vendor");
                d.responses[rId].conditions     = ParseConditions($"Response_{rId}_");
                d.responses[rId].rewards        = ParseRewards($"Response_{rId}_");
            }
            return(d);
        }
Ejemplo n.º 14
0
    public void SetDialogues(NPCDialogue npcDialogue)
    {
        dialogueIndex = 0;
        dialogue.text = null;

        spriteIndex = new string[npcDialogue.Dialogues.Count];
        dialogues   = new string[npcDialogue.Dialogues.Count];
        sprites     = new Sprite[npcDialogue.Dialogues.Count];

        for (int i = 0; i < npcDialogue.Dialogues.Count; i++)
        {
            spriteIndex[i] = npcDialogue.Dialogues[i].dialogueImagePosition;
            dialogues[i]   = npcDialogue.Dialogues[i].dialogueText;
            sprites[i]     = npcDialogue.Dialogues[i].dialogueImage;
        }
        ChangeSprite();
        ChangeDialogueBoxAnimation("Show");
    }
Ejemplo n.º 15
0
 public void CloseNotePad()
 {
     foreach (NotepadTopic topic in topics)
     {
         topic.contractorTopic = null;
         topic.govTopic        = null;
         topic.clickEnable     = false;
     }
     _open            = false;
     govSelected      = null;
     contSelected     = null;
     selectedDialogue = null;
     selectedNpc      = null;
     activeDialogue   = null;
     ControllerInput.RemoveScreen(transform);
     StartCoroutine(DisplayCoroutine());
     Events.Instance.RemoveListener <OnActiveSelectTopic>(SelectTopic);
 }
Ejemplo n.º 16
0
    private void ClickObject(Vector2 screenPosition)
    {
        RaycastHit hit;
        Vector3    screenPos = new Vector3(screenPosition.x, screenPosition.y, 0);
        Ray        ray       = mainCamera.ScreenPointToRay(screenPos);

        if (Physics.Raycast(ray, out hit))
        {
            hitObject = hit.collider.gameObject;
            hitObject.GetComponent <Renderer>().material.color = Color.red; // 物件被點選轉成紅色
            NPC           = hitObject.GetComponent <NPCDialogue>();         // 所有物件都有對話
            NPC.isDialog  = true;                                           // NPC開啟對話
            isDialogState = true;                                           // 表示mainCamera目前在對話 進入對話模式
        }
        else
        {
            hitObject.GetComponent <Renderer>().material.color = Color.black; //當沒有點選此物時則轉回黑色
        }
    }
Ejemplo n.º 17
0
        protected void SelectTopic(OnActiveSelectTopic e)
        {
            Events.Instance.RemoveListener <OnActiveSelectTopic>(SelectTopic);
            PointingBubble.instance.LinkTopic(topics[e.notepadIndex]);
            if (e.topicItem.contractorTopic != null)
            {
                contSelected = e.topicItem.contractorTopic;
                if (activeDialogue != null)
                {
                    activeDialogue = activeDialogue.nextTexts[e.notepadIndex];
                }
                else
                {
                    activeDialogue = contSelected.text;
                }
            }
            else if (e.topicItem.govTopic != null)
            {
                govSelected = e.topicItem.govTopic;
                if (activeDialogue != null)
                {
                    activeDialogue = activeDialogue.nextTexts[e.notepadIndex];
                }
                else
                {
                    activeDialogue = govSelected.texts;
                }
            }

            if (activeDialogue.nextTexts.Count <= 0)
            {
                PointingBubble.instance.NextDialogueStep(true);
                ShowNextAnswer(true);
                CloseNotePad();
            }
            else
            {
                ShowNextAnswer(false);
                PointingBubble.instance.NextDialogueStep(false);
                SetNextDialogue();
            }
        }
Ejemplo n.º 18
0
        public void PlayDialogue(NPCDialogue dialogue)
        {
            if (dialogue.dialogue.Count == 0)
            {
                return;
            }

            // Stop movement
            PlayerController.Instance.inputVector = Vector2.zero;

            // Prepare
            inDialogue       = true;
            _currentDialogue = dialogue;
            speakerName.text = dialogue.displayName;
            dialogCanvas.gameObject.SetActive(true);

            // Run first message
            _currentMsg = 0;
            RunMessage(dialogue.dialogue[_currentMsg]);
        }
Ejemplo n.º 19
0
        public DialogueView_Window(NPCCharacter character, NPCDialogue dialogue, Simulation simulation, NPCDialogue prev = null)
        {
            InitializeComponent();

            Character  = character;
            Dialogue   = dialogue;
            Simulation = simulation;
            Previous   = prev;
            Start      = dialogue;

            Loaded += (sender, e) =>
            {
                SimulationView_Window svw = new SimulationView_Window(this, Simulation);
                svw.Owner = this;
                svw.Show();
                Closing += (sender2, e2) =>
                {
                    svw.Close();
                };
            };
        }
Ejemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        agent       = transform.GetChild(0).GetComponent <NavMeshAgent>();
        npcDialogue = GetComponent <NPCDialogue>();

        capCollider   = GetComponent <CapsuleCollider>();
        agentCollider = transform.GetChild(0).GetComponent <CapsuleCollider>();

        capCollider.radius = agentCollider.radius * 1.5f;
        capCollider.height = agentCollider.height;

        wayPointsGO = transform.GetChild(1).gameObject;
        wayPoints   = new Vector3[wayPointsGO.transform.childCount];

        for (int i = 0; i < wayPoints.Length; i++)
        {
            wayPoints[i] = wayPointsGO.transform.GetChild(i).position;
        }

        timeUntilChangeWayPoint = Random.Range(minTimeAtWayPoint, maxTimeAtWayPoint);
    }
 public void Buttons()
 {
     if (!(index >= currentDialogue.Length - 1 || index == optionIndex))
     {
         button.SetActive(true);
         acceptButton.SetActive(false);
         refuseButton.SetActive(false);
         index++;
         if (index >= currentDialogue.Length - 1)
         {
             acceptButton.SetActive(false);
             refuseButton.SetActive(false);
             buttonText.text = "Bye";
         }
     }
     else if (index == optionIndex)
     {
         index++;
         button.SetActive(false);
         acceptButton.SetActive(true);
         refuseButton.SetActive(true);
     }
     else
     {
         index = 0;
         Camera.main.GetComponent <MouseLook>().enabled = true;
         playerMouseLook.enabled = true;
         Cursor.lockState        = CursorLockMode.Locked;
         Cursor.visible          = false;
         dialoguePanel.SetActive(false);
         acceptButton.SetActive(false);
         refuseButton.SetActive(false);
         currentNPC = null;
     }
     if (currentNPC != null)
     {
         DlgApproval();
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// 레이케스트 시작
 /// </summary>
 public void RayStart()
 {
     //? 말풍선
     if (dialoguetype == NPCDialogue.SpeechBubble)
     {
         if (!is_msg)
         {
             StartCoroutine(SpeechBubblePlay(ReturnRandomString()));
         }
     }
     else if (dialoguetype == NPCDialogue.Dialogue)
     {
         if (dialogue.Length <= 0)
         {
             dialoguetype = NPCDialogue.SpeechBubble; count = 0; maxcount = 999;
         }
         if (!is_msg && dialogue.Length >= 1 && _StoryNumber < dialogue.Length)
         {
             StartCoroutine(DailoguePlay(dialogue[_StoryNumber]));
         }
     }
 }
Ejemplo n.º 23
0
    //打开界面 调用一次
    public void OpenView(List <Favorable> favorableList)
    {
        for (int i = 0; i < favorableList.Count; i++)
        {
            int        index   = i;
            GameObject NpcItem = GameObject.Instantiate(NpcHeadItem);
            var        npcitem = NpcItem.GetComponent <NPCItem>();
            //setParent
            ChapterHelper.SetParent(npcitem.gameObject, scrollRect.content);

            favorableList = ImpulseHelper.ImpulseSort(favorableList);

            //set
            bool isUnlock = false;
            var  roleInfo = StaticData.configExcel.GetHallRoleByID(favorableList[i].NPCId);
            if (StaticData.playerInfoData.userInfo.SectionId >= roleInfo.UnlockChapter)
            {
                isUnlock = true;
            }
            //根据男主id 随机一句话
            NPCDialogue nPCDialogue = UIImpulseComponent.npcId.Find((f) =>
            {
                return(f.NPCID == favorableList[i].NPCId);
            });
            int ind = Random.Range(0, nPCDialogue.dialogue.Count);
            //for (int j = 0; j < UIImpulseComponent.npcId.Count; j++)
            //{
            //    if (UIImpulseComponent.npcId[j].NPCID == favorableList[i].NPCId)
            //    {
            //        Random.Range(0,)
            //    }
            //}
            npcitem.Set(favorableList[i].NPCId, favorableList[i].headPortrait, favorableList[i].NPC2PlayerValue, favorableList[i].Player2NPCValue, favorableList[i].cardiacValue, ImpulseHelper.GetNPCDialogue(nPCDialogue.dialogue[ind]), isUnlock);
            npcitem.dateBtn.onClick.AddListener(() => OnClick(favorableList[index]));
            NpcItemList.Add(npcitem);
        }
    }
Ejemplo n.º 24
0
 //刷新
 void Reshf(List <Favorable> favorableList)
 {
     //排序
     favorableList = ImpulseHelper.ImpulseSort(favorableList);
     for (int i = 0; i < favorableList.Count; i++)
     {//直接全部重新刷新
         int  index    = i;
         bool isUnlock = false;
         var  roleInfo = StaticData.configExcel.GetHallRoleByID(favorableList[i].NPCId);
         if (StaticData.playerInfoData.userInfo.SectionId >= roleInfo.UnlockChapter)
         {
             isUnlock = true;
         }
         //根据男主id 随机一句话
         //根据男主id 随机一句话
         NPCDialogue nPCDialogue = UIImpulseComponent.npcId.Find((f) =>
         {
             return(f.NPCID == favorableList[i].NPCId);
         });
         int ind = Random.Range(0, nPCDialogue.dialogue.Count);
         NpcItemList[i].Set(favorableList[i].NPCId, favorableList[i].headPortrait, favorableList[i].NPC2PlayerValue, favorableList[i].Player2NPCValue, favorableList[i].cardiacValue, ImpulseHelper.GetNPCDialogue(nPCDialogue.dialogue[ind]), isUnlock);
         NpcItemList[i].dateBtn.onClick.AddListener(() => OnClick(favorableList[index]));
     }
 }
 public DialogueTabViewModel()
 {
     Dialogue = new NPCDialogue();
 }
Ejemplo n.º 26
0
    private void LinkButtonToResponse(Button dialogueButton, PlayerDialogue playerDialogue, NPCDialogue NPCDialogue)
    {
        NPCQuestInteraction npcQuestInteraction = null;

        if (npcInteraction.GetType() == typeof(NPCQuestInteraction))
        {
            npcQuestInteraction = (NPCQuestInteraction)npcInteraction;
        }

        switch (playerDialogue.dialogueType)
        {
        case PlayerDialogueType.NextDialogue:
            dialogueButton.onClick.AddListener(delegate { npcInteraction.PlayDialogue(NPCDialogue.nextDialogue); });
            break;

        case PlayerDialogueType.GetInfo:
            dialogueButton.onClick.AddListener(delegate { npcInteraction.PlayDialogue(playerDialogue.nextDialogue); });
            break;

        case PlayerDialogueType.Accept:
            if (!npcQuestInteraction)
            {
                Debug.Log("NPCQuestInteraction not found, there shouldn't be an Accept option");
            }
            else
            {
                dialogueButton.onClick.AddListener(delegate {
                    npcQuestInteraction.PlayDialogue(playerDialogue.nextDialogue);
                    npcQuestInteraction.QuestAccepted();
                });
            }
            break;

        case PlayerDialogueType.Refuse:
            if (!npcQuestInteraction)
            {
                Debug.Log("NPCQuestInteraction not found, there shouldn't be a Refuse option");
            }
            else
            {
                dialogueButton.onClick.AddListener(delegate {
                    npcQuestInteraction.PlayDialogue(playerDialogue.nextDialogue);
                    npcQuestInteraction.QuestRefused();
                });
            }
            break;

        case PlayerDialogueType.CompleteQuest:
            if (!npcQuestInteraction)
            {
                Debug.Log("NPCQuestInteraction not found, there shouldn't be a CompleteQuest option");
            }
            else
            {
                dialogueButton.onClick.AddListener(delegate {
                    npcQuestInteraction.PlayDialogue(playerDialogue.nextDialogue);
                    npcQuestInteraction.QuestCompleted();
                });
            }
            break;

        case PlayerDialogueType.CloseDialogue:
            dialogueButton.onClick.AddListener(delegate { npcInteraction.CloseDialogue(); });
            break;

        default:
            dialogueButton.onClick.AddListener(delegate { npcInteraction.CloseDialogue(); });
            break;
        }
    }
Ejemplo n.º 27
0
 // Start is called before the first frame update
 void Start()
 {
     dialogue       = transform.parent.GetComponent <NPCDialogue>();
     followUpLength = GetComponent <DialogueButton>().followUpLength;
     this.enabled   = false;
 }
        private MetroTabItem CreateTab(NPCDialogue dialogue)
        {
            MetroTabItem tabItem = new MetroTabItem();

            tabItem.CloseButtonEnabled       = true;
            tabItem.CloseTabCommand          = CloseTabCommand;
            tabItem.CloseTabCommandParameter = tabItem;
            var binding = new Binding()
            {
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                Mode = BindingMode.OneWay,
                Path = new PropertyPath("UIText")
            };
            Label l = new Label();

            l.SetBinding(Label.ContentProperty, binding);
            tabItem.Header      = l;
            tabItem.DataContext = dialogue;

            var             cmenu      = new ContextMenu();
            List <MenuItem> cmenuItems = new List <MenuItem>()
            {
                ContextHelper.CreateCopyButton((object sender, RoutedEventArgs e) =>
                {
                    Save();

                    ContextMenu context = (sender as MenuItem).Parent as ContextMenu;
                    MetroTabItem target = context.PlacementTarget as MetroTabItem;
                    ClipboardManager.SetObject(Universal_ItemList.ReturnType.Dialogue, target.DataContext);
                }),
                ContextHelper.CreateDuplicateButton((object sender, RoutedEventArgs e) =>
                {
                    Save();

                    ContextMenu context = (sender as MenuItem).Parent as ContextMenu;
                    MetroTabItem target = context.PlacementTarget as MetroTabItem;
                    var cloned          = (target.DataContext as NPCDialogue).Clone();

                    MainWindow.CurrentProject.data.dialogues.Add(cloned);
                    MetroTabItem ti = CreateTab(cloned);
                    MainWindow.Instance.dialogueTabSelect.Items.Add(ti);
                }),
                ContextHelper.CreatePasteButton((object sender, RoutedEventArgs e) =>
                {
                    if (ClipboardManager.TryGetObject(ClipboardManager.DialogueFormat, out var obj) && !(obj is null) && obj is NPCDialogue cloned)
                    {
                        MainWindow.CurrentProject.data.dialogues.Add(cloned);
                        MetroTabItem ti = CreateTab(cloned);
                        MainWindow.Instance.dialogueTabSelect.Items.Add(ti);
                    }
                })
            };

            foreach (var cmenuItem in cmenuItems)
            {
                cmenu.Items.Add(cmenuItem);
            }

            tabItem.ContextMenu = cmenu;
            return(tabItem);
        }
Ejemplo n.º 29
0
 private void Awake()
 {
     npcDialogue = GetComponent <NPCDialogue>();
 }
Ejemplo n.º 30
0
        public NPCDialogue ParseDialogue()
        {
            NPCDialogue d = new NPCDialogue()
            {
                GUID = asset.Has("GUID") ? asset.ReadString("GUID") : Guid.NewGuid().ToString("N"),
                ID   = asset.ReadUInt16("ID")
            };

            d.Messages = new List <NPCMessage>(asset.ReadByte("Messages"));
            Dictionary <ushort, byte[]> m_visible = new Dictionary <ushort, byte[]>();

            for (byte mId = 0; mId < d.Messages.Capacity; mId++)
            {
                string[] pages = new string[asset.ReadByte($"Message_{mId}_Pages")];
                for (byte pId = 0; pId < pages.Length; pId++)
                {
                    string page = local?.ReadString($"Message_{mId}_Page_{pId}");
                    if (page == null)
                    {
                        App.Logger.Log($"Page {pId} in message {mId} not found.");
                    }
                    pages[pId] = page ?? string.Empty;
                }
                byte[] array2 = new byte[asset.ReadByte($"Message_{mId}_Responses")];
                for (byte rId = 0; rId < array2.Length; rId++)
                {
                    array2[rId] = asset.ReadByte($"Message_{mId}_Response_{rId}");
                }
                m_visible.Add(mId, array2);

                d.Messages.Add(new NPCMessage()
                {
                    conditions = ParseConditions($"Message_{mId}_").ToList(),
                    pages      = pages.ToList(),
                    prev       = asset.ReadUInt16($"Message_{mId}_Prev"),
                    rewards    = ParseRewards($"Message_{mId}_").ToList()
                });
            }
            d.Responses = new List <NPCResponse>(asset.ReadByte("Responses"));
            for (byte rId = 0; rId < d.Responses.Capacity; rId++)
            {
                d.Responses.Add(new NPCResponse());
                byte b = asset.ReadByte($"Response_{rId}_Messages");
                d.Responses[rId].visibleIn = new int[d.Messages.Count];
                for (byte i = 0; i < d.Responses[rId].visibleIn.Length; i++)
                {
                    if (m_visible.TryGetValue(i, out var pages))
                    {
                        if (pages.Contains(rId))
                        {
                            d.Responses[rId].visibleIn[i] = 1;
                            continue;
                        }
                    }

                    for (byte i2 = 0; i2 < b; i2++)
                    {
                        byte?m;
                        if (asset.Has($"Response_{rId}_Message_{i2}"))
                        {
                            m = asset.ReadByte($"Response_{rId}_Message_{i2}");
                        }
                        else
                        {
                            m = null;
                        }
                        if (m != null)
                        {
                            d.Responses[rId].visibleIn[m.Value] = 1;
                        }
                    }
                }
                d.Responses[rId].mainText = local?.ReadString($"Response_{rId}");
                if (d.Responses[rId].mainText == null)
                {
                    break;
                }

                d.Responses[rId].openDialogueId = asset.ReadUInt16($"Response_{rId}_Dialogue");
                d.Responses[rId].openQuestId    = asset.ReadUInt16($"Response_{rId}_Quest");
                d.Responses[rId].openVendorId   = asset.ReadUInt16($"Response_{rId}_Vendor");
                d.Responses[rId].conditions     = ParseConditions($"Response_{rId}_").ToList();
                d.Responses[rId].rewards        = ParseRewards($"Response_{rId}_").ToList();
            }
            return(d);
        }