剧情
This commit is contained in:
106
Assets/Scripts/Story/StoryData/StoryData.cs
Normal file
106
Assets/Scripts/Story/StoryData/StoryData.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Story
|
||||
{
|
||||
[CreateAssetMenu(fileName = "StoryData", menuName = "Ichni/Story/StoryData")]
|
||||
public class StoryData : SerializedScriptableObject
|
||||
{
|
||||
public List<DialogBlockData> dialogBlockDatas; // 剧情单元格名称列表
|
||||
public List<SongBlockData> songBlockDatas; // 音乐单元格名称列表
|
||||
public List<TutorialBlockData> tutorialBlockDatas; // 教程单元格名称列表
|
||||
public List<InitialBlockData> initialBlocks; // 初始剧情单元格列表,包含所有初始剧情单元格的名称
|
||||
|
||||
public StoryBlockData GetDataByName(string blockName, out Type dataType)
|
||||
{
|
||||
foreach (var block in tutorialBlockDatas.Where(block => block.blockName == blockName))
|
||||
{
|
||||
dataType = typeof(TutorialBlockData);
|
||||
return block;
|
||||
}
|
||||
|
||||
foreach (var block in songBlockDatas.Where(block => block.blockName == blockName))
|
||||
{
|
||||
dataType = typeof(SongBlockData);
|
||||
return block;
|
||||
}
|
||||
|
||||
foreach (var block in dialogBlockDatas.Where(block => block.blockName == blockName))
|
||||
{
|
||||
dataType = typeof(DialogBlockData);
|
||||
return block;
|
||||
}
|
||||
|
||||
throw new ArgumentException($"No block found with name: {blockName}");
|
||||
}
|
||||
}
|
||||
|
||||
[InlineProperty]
|
||||
[Serializable]
|
||||
public class InitialBlockData
|
||||
{
|
||||
public string blockName;
|
||||
public StoryBlockState initialState; // 初始状态
|
||||
public Vector2 blockPosition; // 初始位置
|
||||
public List<string> nextBlocks; // 下一步可选的剧情单元格名称列表
|
||||
}
|
||||
|
||||
[InlineProperty]
|
||||
[Serializable]
|
||||
public class StoryBlockData
|
||||
{
|
||||
[FoldoutGroup("$blockName", true)]
|
||||
public string blockName;
|
||||
[FoldoutGroup("$blockName")]
|
||||
public string blockID;
|
||||
[FoldoutGroup("$blockName")]
|
||||
public Vector2 blockSize;
|
||||
}
|
||||
|
||||
[InlineProperty]
|
||||
[Serializable]
|
||||
public class TutorialBlockData : StoryBlockData
|
||||
{
|
||||
[FoldoutGroup("$blockName")]
|
||||
public string tutorialName;
|
||||
|
||||
|
||||
public TutorialBlockData()
|
||||
{
|
||||
this.blockSize = new Vector2(400, 200);
|
||||
}
|
||||
}
|
||||
|
||||
[InlineProperty]
|
||||
[Serializable]
|
||||
public class DialogBlockData : StoryBlockData
|
||||
{
|
||||
[FoldoutGroup("$blockName")]
|
||||
public string dialogTitle;
|
||||
|
||||
|
||||
public DialogBlockData()
|
||||
{
|
||||
this.blockSize = new Vector2(400, 200);
|
||||
}
|
||||
}
|
||||
|
||||
[InlineProperty]
|
||||
[Serializable]
|
||||
public class SongBlockData : StoryBlockData
|
||||
{
|
||||
[FoldoutGroup("$blockName")]
|
||||
public string songName;
|
||||
|
||||
|
||||
public SongBlockData()
|
||||
{
|
||||
this.blockSize = new Vector2(400, 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Story/StoryData/StoryData.cs.meta
Normal file
11
Assets/Scripts/Story/StoryData/StoryData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ab917c50249812429ebd44d6574497c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user