1
This commit is contained in:
48
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs
Normal file
48
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Michsky.MUIP;
|
||||
using Sirenix.Utilities;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
public class ChoiceFrame : MonoBehaviour
|
||||
{
|
||||
public GameObject choiceButtonPrefab;
|
||||
public RectTransform choiceButtonContainer;
|
||||
public List<Button> choiceButtonList;
|
||||
public TooltipContent hint;
|
||||
|
||||
public void PlayChoice(List<Choice> choices)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
choiceButtonContainer.GetAllChildren().ForEach(x => Destroy(x.gameObject));
|
||||
choiceButtonList.Clear();
|
||||
|
||||
/*if (choiceModule.hint != "")
|
||||
{
|
||||
hint.gameObject.SetActive(true);
|
||||
hint.description = choiceModule.hint;
|
||||
}
|
||||
else
|
||||
{
|
||||
hint.gameObject.SetActive(false);
|
||||
}*/
|
||||
|
||||
foreach (var choice in choices)
|
||||
{
|
||||
GameObject choiceButton = Instantiate(choiceButtonPrefab, choiceButtonContainer);
|
||||
choiceButton.GetComponentInChildren<TMP_Text>().text = choice.choiceText;
|
||||
choiceButton.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
DialogManager.instance.PlayNextDialogParagraph(choice.nextDialogName);
|
||||
DialogManager.instance.isPlayingChoice = false;
|
||||
gameObject.SetActive(false);
|
||||
});
|
||||
choiceButtonList.Add(choiceButton.GetComponent<Button>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs.meta
Normal file
11
Assets/Scripts/UI/DialogUI/ChoiceFrame.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62ce59e989ba99d4ca0407641e0ae2f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/UI/DialogUI/DialogUIPage.cs
Normal file
16
Assets/Scripts/UI/DialogUI/DialogUIPage.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class DialogUIPage : UIPageBase
|
||||
{
|
||||
public TextFrame textFrame;
|
||||
public ChoiceFrame choiceFrame;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/DialogUI/DialogUIPage.cs.meta
Normal file
11
Assets/Scripts/UI/DialogUI/DialogUIPage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17254192719abee4f9222246fd403de5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/UI/DialogUI/TextFrame.cs
Normal file
38
Assets/Scripts/UI/DialogUI/TextFrame.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
public class TextFrame : MonoBehaviour
|
||||
{
|
||||
public GameObject textPrefab;
|
||||
public RectTransform textContainer;
|
||||
|
||||
private TweenerCore<string, string, StringOptions> contentTween;
|
||||
public bool isPlayingSentence;
|
||||
|
||||
public void PlaySentence(string speakerName, string content)
|
||||
{
|
||||
GameObject contentText = Instantiate(textPrefab, textContainer);
|
||||
contentText.transform.GetChild(1).GetComponent<TMP_Text>().text = speakerName;
|
||||
contentText.transform.GetChild(2).GetComponent<TMP_Text>().text = content;
|
||||
//contentText.GetComponent<Localize>().OnLocalize();
|
||||
}
|
||||
|
||||
public void FinishSentence()
|
||||
{
|
||||
if (isPlayingSentence)
|
||||
{
|
||||
contentTween.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/DialogUI/TextFrame.cs.meta
Normal file
11
Assets/Scripts/UI/DialogUI/TextFrame.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14874d8a3e4a31941879415479892501
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user