剧情
This commit is contained in:
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceButtonUI.cs
Normal file
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceButtonUI.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class ChoiceButtonUI : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceButtonUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceButtonUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90f34f59ff260c44796d71c51b7c0ee6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceGroupUI.cs
Normal file
45
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceGroupUI.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class ChoiceGroupUI : MonoBehaviour
|
||||
{
|
||||
public GameObject choiceButtonPrefab;
|
||||
public RectTransform container;
|
||||
|
||||
public List<Button> choiceButtonList;
|
||||
|
||||
public string choiceName;
|
||||
public int choiceIndex;
|
||||
|
||||
public void Initialize(ChoiceGroup choiceGroup)
|
||||
{
|
||||
this.choiceName = choiceGroup.choiceName;
|
||||
choiceButtonList = new List<Button>();
|
||||
|
||||
for (var index = 0; index < choiceGroup.choices.Count; index++)
|
||||
{
|
||||
var choice = choiceGroup.choices[index];
|
||||
int cIndex = index; // Capture the current index for the listener
|
||||
|
||||
GameObject choiceButton = Instantiate(choiceButtonPrefab, container);
|
||||
choiceButton.GetComponentInChildren<Localize>().SetTerm(StoryManager.instance.currentChapter + "/" + choice.choiceText);
|
||||
choiceButton.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
DialogManager.instance.PlayNextDialogParagraph(choice.nextDialogName);
|
||||
DialogManager.instance.isPlayingChoice = false;
|
||||
choiceButtonList.ForEach(b => b.interactable = false);
|
||||
DialogManager.instance.PlayDialog();
|
||||
this.choiceIndex = cIndex;
|
||||
GameSaveManager.instance.StorySaveModule.selectedChoices[choiceName] = cIndex;
|
||||
});
|
||||
choiceButtonList.Add(choiceButton.GetComponent<Button>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceGroupUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/DialogUI/ChoiceGroupUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a653477cd0de8794b810214793b04cc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
81
Assets/Scripts/Story/StoryUI/DialogUI/DialogContentFrame.cs
Normal file
81
Assets/Scripts/Story/StoryUI/DialogUI/DialogContentFrame.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
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 Ichni.Story.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
public class DialogContentFrame : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public GameObject textPrefab;
|
||||
public GameObject choiceGroupPrefab;
|
||||
|
||||
public RectTransform dialogContentContainer;
|
||||
public List<DialogTextUI> dialogTexts;
|
||||
public List<ChoiceGroupUI> choiceGroups;
|
||||
|
||||
public void PlaySentence(string speakerName, string content)
|
||||
{
|
||||
DialogTextUI dialogTextUI = Instantiate(textPrefab, dialogContentContainer).GetComponent<DialogTextUI>();
|
||||
dialogTextUI.speakerNameText.SetTerm("Characters/" + speakerName);
|
||||
dialogTextUI.contentText.SetTerm(StoryManager.instance.currentChapter +"/" +content);
|
||||
dialogTexts.Add(dialogTextUI);
|
||||
}
|
||||
|
||||
public ChoiceGroupUI PlayChoice(ChoiceGroup choiceGroup)
|
||||
{
|
||||
ChoiceGroupUI choiceGroupUI = Instantiate(choiceGroupPrefab, dialogContentContainer).GetComponent<ChoiceGroupUI>();
|
||||
choiceGroupUI.Initialize(choiceGroup);
|
||||
choiceGroups.Add(choiceGroupUI);
|
||||
|
||||
return choiceGroupUI;
|
||||
}
|
||||
|
||||
public void SelectChoice(ChoiceGroup choiceGroup, int index)
|
||||
{
|
||||
ChoiceGroupUI choiceGroupUI = PlayChoice(choiceGroup);
|
||||
for (var buttonIndex = 0; buttonIndex < choiceGroupUI.choiceButtonList.Count; buttonIndex++)
|
||||
{
|
||||
Button b = choiceGroupUI.choiceButtonList[buttonIndex];
|
||||
b.interactable = false;
|
||||
|
||||
if (buttonIndex == index)
|
||||
{
|
||||
b.image.color = Color.red;
|
||||
}
|
||||
}
|
||||
|
||||
DialogManager.instance.PlayNextDialogParagraph(choiceGroup.choices[index].nextDialogName, false);
|
||||
}
|
||||
|
||||
public void ClearAllSentences()
|
||||
{
|
||||
foreach (DialogTextUI dialogText in dialogTexts)
|
||||
{
|
||||
Destroy(dialogText.gameObject);
|
||||
}
|
||||
|
||||
foreach (ChoiceGroupUI choiceGroup in choiceGroups)
|
||||
{
|
||||
Destroy(choiceGroup.gameObject);
|
||||
}
|
||||
|
||||
dialogTexts.Clear();
|
||||
choiceGroups.Clear();
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
DialogManager.instance.PlayDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14874d8a3e4a31941879415479892501
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Story/StoryUI/DialogUI/DialogTextUI.cs
Normal file
16
Assets/Scripts/Story/StoryUI/DialogUI/DialogTextUI.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using I2.Loc;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class DialogTextUI : MonoBehaviour
|
||||
{
|
||||
public Image background;
|
||||
public Localize speakerNameText;
|
||||
public Localize contentText;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/DialogUI/DialogTextUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/DialogUI/DialogTextUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 831ccff3dc06bfc4884663d623af866d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Scripts/Story/StoryUI/DialogUI/DialogUIPage.cs
Normal file
15
Assets/Scripts/Story/StoryUI/DialogUI/DialogUIPage.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
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 DialogContentFrame dialogContentFrame;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/DialogUI/DialogUIPage.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/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:
|
||||
Reference in New Issue
Block a user