剧情
This commit is contained in:
8
Assets/Scripts/Story/StoryUI/Blocks.meta
Normal file
8
Assets/Scripts/Story/StoryUI/Blocks.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2c23056fb0ab4b45a8db11866018794
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/Scripts/Story/StoryUI/Blocks/BeatmapStatusMark.cs
Normal file
18
Assets/Scripts/Story/StoryUI/Blocks/BeatmapStatusMark.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BeatmapStatusMark : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b547d2cc398393a46a2a4c503f128cac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/Scripts/Story/StoryUI/Blocks/BlockConnectorUI.cs
Normal file
32
Assets/Scripts/Story/StoryUI/Blocks/BlockConnectorUI.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Story.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI.Extensions;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
public class BlockConnectorUI : MonoBehaviour
|
||||
{
|
||||
public UILineRenderer curve;
|
||||
public StoryBlockUIBase startBlock;
|
||||
public StoryBlockUIBase endBlock;
|
||||
|
||||
public void SetCurve(Vector2 startPosition, Vector2 endPosition)
|
||||
{
|
||||
Vector2 mid1 = (startPosition + endPosition) / 2;
|
||||
Vector2 mid2 = (startPosition + endPosition) / 2;
|
||||
|
||||
mid1.y = startPosition.y;
|
||||
mid2.y = endPosition.y;
|
||||
|
||||
curve.Points = new Vector2[]
|
||||
{
|
||||
startPosition,
|
||||
//mid1,
|
||||
mid2,
|
||||
endPosition
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Blocks/BlockConnectorUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Blocks/BlockConnectorUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98bbf463dca50cc43961c0bb2b8d4f22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Scripts/Story/StoryUI/Blocks/DialogBlockUI.cs
Normal file
51
Assets/Scripts/Story/StoryUI/Blocks/DialogBlockUI.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class DialogBlockUI : StoryBlockUIBase
|
||||
{
|
||||
public string blockTitle;
|
||||
public TMP_Text titleText;
|
||||
|
||||
public Button button;
|
||||
public List<ChoiceGroupUI> choiceGroups;
|
||||
|
||||
public void Initialize(string blockName, Vector2 position, Vector2 positionOffset,
|
||||
Vector2 size, StoryBlockState state, string blockTitle)
|
||||
{
|
||||
base.Initialize(blockName, position, positionOffset, size, state);
|
||||
|
||||
this.blockTitle = blockTitle;
|
||||
titleText.text = blockTitle;
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
if(state == StoryBlockState.Locked) return;
|
||||
|
||||
StoryManager.instance.storyline.currentBlock = this;
|
||||
|
||||
if (state == StoryBlockState.Current)
|
||||
{
|
||||
DialogManager.instance.SetDialog(blockName);
|
||||
DialogManager.instance.PlayNextDialogParagraph(DialogManager.instance.currentDialog);
|
||||
}
|
||||
else if (state == StoryBlockState.Completed)
|
||||
{
|
||||
DialogManager.instance.SetDialog(blockName);
|
||||
DialogManager.instance.PlayNextDialogParagraph(DialogManager.instance.currentDialog, false);
|
||||
DialogManager.instance.RevealDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override StoryBlockSave GetBlockSave()
|
||||
{
|
||||
return new DialogBlockSave(blockName, blockPosition, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Blocks/DialogBlockUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Blocks/DialogBlockUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b976128eb3ec59e4e866dbb610441706
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Assets/Scripts/Story/StoryUI/Blocks/SongBlockUI.cs
Normal file
78
Assets/Scripts/Story/StoryUI/Blocks/SongBlockUI.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Menu;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class SongBlockUI : StoryBlockUIBase
|
||||
{
|
||||
public string songName;
|
||||
public Button button;
|
||||
public TMP_Text songNameText;
|
||||
public RectTransform beatmapStatusMarkContainer;
|
||||
|
||||
public GameObject beatmapStatusMarkPrefab;
|
||||
|
||||
public void Initialize(string blockName, Vector2 position, Vector2 positionOffset,
|
||||
Vector2 size, StoryBlockState state, string songName)
|
||||
{
|
||||
base.Initialize(blockName, position, positionOffset, size, state);
|
||||
|
||||
this.songName = songName;
|
||||
songNameText.text = songName;
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
MenuManager.instance.prepareUIPage.FadeIn();
|
||||
});
|
||||
|
||||
SetUpBeatmapStatusMarks();
|
||||
}
|
||||
|
||||
public override StoryBlockSave GetBlockSave()
|
||||
{
|
||||
return new SongBlockSave(blockName, blockPosition, state);
|
||||
}
|
||||
|
||||
public void SetUpBeatmapStatusMarks()
|
||||
{
|
||||
SongStatusSave songStatusSave = GameSaveManager.instance.SongSaveModule.songStatusSaves[songName];
|
||||
|
||||
string chapter = StoryManager.instance.currentChapter;
|
||||
ChapterSelectionUnit cpt = ChapterSelectionManager.instance.chapters.First(c => c.chapterIndex == chapter);
|
||||
SongItemData song = cpt.songs.First(s => s.songName == this.songName);
|
||||
foreach (DifficultyData difficulty in song.difficultyDataList)
|
||||
{
|
||||
foreach (KeyValuePair<string, BeatmapSave> beatmapSave in songStatusSave.beatmapSaves)
|
||||
{
|
||||
if (beatmapSave.Key == difficulty.difficultyName)
|
||||
{
|
||||
if (beatmapSave.Value.isAllPerfect)
|
||||
{
|
||||
GameObject mark = Instantiate(beatmapStatusMarkPrefab, beatmapStatusMarkContainer);
|
||||
mark.GetComponent<Image>().color = difficulty.color;
|
||||
mark.transform.GetChild(0).GetComponent<TMP_Text>().color = difficulty.color;
|
||||
mark.transform.GetChild(0).GetComponent<TMP_Text>().text = "AP";
|
||||
break;
|
||||
}
|
||||
|
||||
if (beatmapSave.Value.isFullCombo)
|
||||
{
|
||||
GameObject mark = Instantiate(beatmapStatusMarkPrefab, beatmapStatusMarkContainer);
|
||||
mark.GetComponent<Image>().color = difficulty.color;
|
||||
mark.transform.GetChild(0).GetComponent<TMP_Text>().color = difficulty.color;
|
||||
mark.transform.GetChild(0).GetComponent<TMP_Text>().text = "FC";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Blocks/SongBlockUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Blocks/SongBlockUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5efe0a39fe908354e9ab6d1edfdb8843
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Scripts/Story/StoryUI/Blocks/StoryBlockUIBase.cs
Normal file
30
Assets/Scripts/Story/StoryUI/Blocks/StoryBlockUIBase.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public abstract class StoryBlockUIBase : MonoBehaviour
|
||||
{
|
||||
public string blockName;
|
||||
public Vector2 blockPosition;
|
||||
public StoryBlockState state;
|
||||
|
||||
public RectTransform blockRect;
|
||||
public RectTransform inPort;
|
||||
public RectTransform outPort;
|
||||
|
||||
protected void Initialize(string blockName, Vector2 position, Vector2 positionOffset, Vector2 size, StoryBlockState state)
|
||||
{
|
||||
this.blockName = blockName;
|
||||
this.blockPosition = position;
|
||||
this.state = state;
|
||||
|
||||
blockRect.anchoredPosition = position + positionOffset;
|
||||
blockRect.sizeDelta = size;
|
||||
}
|
||||
|
||||
public abstract StoryBlockSave GetBlockSave();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Blocks/StoryBlockUIBase.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Blocks/StoryBlockUIBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d489f986a1eea1e4c938658f0fd468ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/Scripts/Story/StoryUI/Blocks/TutorialBlockUI.cs
Normal file
34
Assets/Scripts/Story/StoryUI/Blocks/TutorialBlockUI.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class TutorialBlockUI : StoryBlockUIBase
|
||||
{
|
||||
public Button button;
|
||||
public string tutorialName;
|
||||
public TMP_Text tutorialNameText;
|
||||
|
||||
public void Initialize(string blockName, Vector2 position, Vector2 positionOffset, Vector2 size, StoryBlockState state, string tutorialName)
|
||||
{
|
||||
base.Initialize(blockName, position, positionOffset, size, state);
|
||||
|
||||
this.tutorialName = tutorialName;
|
||||
tutorialNameText.text = tutorialName;
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
//DialogManager.instance.SetDialog(blockName);
|
||||
});
|
||||
}
|
||||
|
||||
public override StoryBlockSave GetBlockSave()
|
||||
{
|
||||
return new TutorialBlockSave(blockName, blockPosition, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Blocks/TutorialBlockUI.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Blocks/TutorialBlockUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 821e50e1519236a46b03eb1f005acebe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Story/StoryUI/DialogUI.meta
Normal file
8
Assets/Scripts/Story/StoryUI/DialogUI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c234abdb2207c8459280e59152ba1c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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:
|
||||
11
Assets/Scripts/Story/StoryUI/StoryUIPage.cs
Normal file
11
Assets/Scripts/Story/StoryUI/StoryUIPage.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.UI
|
||||
{
|
||||
public class StoryUIPage : UIPageBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/StoryUIPage.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/StoryUIPage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ec0b23c77de2764d9425add8f28ea00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
279
Assets/Scripts/Story/StoryUI/Storyline.cs
Normal file
279
Assets/Scripts/Story/StoryUI/Storyline.cs
Normal file
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public partial class Storyline : MonoBehaviour
|
||||
{
|
||||
[Header("UI References")]
|
||||
public RectTransform content; // Content of ScrollRect
|
||||
[FormerlySerializedAs("textBlockPrefab")] public GameObject dialogBlockPrefab; // Prefab of UI Node
|
||||
public GameObject musicBlockPrefab;
|
||||
public GameObject tutorialBlockPrefab;
|
||||
public GameObject connectionCurvePrefab; // Prefab of connection curve
|
||||
|
||||
[Header("Layout Settings")]
|
||||
public float marginLeft = 50f; // additive space on the left
|
||||
public float marginRight = 50f; // Extra space on the right
|
||||
public float marginTop = 50f; // Extra space on the top
|
||||
public float marginBottom = 50f; // Extra space on the bottom
|
||||
public RectTransform connectionContainer;
|
||||
|
||||
public StoryBlockUIBase currentBlock;
|
||||
|
||||
public List<StoryBlockUIBase> storyBlocks;
|
||||
public List<DialogBlockUI> dialogBlocks;
|
||||
public List<SongBlockUI> songBlocks;
|
||||
public List<TutorialBlockUI> tutorialBlocks;
|
||||
public List<BlockConnectorUI> connectors;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
storyBlocks = new List<StoryBlockUIBase>();
|
||||
dialogBlocks = new List<DialogBlockUI>();
|
||||
songBlocks = new List<SongBlockUI>();
|
||||
tutorialBlocks = new List<TutorialBlockUI>();
|
||||
connectors = new List<BlockConnectorUI>();
|
||||
|
||||
//TutorialBlockUI t0 = GenerateTutorialBlock(new Vector2(200, -400), "ZakoCurse 0");
|
||||
//TextBlockUI b1 = GenerateTextBlock("Departure_P1_A", new Vector2(1000, -400), StoryBlockState.Current);
|
||||
|
||||
SetUpStoryline(StoryManager.instance.currentChapter);
|
||||
|
||||
/*GenerateTextBlock("Departure_P1_A", new Vector2(1000, -400), StoryBlockState.Current);
|
||||
GenerateTextBlock("Departure_P2_A", new Vector2(1500, -400), StoryBlockState.Current);
|
||||
GenerateConnector("Departure_P1_A", "Departure_P2_A");*/
|
||||
|
||||
SetUpBackground();
|
||||
connectionContainer.SetParent(content);
|
||||
connectionContainer.SetAsFirstSibling();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Storyline
|
||||
{
|
||||
public TutorialBlockUI GenerateTutorialBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
TutorialBlockUI block = Instantiate(tutorialBlockPrefab, content).GetComponent<TutorialBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
TutorialBlockData blockData = storyData.tutorialBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
|
||||
block.Initialize(blockData.blockName, position, new Vector2(marginLeft, 0), blockData.blockSize, state, blockData.tutorialName);
|
||||
|
||||
storyBlocks.Add(block);
|
||||
tutorialBlocks.Add(block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
public DialogBlockUI GenerateDialogBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
DialogBlockUI block = Instantiate(dialogBlockPrefab, content).GetComponent<DialogBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
DialogBlockData blockData = storyData.dialogBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
|
||||
block.Initialize(blockData.blockName, position, new Vector2(marginLeft, 0), blockData.blockSize, state, blockData.dialogTitle);
|
||||
|
||||
storyBlocks.Add(block);
|
||||
dialogBlocks.Add(block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
public SongBlockUI GenerateSongBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
SongBlockUI block = Instantiate(musicBlockPrefab, content).GetComponent<SongBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
SongBlockData blockData = storyData.songBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
|
||||
block.Initialize(blockName,position,new Vector2(marginLeft, 0), blockData.blockSize, state, blockData.songName);
|
||||
|
||||
storyBlocks.Add(block);
|
||||
songBlocks.Add(block);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
public void GenerateConnector(StoryBlockUIBase startBlock, StoryBlockUIBase endBlock)
|
||||
{
|
||||
BlockConnectorUI connector = Instantiate(connectionCurvePrefab, connectionContainer).GetComponent<BlockConnectorUI>();
|
||||
|
||||
Vector2 startPosition = SpaceConverter.GetLocalUIPosition(startBlock.outPort, GetComponent<RectTransform>());
|
||||
Vector2 endPosition = SpaceConverter.GetLocalUIPosition(endBlock.inPort, GetComponent<RectTransform>());
|
||||
|
||||
connector.startBlock = startBlock;
|
||||
connector.endBlock = endBlock;
|
||||
|
||||
connector.SetCurve(startPosition, endPosition);
|
||||
connectors.Add(connector);
|
||||
}
|
||||
|
||||
public void GenerateConnector(string startBlockName, string endBlockName)
|
||||
{
|
||||
StoryBlockUIBase startBlock = storyBlocks.FirstOrDefault(block => block.blockName == startBlockName);
|
||||
StoryBlockUIBase endBlock = storyBlocks.FirstOrDefault(block => block.blockName == endBlockName);
|
||||
GenerateConnector(startBlock, endBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Storyline
|
||||
{
|
||||
private void ClearStoryline()
|
||||
{
|
||||
foreach (var block in storyBlocks)
|
||||
{
|
||||
Destroy(block.gameObject);
|
||||
}
|
||||
storyBlocks.Clear();
|
||||
dialogBlocks.Clear();
|
||||
songBlocks.Clear();
|
||||
tutorialBlocks.Clear();
|
||||
|
||||
foreach (var connector in connectors)
|
||||
{
|
||||
Destroy(connector.gameObject);
|
||||
}
|
||||
connectors.Clear();
|
||||
|
||||
content.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
private void SetUpBackground()
|
||||
{
|
||||
float maxRight = float.MinValue;
|
||||
|
||||
foreach (var block in storyBlocks)
|
||||
{
|
||||
float rightEdge = block.blockRect.anchoredPosition.x + block.blockRect.sizeDelta.x * 0.5f;
|
||||
if (rightEdge > maxRight)
|
||||
{
|
||||
maxRight = rightEdge;
|
||||
}
|
||||
}
|
||||
|
||||
maxRight += marginRight;
|
||||
|
||||
if (maxRight < 2560f)
|
||||
{
|
||||
maxRight = 2560f;
|
||||
}
|
||||
|
||||
|
||||
float lowY = float.MaxValue;
|
||||
|
||||
foreach (var block in storyBlocks)
|
||||
{
|
||||
float bottomEdge = block.blockRect.anchoredPosition.y - block.blockRect.sizeDelta.y * 0.5f;
|
||||
if (bottomEdge < lowY)
|
||||
{
|
||||
lowY = bottomEdge;
|
||||
}
|
||||
}
|
||||
|
||||
float maxHeight = Mathf.Abs(lowY) + marginTop + marginBottom;
|
||||
|
||||
if (maxHeight < 1440f)
|
||||
{
|
||||
maxHeight = 1440f;
|
||||
}
|
||||
|
||||
content.sizeDelta = new Vector2(maxRight, maxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Storyline
|
||||
{
|
||||
public void SetUpStoryline(string chapterName)
|
||||
{
|
||||
GameSaveManager.instance.StorySaveModule.LoadStoryline(chapterName);
|
||||
|
||||
foreach (var blockSave in GameSaveManager.instance.StorySaveModule.tutorialBlockSaves[chapterName])
|
||||
{
|
||||
GenerateTutorialBlock(blockSave.blockName, blockSave.position, blockSave.state);
|
||||
}
|
||||
|
||||
foreach (var blockSave in GameSaveManager.instance.StorySaveModule.songBlockSaves[chapterName])
|
||||
{
|
||||
GenerateSongBlock(blockSave.blockName, blockSave.position, blockSave.state);
|
||||
}
|
||||
|
||||
foreach (var blockSave in GameSaveManager.instance.StorySaveModule.dialogBlockSaves[chapterName])
|
||||
{
|
||||
GenerateDialogBlock(blockSave.blockName, blockSave.position, blockSave.state);
|
||||
}
|
||||
|
||||
foreach (var connectorSave in GameSaveManager.instance.StorySaveModule.connectorSaves[chapterName])
|
||||
{
|
||||
GenerateConnector(connectorSave.startBlockName, connectorSave.endBlockName);
|
||||
}
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void SaveStoryline(string chapterName)
|
||||
{
|
||||
List<TutorialBlockSave> tutorialBlockSaves =
|
||||
tutorialBlocks.Select(block => block.GetBlockSave() as TutorialBlockSave).ToList();
|
||||
|
||||
List<SongBlockSave> songBlockSaves =
|
||||
songBlocks.Select(block => block.GetBlockSave() as SongBlockSave).ToList();
|
||||
|
||||
List<DialogBlockSave> dialogBlockSaves =
|
||||
dialogBlocks.Select(block => block.GetBlockSave() as DialogBlockSave).ToList();
|
||||
|
||||
List<BlockConnectorSave> connectorSaves =
|
||||
connectors.Select(connector => new BlockConnectorSave(connector.startBlock.blockName, connector.endBlock.blockName)).ToList();
|
||||
|
||||
GameSaveManager.instance.StorySaveModule.SaveStoryline(
|
||||
chapterName, tutorialBlockSaves, songBlockSaves, dialogBlockSaves, connectorSaves);
|
||||
}
|
||||
|
||||
[Button]
|
||||
public void ResetStory()
|
||||
{
|
||||
ClearStoryline();
|
||||
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
List<InitialBlockData> initialBlocks = storyData.initialBlocks;
|
||||
|
||||
foreach (InitialBlockData blockData in initialBlocks)
|
||||
{
|
||||
storyData.GetDataByName(blockData.blockName, out Type dataType);
|
||||
|
||||
if (dataType == typeof(TutorialBlockData))
|
||||
{
|
||||
GenerateTutorialBlock(blockData.blockName, blockData.blockPosition, blockData.initialState);
|
||||
}
|
||||
else if (dataType == typeof(DialogBlockData))
|
||||
{
|
||||
GenerateDialogBlock(blockData.blockName, blockData.blockPosition, blockData.initialState);
|
||||
}
|
||||
else if (dataType == typeof(SongBlockData))
|
||||
{
|
||||
GenerateSongBlock(blockData.blockName, blockData.blockPosition, blockData.initialState);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (InitialBlockData blockData in initialBlocks)
|
||||
{
|
||||
foreach (string nextBlockName in blockData.nextBlocks)
|
||||
{
|
||||
GenerateConnector(blockData.blockName, nextBlockName);
|
||||
}
|
||||
}
|
||||
|
||||
SetUpBackground();
|
||||
SaveStoryline(StoryManager.instance.currentChapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryUI/Storyline.cs.meta
Normal file
11
Assets/Scripts/Story/StoryUI/Storyline.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42d37c15aeeaf1d4abbdc13962bb8b70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user