Ink Integration
Initial integration of Ink scripting - simply runs the first story it finds.
This commit is contained in:
parent
9779afb1bb
commit
82c8041765
215 changed files with 23662 additions and 17 deletions
|
|
@ -8,6 +8,8 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Cinemachine;
|
||||
using Ink;
|
||||
using Ink.Runtime;
|
||||
using MessagePack;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
|
|
@ -21,6 +23,7 @@ using UnityEngine.EventSystems;
|
|||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
using float3 = Unity.Mathematics.float3;
|
||||
using Path = System.IO.Path;
|
||||
using quaternion = Unity.Mathematics.quaternion;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
|
|
@ -154,6 +157,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
public ItemManager ItemManager { get; private set; }
|
||||
public Zone Zone { get; private set; }
|
||||
public List<EntityPack> Loadouts { get; } = new List<EntityPack>();
|
||||
public IEnumerable<Story> GetStories => _stories;
|
||||
|
||||
private readonly (float2 direction, string name)[] _directions = {
|
||||
(float2(0, 1), "Front"),
|
||||
|
|
@ -165,6 +169,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
private DragAction _dragAction;
|
||||
private Action<DragAction> _endDragCallback;
|
||||
|
||||
private List<Story> _stories = new List<Story>();
|
||||
|
||||
public EntitySettings NewEntitySettings
|
||||
{
|
||||
get => MessagePackSerializer.Deserialize<EntitySettings>(MessagePackSerializer.Serialize(Settings.GameplaySettings.DefaultEntitySettings));
|
||||
|
|
@ -200,6 +206,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
ItemManager = new ItemManager(CultCache, Settings.GameplaySettings, Debug.Log);
|
||||
ZoneRenderer.ItemManager = ItemManager;
|
||||
|
||||
var narrativePath = GameDataDirectory.CreateSubdirectory("Narrative");
|
||||
var narrativeFiles = narrativePath.EnumerateFiles("*.ink");
|
||||
foreach(var inkFile in narrativeFiles)
|
||||
{
|
||||
var compiler = new Compiler(File.ReadAllText(inkFile.FullName));
|
||||
_stories.Add(compiler.Compile());
|
||||
}
|
||||
|
||||
// _loadoutPath = GameDataDirectory.CreateSubdirectory("Loadouts");
|
||||
// Loadouts.AddRange(_loadoutPath.EnumerateFiles("*.loadout")
|
||||
// .Select(fi => MessagePackSerializer.Deserialize<EntityPack>(File.ReadAllBytes(fi.FullName))));
|
||||
|
|
|
|||
9
Assets/Scripts/UI/ChoicePrefab.cs
Normal file
9
Assets/Scripts/UI/ChoicePrefab.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChoicePrefab : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI Label;
|
||||
public Button Button;
|
||||
}
|
||||
11
Assets/Scripts/UI/ChoicePrefab.cs.meta
Normal file
11
Assets/Scripts/UI/ChoicePrefab.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 369e33e0c70b03740a9f757c5a1a9dac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Scripts/UI/LocalMenu.cs
Normal file
63
Assets/Scripts/UI/LocalMenu.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ink.Runtime;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
|
||||
public class LocalMenu : MonoBehaviour
|
||||
{
|
||||
public ObservablePointerClickTrigger ContinueTrigger;
|
||||
public TextMeshProUGUI Output;
|
||||
public RectTransform ChoiceParent;
|
||||
public ChoicePrefab ChoicePrefab;
|
||||
|
||||
private Story _currentStory;
|
||||
private List<GameObject> _choiceInstances = new List<GameObject>();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_currentStory = ActionGameManager.Instance.GetStories.First();
|
||||
Continue();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
ContinueTrigger.OnPointerClickAsObservable().Subscribe(pointerEvent =>
|
||||
{
|
||||
if (_currentStory == null) return;
|
||||
|
||||
if(_currentStory.canContinue) Continue();
|
||||
});
|
||||
}
|
||||
|
||||
void Continue()
|
||||
{
|
||||
Output.text = _currentStory.Continue();
|
||||
|
||||
foreach(var instance in _choiceInstances)
|
||||
Destroy(instance);
|
||||
_choiceInstances.Clear();
|
||||
|
||||
foreach (var choice in _currentStory.currentChoices)
|
||||
{
|
||||
var choiceInstance = Instantiate(ChoicePrefab, ChoiceParent);
|
||||
choiceInstance.Label.text = choice.text;
|
||||
choiceInstance.Button.onClick.AddListener(() =>
|
||||
{
|
||||
_currentStory.ChoosePath(choice.targetPath);
|
||||
Continue();
|
||||
});
|
||||
_choiceInstances.Add(choiceInstance.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/LocalMenu.cs.meta
Normal file
11
Assets/Scripts/UI/LocalMenu.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 94223b4e7b954df47a5400f0e7be80c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -73,5 +73,6 @@ public enum MenuTab
|
|||
Map,
|
||||
Inventory,
|
||||
Trade,
|
||||
Galaxy
|
||||
Galaxy,
|
||||
Local
|
||||
}
|
||||
Loading…
Reference in a new issue