void StartStory() { story = new Story(inkJSONAsset.text); story.BindExternalFunction("place_actors", (string leftName, string rightName) => { characterManager.PlaceActors(leftName, rightName); }); story.BindExternalFunction("change_emotion", (string emotion, int ID) => { characterManager.ChangeActorEmotion(emotion, ID); }); story.BindExternalFunction("place_one_actor", (string soleName) => { characterManager.PlaceOneActor(soleName); }); story.BindExternalFunction("choose_background", (int background) => { backgroundManager.SetBackground(background); }); RefreshView(); }
private void initExternalMethods() { //checks if hero has a given item story.BindExternalFunction("check_has_item", (int id) => { return(Hero.active.inventory.HasItem(id)); }); //returns name story.BindExternalFunction("hero_name", () => { return(Hero.active.data.Name); }); //checks if type of sample is playing story.BindExternalFunction("is_instrument_playing", (string _ins) => { return(CheckSamplesForInstrument(_ins)); }); //checks if player has sample story.BindExternalFunction("check_has_sample", (int id) => { return(Hero.active.inventory.HasSample(id)); }); }
private void SetExternalInkFunctions() { story.BindExternalFunction("GetName", (int p) => { return(citizens[p].citizenName); }); story.BindExternalFunction("GetSurname", (int p) => { return(citizens[p].citizenSurname); }); story.BindExternalFunction("GetLike", (int p) => { return((int)citizens[p].like); }); story.BindExternalFunction("GetDislike", (int p) => { return((int)citizens[p].dislike); }); story.BindExternalFunction("GetProficiency", (int p) => { return((int)citizens[p].proficience); }); }
public void BindFunction <T1, T2>(string functionName, Action <T1, T2> action) { if (!_functionNames.Contains(functionName)) { _story.BindExternalFunction(functionName, action); _functionNames.Add(functionName); } }
// Creates a new Story object with the compiled story which we can then play! void StartStory() { story = new Story(inkJSONAsset.text); story.BindExternalFunction("place_actors", (string leftName, string rightName) => { cm.PlaceActors(leftName, rightName); }); story.BindExternalFunction("change_emotion", (string emotion, int ID) => { cm.ChangeActorEmotion(emotion, ID); }); RefreshView(); }
private void BindFunctions() { inkStory.BindExternalFunction("getValue", (int a) => { GVar var = GlobalVariables.GetVariable(a); if (var == null) { return("no var"); } switch (var.type) { case VariableType.Boolean: return(var.BooleanValue); case VariableType.Integer: return(var.IntegerValue); case VariableType.String: return(var.textVal); case VariableType.Float: return(var.floatVal); } return("no var"); }); }
void Start() { _registeredActors = UI.GetActorNames(); _story = new Story(StoryJson.text); ProceedButton.onClick.AddListener(delegate { OnProceed(); }); _story.BindExternalFunction("gender", () => GetGender()); // Bind variable changes _story.ObserveVariable("didCompleteChapter", OnDidCompleteChapterChange); UI.SetOnChoiceHandler(OnChoice); /* * Debug.Log(LayoutUtility.GetPreferredHeight(OutputText.rectTransform)); * Debug.Log(LayoutUtility.GetPreferredHeight(OutputBackground.rectTransform)); * OutputText.text = "Lorem ipsum dolores etc etc etc\n\nThis is some multiline text"; * Debug.Log(LayoutUtility.GetPreferredHeight(OutputText.rectTransform)); * Debug.Log(LayoutUtility.GetPreferredHeight(OutputBackground.rectTransform)); * * OutputText.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, LayoutUtility.GetPreferredHeight(OutputText.rectTransform)); * OutputBackground.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, LayoutUtility.GetPreferredHeight(OutputText.rectTransform) + 30); */ OnProceed(); }
// Start is called before the first frame update void Start() { audioSource = this.GetComponent <AudioSource>(); story = new Story(inkAsset.text); // ------------------ Observeable Variables story.ObserveVariable("energy", (string varName, object newValue) => { StatController.UpdateEnergyStat((int)newValue); }); story.ObserveVariable("comfort", (string varName, object newValue) => { StatController.UpdateComfortStat((int)newValue); }); story.ObserveVariable("hunger", (string varName, object newValue) => { StatController.UpdateHungerStat((int)newValue); }); story.ObserveVariable("bladder", (string varName, object newValue) => { StatController.UpdateBladderStat((int)newValue); }); story.ObserveVariable("hygiene", (string varName, object newValue) => { StatController.UpdateHygieneStat((int)newValue); }); story.BindExternalFunction("EndGame", () => EndGame()); userFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; storyText.fontSize = userFontSize; storyText.font = userFont; Refresh(); }
private void StartStory() { _story = new Story(_inkJsonAsset.text); _story.BindExternalFunction("ShowCharacter", (string name, string position, string mood) => _characterManager.ShowCharacter(name, position, mood)); _story.BindExternalFunction("HideCharacter", (string name) => _characterManager.HideCharacter(name)); _story.BindExternalFunction("ChangeMood", (string name, string mood) => _characterManager.ChangeMood(name, mood)); DisplayNextLine(); RefreshChoiceView(); }
void BindExternalFunctions() { story.BindExternalFunction("GoToScene", (string _sceneName) => { endDialogueEvent = true; sceneName = _sceneName; }); }
void BindFunctions() { _inkStory.BindExternalFunction("loadQuestLevel1", () => { Debug.Log("load quest"); gameSceneManager.LoadQuestLevel1(); soundManager.PlayPlanetCraft(); }); _inkStory.BindExternalFunction("playVoiceAlien1", () => { soundManager.PlayVoiceAlien1(); }); _inkStory.BindExternalFunction("gameOver", () => { Debug.Log("Game Over!"); gameManager.GameOver(); }); }
public void setStory() { if (dialogValue.value) { DeleteOldDialogs(); story = new Story(dialogValue.value.text); } else { Debug.LogError("Failed to set Story"); } story.BindExternalFunction("removePotato", () => { _ = inventory.items.Remove(potato); }); story.BindExternalFunction("removeLeaf", () => { _ = inventory.items.Remove(leaf); }); story.BindExternalFunction("addCoinToPlayer", (int coin) => { inventory.coin += coin; }); }
private void SetExternalInkFunctions() { story.BindExternalFunction("GetName", (int p) => { return(getName(p)); }); story.BindExternalFunction("GetSurname", (int p) => { return(getSurname(p)); }); story.BindExternalFunction("GetLike", (int p) => { return(getLike(p)); }); story.BindExternalFunction("GetDislike", (int p) => { return(getDislike(p)); }); story.BindExternalFunction("GetProficiency", (int p) => { return(getProficiency(p)); }); story.BindExternalFunction("GetItem", (int p) => { return(newItem.GetComponent <DecorationScript>().displayName); }); }
// Use this for initialization void Awake() { // if (_instance == null) // _instance = this; // else // { // Destroy(gameObject); // return; // } DontDestroyOnLoad(gameObject); inkEventDelegate += CatchEvent; inkStory = new Story(storyScript.text); inkStory.BindExternalFunction <String>("CustomEvent", inkEventDelegate); }
// Use this for initialization void OnEnable() { Debug.Log(StoryManager.instance.name); mainStory = _mainStory; StoryManager.instance.LoadSaves(); entities = Resources.LoadAll <Entity>("Entities"); Debug.Log(entities.Length + " entities loaded"); atmospheres = Resources.LoadAll <Atmosphere>("Atmospheres"); Debug.Log(atmospheres.Length + " atmospheres loaded"); scenes = Resources.LoadAll <SceneRedirect>("Databases/Scene Redirects"); Debug.Log(scenes.Length + " scene redirects loaded"); if (story == null) { story = new Story(mainStory.text); story.ObserveVariable("scene", (string varName, object newValue) => { GameManager.instance.ChangeScene((string)newValue); }); story.ObserveVariable("ana_healthMax", (string varName, object newValue) => { GameManager.instance.ChangeMaxHealth((int)newValue); }); story.ObserveVariable("ana_health", (string varName, object newValue) => { GameManager.instance.ChangeHealth((int)newValue); }); story.BindExternalFunction("Roll", (float req, float mod) => { return(GameManager.instance.Roll(req, mod)); }); /* * story.BindExternalFunction("getReputation", (string name) => { * Entity entity = GetEntity(name); * return GetReputation(entity); * }); * story.BindExternalFunction("changeScene", (string name) => { * //Entity entity = GetEntity(name); * return "["+name+"]"; //NovelManager.ChangeScene(name); * }); */ } }
// Use this for initialization void Awake() { if (_instance == null) { _instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); startTime = System.DateTime.Now.ToString("dd-MM-yy_HH:mm:ss"); inkEventDelegate += CatchEvent; inkStory = new Story(storyScript.text); inkStory.BindExternalFunction <String>("CustomEvent", inkEventDelegate); }
// Start is called before the first frame update public void PlayDialogue(string name) { talking = true; TextAsset inkJSON = Resources.Load <TextAsset>("Ink/" + name); story = new Story(inkJSON.text); story.BindExternalFunction("check_money", (string value) => { int number = int.Parse(value); if (money > number) { return(1); } else { return(0); } }); refreshUI(); }
private void BindFunctions() { story.BindExternalFunction("closeOut", () => { SlotManager.SM.CheckIfDoneAll(); if (SlotManager.SM.shouldEnd) { narrButton.interactable = false; StartCoroutine(SlotManager.FadeOut(SlotManager.SM.audioSource, 0.8f)); LeanTween.scale(flashbackObject, Vector3.zero, 2f).setEaseInOutQuad().setDelay(0.6f).setOnComplete(() => { SlotManager.SM.CallEnd(); }); } else { LeanTween.scale(flashbackObject, Vector3.zero, 2f).setEaseInOutQuad().setDelay(0.6f); narrButton.interactable = false; StartCoroutine(SlotManager.FadeOut(SlotManager.SM.audioSource, 0.8f)); SlotManager.SM.RefreshButton(); } }); }
protected void Start() { _inkStory.BindExternalFunction("ResetStory", () => { ResetInk(); }); _inkStory.BindExternalFunction("EndEvent", () => { GhuestManager.gm.EndEvent(); }); _inkStory.BindExternalFunction("HangUp", () => { Desk.d.phone.HangUp(); }); _inkStory.BindExternalFunction("EndEmployeeMessage", () => { BinaryRiver.br.CloseMail(); }); _inkStory.BindExternalFunction("GiveItem", (string n) => { Desk.d.drawers.ShowItem(n); }); _inkStory.BindExternalFunction("TriggerGameFinale", () => { FINALE(); }); _inkStory.BindExternalFunction("ActualFinish", () => { endGame.finishThatShit(); }); currentTextObject = readerContainer.transform.GetChild(0).GetComponent <Text>(); currentChoices = new List <String>(); waitingTags = new List <String>(); waitingForInput = false; waitingForContinue = false; SwitchActive(false); }
public void ReloadStories() { CurrentStories.Clear(); foreach (Chat C in AllChats) { Story s = new Story(C.ChatText.text); CurrentStories.Add(C.ChatChannelName, s); s.BindExternalFunction("RelationshipChange", (string character, int change) => { DisplayManager.instance.AddRelationshipValue(character, change); Debug.Log("RelationshipChange called with channel " + character + " and value " + change); }); s.BindExternalFunction("GetRelationshipValue", (string character) => { return(DisplayManager.instance.GetRelationshipValue(character)); }); s.BindExternalFunction("PlayerName", () => { return(DisplayManager.instance.GetPlayerName()); }); s.BindExternalFunction("PlayerPersonalPronoun", () => { return(DisplayManager.instance.GetPersonalPronoun()); }); s.BindExternalFunction("PlayerPossessivePronoun", () => { return(DisplayManager.instance.GetPossessivePronoun()); }); s.BindExternalFunction("PlayerObjectivePronoun", () => { return(DisplayManager.instance.GetObjectivePronoun()); }); } }
/* Call this to bind all ink functions to my scripts. Called in StartStory. */ private void BindExternalFunctions(Story story) { story.BindExternalFunction("enter_both", (string leftname, string rightname) => { cm.PlaceActors(leftname, rightname); }); story.BindExternalFunction("enter_left", (string leftname) => { cm.PlaceLeft(leftname); }); story.BindExternalFunction("enter_right", (string rightname) => { cm.PlaceRight(rightname); }); story.BindExternalFunction("exit_left", () => { cm.ExitLeft(); }); story.BindExternalFunction("exit_right", () => { cm.ExitRight(); }); story.BindExternalFunction("enter_at_location", (string actorName, int location) => { cm.PlaceAtLocation(actorName, location); }); story.BindExternalFunction("remove _all", () => { cm.ExitAll(); }); story.BindExternalFunction("i_display_image", (string imageName) => { im.DisplayImage(imageName); }); story.BindExternalFunction("i_scene_transition", (string name) => { stm.Transition(name); }); story.BindExternalFunction("swap_actors", (string name, int position) => { cm.SwapCharacterPosition(name, position); }); story.BindExternalFunction("flip_actor", (string name) => { cm.flip(name); }); }
private void BindFunctions() { inkStory.BindExternalFunction("getValue", (int a) => { GVar var = GlobalVariables.GetVariable(a); if (var == null) { return("no var"); } switch (var.type) { case VariableType.Boolean: return(var.BooleanValue); case VariableType.Integer: return(var.IntegerValue); case VariableType.String: return(var.textVal); case VariableType.Float: return(var.floatVal); } return("no var"); }); inkStory.BindExternalFunction("getLocalValue", (int a) => { GVar var = LocalVariables.GetVariable(a); if (var == null) { return("no var"); } switch (var.type) { case VariableType.Boolean: return(var.BooleanValue); case VariableType.Integer: return(var.IntegerValue); case VariableType.String: return(var.textVal); case VariableType.Float: return(var.floatVal); } return("no var"); }); inkStory.BindExternalFunction("inventoryContains", (string item) => { foreach (InvItem invItem in KickStarter.runtimeInventory.localItems) { if (invItem.GetLabel(0).Trim().ToLower() == item.Trim().ToLower()) { return(true); } } return(false); }); }
private void Initialize() { CurrentStories = new Dictionary <string, Story>(); CurrentTimeClocks = new Dictionary <string, float>(); foreach (Chat C in AllChats) { Story s = new Story(C.ChatText.text); CurrentStories.Add(C.ChatChannelName, s); s.BindExternalFunction("RelationshipChange", (string character, int change) => { DisplayManager.instance.AddRelationshipValue(character, change); Debug.Log("RelationshipChange called with channel " + character + " and value " + change); }); s.BindExternalFunction("GetRelationshipValue", (string character) => { return(DisplayManager.instance.GetRelationshipValue(character)); }); s.BindExternalFunction("PlayerName", () => { return(DisplayManager.instance.GetPlayerName()); }); s.BindExternalFunction("PlayerPersonalPronoun", () => { return(DisplayManager.instance.GetPersonalPronoun()); }); s.BindExternalFunction("PlayerPossessivePronoun", () => { return(DisplayManager.instance.GetPossessivePronoun()); }); s.BindExternalFunction("PlayerObjectivePronoun", () => { return(DisplayManager.instance.GetObjectivePronoun()); }); s.BindExternalFunction("PartyAnetta", () => { return(DisplayManager.instance.GetPartyAnetta()); }); s.BindExternalFunction("SetPartyAnetta", (bool party) => { DisplayManager.instance.SetPartyAnetta(party); }); s.BindExternalFunction("CheckHemaDrunk", () => { return(DisplayManager.instance.GetHemaDrunk()); }); s.BindExternalFunction("SetHemaDrunk", (bool drunk) => { DisplayManager.instance.SetHemaDrunk(drunk); }); s.BindExternalFunction("SetKebab", (bool kebab) => { DisplayManager.instance.SetKebab(kebab); }); s.BindExternalFunction("GetKebab", () => { return(DisplayManager.instance.GetKebab()); }); s.BindExternalFunction("ShowEndGamePanel", () => { DisplayManager.instance.ShowEndGamePanel(); }); } }
void Start() { /*Person ResetCharacter = new Person(1, 7, 1, 1, * 1, 1, 1, "Assets/Prefabs/PlayerCharacter.prefab"); * GameObject avatar = Instantiate(avatarPrefab) as GameObject; * avatar.transform.SetParent(characterCreationImage.transform, false);*/ audioSource = this.GetComponent <AudioSource>(); story = new Story(inkAsset.text); // ------------------ Observeable Variables // Stats story.ObserveVariable("energy", (string varName, object newValue) => { StatController.UpdateEnergyStat((int)newValue); }); story.ObserveVariable("health", (string varName, object newValue) => { StatController.UpdateHealthStat((int)newValue); }); story.ObserveVariable("wellness", (string varName, object newValue) => { StatController.UpdateWellnessStat((int)newValue); }); // Date / UI Stuff story.ObserveVariable("fullDate", (string varName, object newValue) => { LabelController.UpdateDate((string)newValue); }); story.ObserveVariable("today", (string varName, object newValue) => { LabelController.UpdateWeekday(newValue); }); story.ObserveVariable("time", (string varName, object newValue) => { LabelController.UpdateTimeSlot(newValue); }); story.ObserveVariable("location", (string varName, object newValue) => { LabelController.UpdateLocation((string)newValue); }); story.ObserveVariable("background", (string varName, object newValue) => { LabelController.UpdateBackground((string)newValue); }); // Inventory story.ObserveVariable("money", (string varName, object newValue) => { InventoryController.UpdateMoneyQuantity((float)newValue); }); story.ObserveVariable("prepackagedMealCount", (string varName, object newValue) => { InventoryController.UpdatePrepackagedFoodQuantity((int)newValue); }); story.ObserveVariable("foodIngredientsCount", (string varName, object newValue) => { InventoryController.UpdateIngredientsSet((int)newValue); }); // Store story.ObserveVariable("storePrompt", (string varName, object newValue) => { StoreController.StoreState((int)newValue); }); story.ObserveVariable("purchaseResponse", (string varName, object newValue) => { StoreController.UpdatePurchaseResponse((string)newValue); }); // Conversation story.ObserveVariable("conversationActive", (string varName, object newValue) => { ConversationToggle((int)newValue); }); story.ObserveVariable("relationshipWithPlayer", (string varName, object newValue) => { UpdateRelationships((int)newValue); }); // ------------------ External Functions story.BindExternalFunction("EndGame", () => EndGame()); story.BindExternalFunction("UpdateNPCs", () => UpdateNPCs()); // ------------------ Font Options userFont = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as TMP_FontAsset; storyText.fontSize = userFontSize; storyText.font = userFont; // ------------------ Start Loop StoryLoop(); }
private void AddFunctions(Story story) { var vars = story.variablesState; if (vars.HasVariable(GOBLIN_TRUST_VAR)) { vars[GOBLIN_TRUST_VAR] = GameManager.Instance.GoblinTrust; if (!story.IsVariableObserved(GOBLIN_TRUST_VAR)) { story.ObserveVariable(GOBLIN_TRUST_VAR, OnGoblinTrustValueChanged); } } const string HAS_ITEM_FUNCTION_NAME = "hasItem"; if (!_curStory.HasExternalFunctionBound(HAS_ITEM_FUNCTION_NAME)) { _curStory.BindExternalFunction(HAS_ITEM_FUNCTION_NAME, (string itemName) => { return(GameManager.Instance.Player.HasItem(GameManager.Instance.GetItem(itemName))); }); } const string REMOVE_ITEM_FUNCTION_NAME = "removeItem"; if (!_curStory.HasExternalFunctionBound(REMOVE_ITEM_FUNCTION_NAME)) { _curStory.BindExternalFunction(REMOVE_ITEM_FUNCTION_NAME, (string itemName) => { GameManager.Instance.Player.RemoveItem(GameManager.Instance.GetItem(itemName)); }); } const string ADD_ITEM_FUNCTION_NAME = "giveItem"; if (!_curStory.HasExternalFunctionBound(ADD_ITEM_FUNCTION_NAME)) { _curStory.BindExternalFunction(ADD_ITEM_FUNCTION_NAME, (string itemName) => { GameManager.Instance.Player.GiveItem(GameManager.Instance.GetItem(itemName)); }); } const string ACTIVATE_NPC = "enableNpc"; if (!_curStory.HasExternalFunctionBound(ACTIVATE_NPC)) { _curStory.BindExternalFunction(ACTIVATE_NPC, (string who, string where, bool value) => { GameManager.Instance.EnableNpc(who, where, value); }); } const string END = "endGame"; if (!_curStory.HasExternalFunctionBound(END)) { _curStory.BindExternalFunction(END, () => { Application.Quit(); }); } const string DESTROY_DIALOGUE_OWNER_FUNCTION_NAME = "destroyDialogueOwner"; if (!_curStory.HasExternalFunctionBound(DESTROY_DIALOGUE_OWNER_FUNCTION_NAME)) { _curStory.BindExternalFunction(DESTROY_DIALOGUE_OWNER_FUNCTION_NAME, () => { if (_dialogueOwner) { var destroyFoo = _dialogueOwner.GetComponent <DestroyController>(); if (destroyFoo) { destroyFoo.TriggerDestroy(); } else { Destroy(_dialogueOwner); } } }); } const string ACTIVATE_INTERACTABLE = "triggerInteractable"; if (!_curStory.HasExternalFunctionBound(ACTIVATE_INTERACTABLE)) { _curStory.BindExternalFunction(ACTIVATE_INTERACTABLE, (int id) => { if (_interactables.Count > id) { _interactables[id].Activate(GameManager.Instance.Player); } }); } }
private void SetExternalFunction() { story.BindExternalFunction("change_background", (string TAG) => ChangeBackground(TAG)); }
public override void Enter() { base.Enter(); currentPage = GameObject.Instantiate <Transform>(pagePrefab); currentPage.transform.SetParent(GameObject.Find("Game Canvas").transform, false); currentPage.transform.SetSiblingIndex(2); contentManager = currentPage.GetComponentInChildren <ContentManager>(); contentParent = contentManager.layoutGroup.transform; contentManager.enabled = true; //settingsButton.FadeIn(); if (storyJSON == null) { Debug.LogWarning("Drag a valid story JSON file into the StoryReader component."); enabled = false; } story = new Story(storyJSON.text); story.BindExternalFunction("getTime", () => { string currentTime; if (outsideOfTime) { return(timeText.text); } if (minuteTime < 10) { currentTime = hourTime + ":0" + minuteTime + "pm"; } else { currentTime = hourTime + ":" + minuteTime + "pm"; } return(currentTime); }); StartCoroutine(OnAdvanceStory()); story.ObserveVariable("insanity", (string varName, object newValue) => { Debug.Log("insanity changed to " + newValue); int newSanity = (int)newValue; #if UNITY_EDITOR GameObject.Find("Sanity").GetComponent <Text>().text = newSanity.ToString(); #endif if (newSanity > previousSanityValue) { // sanity increased Debug.Log("Play sanity increase audio"); AudioClipDatabase.Instance.PlaySanityIncrease(); if (sanityEffects.Count >= newSanity && previousSanityValue >= 0) { for (int i = previousSanityValue; i < newSanity; i++) { sanityEffects[i].ApplyEffect(); } } } else { // sanity decreased Debug.Log("Play sanity decrease audio"); AudioClipDatabase.Instance.PlaySanityDecrease(); if (sanityEffects.Count >= previousSanityValue && newSanity >= 0) { for (int i = newSanity; i < previousSanityValue; i++) { sanityEffects[i].RemoveEffect(); } } } previousSanityValue = newSanity; }); }
public void BindToStory() { currentStory.BindExternalFunction <string, bool>("setGUIVisible", (name, value) => { currentBindings.SetGUIVisible(name, value); return(true); }); currentStory.BindExternalFunction <string, float, float>("createObject", (objectName, x, y) => { return(currentBindings.CreateObject(objectName, x, y)); }); currentStory.BindExternalFunction <string, float, float>("lookAt", (objectName, x, y) => { currentBindings.LookAt(objectName, x, y); }); currentStory.BindExternalFunction <float, string>("setTimeout", (value, knot) => { currentBindings.SetTimeout(value, knot); return(true); }); currentStory.BindExternalFunction <string, bool>("useUnscaledTime", (objectName, value) => { currentBindings.UseUnscaledTime(objectName, value); return(true); }); currentStory.BindExternalFunction <float>("setTimeScale", (value) => { TimePause.SetUniformScale(value); return(true); }); currentStory.BindExternalFunction <bool>("setTextBoxVisible", (value) => { currentBindings.SetTextBoxVisible(value); return(true); }); currentStory.BindExternalFunction("getPlayerX", () => { GameObject gameObject = GameObject.FindWithTag("Player"); if (gameObject != null) { return(gameObject.transform.position.x); } else { return(0.0f); } }); currentStory.BindExternalFunction("getPlayerY", () => { GameObject gameObject = GameObject.FindWithTag("Player"); if (gameObject != null) { return(gameObject.transform.position.y); } else { return(0.0f); } }); currentStory.BindExternalFunction <string>("getCharacterX", (character) => { GameObject gameObject = currentBindings.GetObjectNamed(character); if (gameObject != null) { return(gameObject.transform.position.x); } else { return(0.0f); } }); currentStory.BindExternalFunction <string>("getCharacterY", (character) => { GameObject gameObject = currentBindings.GetObjectNamed(character); if (gameObject != null) { return(gameObject.transform.position.y); } else { return(0.0f); } }); currentStory.BindExternalFunction <string, string, string>("playCards", (playerName, returnTo, returnKnot) => { CardGameInitializer.PlayCards(playerName, returnTo, returnKnot); return(true); }); currentStory.BindExternalFunction <string>("showStore", (storeName) => { currentBindings.ShowStore(storeName); return(true); }); currentStory.BindExternalFunction <int, string>("useSpinner", (digits, name) => { currentBindings.UseSpinner(digits, name); return(true); }); }
void StartStory() { story = new Story(inkJSONAsset.text); story.BindExternalFunction("trunc", (float x) => { return(Mathf.FloorToInt(x)); }); RefreshView(); }
//TODO: optimize so that only needed functions bind //maybe make an array of functions and can call externally to bind //use this to bind all functions for now void BindFunctions() { story.BindExternalFunction("load_scene", (string scene) => { levelManager.LoadLevel(scene); }); }