Ink Integration

Initial integration of Ink scripting - simply runs the first story it finds.
This commit is contained in:
Reinier Vens 2021-04-19 04:35:46 +01:00
commit 82c8041765
215 changed files with 23662 additions and 17 deletions

View file

@ -0,0 +1,9 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ChoicePrefab : MonoBehaviour
{
public TextMeshProUGUI Label;
public Button Button;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 369e33e0c70b03740a9f757c5a1a9dac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View 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()
{
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 94223b4e7b954df47a5400f0e7be80c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -73,5 +73,6 @@ public enum MenuTab
Map,
Inventory,
Trade,
Galaxy
Galaxy,
Local
}