private void TriggerIfStateMatches() { if (KickStarter.stateHandler.gameState == gameState && actionListAsset != null && !KickStarter.actionListAssetManager.IsListRunning(actionListAsset)) { AdvGame.RunActionListAsset(actionListAsset); } }
public void ClickOutput(AC.Menu _menu, MouseState _mouseState) { if (items.Count > 0) { if (_mouseState == MouseState.SingleClick) { if (KickStarter.runtimeInventory.selectedItem == null) { // Pick up created item if (activeRecipe.onCreateRecipe == OnCreateRecipe.SelectItem) { KickStarter.runtimeInventory.PerformCrafting(activeRecipe, true); } else if (activeRecipe.onCreateRecipe == OnCreateRecipe.RunActionList) { KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false); if (activeRecipe.invActionList != null) { AdvGame.RunActionListAsset(activeRecipe.invActionList); } } else { KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false); } } } PlayerMenus.ResetInventoryBoxes(); } }
private bool ClickOutput(AC.Menu _menu, MouseState _mouseState) { if (invInstances.Count > 0) { if (_mouseState == MouseState.SingleClick && !InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance)) { // Pick up created item switch (activeRecipe.onCreateRecipe) { case OnCreateRecipe.SelectItem: KickStarter.runtimeInventory.PerformCrafting(activeRecipe, true); break; case OnCreateRecipe.JustMoveToInventory: KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false); break; case OnCreateRecipe.RunActionList: KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false); if (activeRecipe.invActionList) { AdvGame.RunActionListAsset(activeRecipe.invActionList); } break; default: break; } return(true); } } return(false); }
/** * <summary>Runs the ActionListAsset defined in SettingsManager's actionListOnStart when the game begins.</summary> * <returns>True if an ActionListAsset was run</returns> */ public bool PlayGlobalOnStart() { if (runAtLeastOnce) { return(false); } runAtLeastOnce = true; ActiveInput.Upgrade(); if (KickStarter.settingsManager.activeInputs != null) { foreach (ActiveInput activeInput in KickStarter.settingsManager.activeInputs) { activeInput.SetDefaultState(); } } if (gameState != GameState.Paused) { // Fix for audio pausing on start AudioListener.pause = false; } if (KickStarter.settingsManager.actionListOnStart) { AdvGame.RunActionListAsset(KickStarter.settingsManager.actionListOnStart); return(true); } return(false); }
/** * <summary>Creates and displays the correct InvItem, based on the current Recipe, provided craftingType = CraftingElementType.Output.</summary> */ public void SetOutput() { if (craftingType != CraftingElementType.Output) { return; } invInstances = new List <InvInstance>(); activeRecipe = KickStarter.runtimeInventory.CalculateRecipe(); if (activeRecipe != null) { AdvGame.RunActionListAsset(activeRecipe.actionListOnCreate); foreach (InvItem assetItem in AdvGame.GetReferences().inventoryManager.items) { if (assetItem.id == activeRecipe.resultID) { invInstances.Add(new InvInstance(assetItem, 1)); } } KickStarter.eventManager.Call_OnCraftingSucceed(activeRecipe); } else { if (!autoCreate && actionListOnWrongIngredients) { actionListOnWrongIngredients.Interact(); } } }
/** * <summary>Creates and displays the correct InvItem, based on the current Recipe, provided craftingType = CraftingElementType.Output.</summary> * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param> * <param name = "autoCreate">If True, then the Recipe must also have autoCreate = True for the InvItem to appear</param> */ public void SetOutput(MenuSource source, bool autoCreate) { if (craftingType != CraftingElementType.Output) { return; } items = new List <InvItem>(); activeRecipe = KickStarter.runtimeInventory.CalculateRecipe(autoCreate); if (activeRecipe != null) { AdvGame.RunActionListAsset(activeRecipe.actionListOnCreate); // foreach (InvItem assetItem in AdvGame.GetReferences().inventoryManager.items) { if (assetItem.id == activeRecipe.resultID) { InvItem newItem = new InvItem(assetItem); newItem.count = 1; items.Add(newItem); } } } if (!autoCreate) { base.RecalculateSize(source); } }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } base.ProcessClick(_menu, _slot, _mouseState); if (uiToggle != null) { isOn = uiToggle.isOn; } else { if (isOn) { isOn = false; } else { isOn = true; } } if (toggleType == AC_ToggleType.Subtitles) { Options.optionsData.showSubtitles = isOn; Options.SavePrefs(); } else if (toggleType == AC_ToggleType.Variable) { if (varID >= 0) { GVar var = RuntimeVariables.GetVariable(varID); if (var.type == VariableType.Boolean) { if (isOn) { var.val = 1; } else { var.val = 0; } var.Upload(); } } } if (toggleType == AC_ToggleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } }
/** * <summary>Recalculates the element's size. * This should be called whenever a Menu's shape is changed.</summary> * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } if (uiToggle != null) { isOn = uiToggle.isOn; } else { if (isOn) { isOn = false; } else { isOn = true; } } if (toggleType == AC_ToggleType.Subtitles) { Options.SetSubtitles(isOn); } else if (toggleType == AC_ToggleType.Variable) { if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Boolean) { if (isOn) { var.val = 1; } else { var.val = 0; } var.Upload(VariableLocation.Global); } } } if (toggleType == AC_ToggleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } base.ProcessClick(_menu, _slot, _mouseState); }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">The index number of ths slot that was clicked</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } base.ProcessClick(_menu, _slot, _mouseState); bool isSuccess = true; if (saveListType == AC_SaveListType.Save && autoHandle) { if (newSaveSlot && _slot == (numSlots - 1)) { isSuccess = SaveSystem.SaveNewGame(); if (KickStarter.settingsManager.orderSavesByUpdateTime) { offset = 0; } else { Shift(AC_ShiftInventory.ShiftRight, 1); } } else { isSuccess = SaveSystem.SaveGame(_slot + offset, optionToShow, fixedOption); } } else if (saveListType == AC_SaveListType.Load && autoHandle) { isSuccess = SaveSystem.LoadGame(_slot + offset, optionToShow, fixedOption); } else if (saveListType == AC_SaveListType.Import) { isSuccess = SaveSystem.ImportGame(_slot + offset, optionToShow, fixedOption); } if (isSuccess) { if (saveListType == AC_SaveListType.Save) { _menu.TurnOff(true); } else if (saveListType == AC_SaveListType.Load) { _menu.TurnOff(false); } AdvGame.RunActionListAsset(actionListOnSave, parameterID, _slot); } else if (!autoHandle && saveListType != AC_SaveListType.Import) { AdvGame.RunActionListAsset(actionListOnSave, parameterID, _slot); } }
private void RunOption(ButtonDialog _option) { _option.hasBeenChosen = true; if (options.Contains(_option)) { lastOption = options.IndexOf(_option); if (KickStarter.actionListManager.OverrideConversation(lastOption)) { return; } lastOption = -1; } Conversation endConversation; if (_option.conversationAction == ConversationAction.ReturnToConversation) { endConversation = this; } else if (_option.conversationAction == ConversationAction.RunOtherConversation && _option.newConversation != null) { endConversation = _option.newConversation; } else { endConversation = null; } if (interactionSource == InteractionSource.AssetFile && _option.assetFile) { AdvGame.RunActionListAsset(_option.assetFile, endConversation); } else if (interactionSource == InteractionSource.CustomScript) { if (_option.customScriptObject != null && _option.customScriptFunction != "") { _option.customScriptObject.SendMessage(_option.customScriptFunction); } } else if (interactionSource == InteractionSource.InScene && _option.dialogueOption) { _option.dialogueOption.conversation = endConversation; _option.dialogueOption.Interact(); } else { ACDebug.Log("No Interaction object found!"); if (endConversation != null) { endConversation.Interact(); } else { KickStarter.stateHandler.gameState = GameState.Normal; } } }
protected bool TriggerIfStateMatches() { if (KickStarter.stateHandler.gameState == gameState && actionListAsset && !KickStarter.actionListAssetManager.IsListRunning(actionListAsset)) { AdvGame.RunActionListAsset(actionListAsset); return(true); } return(false); }
private void ProcessActionEnd(ActionEnd actionEnd, int i) { if (actionEnd.resultAction == ResultAction.RunCutscene) { if (actionEnd.linkedAsset != null) { if (isSkipping) { AdvGame.SkipActionListAsset(actionEnd.linkedAsset); } else { AdvGame.RunActionListAsset(actionEnd.linkedAsset, 0, !IsSkippable()); } CheckEndCutscene(); } else if (actionEnd.linkedCutscene != null) { if (actionEnd.linkedCutscene != this) { if (isSkipping) { actionEnd.linkedCutscene.Skip(); } else { actionEnd.linkedCutscene.Interact(0, !IsSkippable()); } CheckEndCutscene(); } else { if (triggerTime > 0f) { Kill(); StartCoroutine("PauseUntilStart", !IsSkippable()); } else { ProcessAction(0); } } } } else if (actionEnd.resultAction == ResultAction.Stop) { CheckEndCutscene(); } else if (actionEnd.resultAction == ResultAction.Skip) { ProcessAction(actionEnd.skipAction); } else if (actionEnd.resultAction == ResultAction.Continue) { ProcessAction(i + 1); } }
public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return(false); } if (uiToggle) { isOn = uiToggle.isOn; } else { if (isOn) { isOn = false; } else { isOn = true; } } switch (toggleType) { case AC_ToggleType.Subtitles: Options.SetSubtitles(isOn); break; case AC_ToggleType.Variable: if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Boolean) { var.IntegerValue = (isOn) ? 1 : 0; var.Upload(VariableLocation.Global); } } break; case AC_ToggleType.CustomScript: MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); break; default: break; } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } return(base.ProcessClick(_menu, _slot, _mouseState)); }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } bool isSuccess = true; if (saveListType == AC_SaveListType.Save) { if (newSaveSlot && _slot == (numSlots - 1)) { SaveSystem.SaveNewGame(); } else { SaveSystem.SaveGame(_slot, optionToShow, fixedOption); } } else if (saveListType == AC_SaveListType.Load) { if (fixedOption && newSaveSlot) { isSuccess = false; } else { isSuccess = SaveSystem.LoadGame(_slot, optionToShow, fixedOption); } } else if (saveListType == AC_SaveListType.Import) { if (fixedOption && newSaveSlot) { isSuccess = false; } else { isSuccess = SaveSystem.ImportGame(_slot, optionToShow, fixedOption); } } if (isSuccess) { if (saveListType == AC_SaveListType.Save) { _menu.TurnOff(true); } else if (saveListType == AC_SaveListType.Load) { _menu.TurnOff(false); } AdvGame.RunActionListAsset(actionListOnSave); } }
private void RunActionList(int _slot) { if (fixedOption) { AdvGame.RunActionListAsset(actionListOnSave, parameterID, optionToShow); } else { AdvGame.RunActionListAsset(actionListOnSave, parameterID, _slot + offset); } }
public void Look(InvItem item) { if (item == null || item.recipeSlot > -1) { return; } if (item.lookActionList) { AdvGame.RunActionListAsset(item.lookActionList); } }
public void Resume() { if (actionListAsset != null) { // Destroy old list, but don't go through ActionListManager's Reset code, to bypass changing GameState etc KickStarter.actionListManager.DestroyAssetList(actionListAsset); actionList = AdvGame.RunActionListAsset(actionListAsset, startIndex, true); } else if (actionList != null) { actionList.Interact(startIndex, true); } }
/** Runs an inventory item's "Examine" interaction */ public void Examine() { if (!IsValid(this)) { return; } if (InvItem.lookActionList) { KickStarter.eventManager.Call_OnUseInventory(this, KickStarter.cursorManager.lookCursor_ID); AdvGame.RunActionListAsset(InvItem.lookActionList); } }
/** * <summary>Adds a page to the journal.</summary> * <param name = "newPage">The page to add</param> * <param name = "onlyAddNew">If True, then the page will not be added if its lineID number matches that of any page already in the journal</param> * <param name = "index">The index number to insert the page into. A value of -1 will cause it to be added at the end.<param> */ public void AddPage(JournalPage newPage, bool onlyAddNew, int index = -1) { if (journalType == JournalType.DisplayExistingJournal) { ACDebug.LogWarning("The journal '" + title + "' cannot be added to - instead its linked journal (" + otherJournalTitle + ") must be modified instead."); return; } if (journalType == JournalType.DisplayActiveDocument) { ACDebug.LogWarning("The journal '" + title + "' cannot be added to."); return; } if (onlyAddNew && newPage.lineID >= 0 && pages != null && pages.Count > 0) { // Check for existing to avoid duplicates foreach (JournalPage page in pages) { if (page.lineID == newPage.lineID) { return; } } } if (index == -1) { index = pages.Count; } if (index < 0 || index >= pages.Count) { pages.Add(newPage); index = pages.IndexOf(newPage); } else { pages.Insert(index, newPage); } if (showPage > index || showPage == 0) { showPage++; } KickStarter.eventManager.Call_OnModifyJournalPage(this, newPage, index, true); AdvGame.RunActionListAsset(actionListOnAddPage); }
private void UpdateValue() { if (uiSlider == null) { visualAmount = Mathf.Clamp(visualAmount, 0f, 1f); // Limit by steps if (numberOfSteps > 0) { visualAmount = Mathf.Round(visualAmount * numberOfSteps) / numberOfSteps; } amount = (visualAmount * (maxValue - minValue)) + minValue; } else { amount = visualAmount; } switch (sliderType) { case AC_SliderType.Speech: Options.SetSpeechVolume(amount); break; case AC_SliderType.Music: Options.SetMusicVolume(amount); break; case AC_SliderType.SFX: Options.SetSFXVolume(amount); break; case AC_SliderType.FloatVariable: if (varID >= 0) { GlobalVariables.SetFloatValue(varID, amount); } break; default: break; } if (!KickStarter.actionListAssetManager.IsListRunning(actionListOnChange)) { AdvGame.RunActionListAsset(actionListOnChange); } }
protected void OnEndConversation(Conversation conversation) { if (conversation == this && onFinishActiveList != null) { if (onFinishActiveList.actionListAsset) { onFinishActiveList.actionList = AdvGame.RunActionListAsset(onFinishActiveList.actionListAsset, onFinishActiveList.startIndex, true); } else if (onFinishActiveList.actionList) { onFinishActiveList.actionList.Interact(onFinishActiveList.startIndex, true); } } onFinishActiveList = null; }
public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (KickStarter.stateHandler.gameState == GameState.Cutscene) { return; } base.ProcessClick(_menu, _slot, _mouseState); bool isSuccess = KickStarter.options.SwitchProfileIfExists(_slot + offset, showActive); if (isSuccess) { AdvGame.RunActionListAsset(actionListOnClick); } }
public bool PlayGlobalOnStart() { if (playedGlobalOnStart) { return(false); } if (KickStarter.settingsManager.actionListOnStart) { AdvGame.RunActionListAsset(KickStarter.settingsManager.actionListOnStart); playedGlobalOnStart = true; return(true); } return(false); }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } base.ProcessClick(_menu, _slot, _mouseState); selected++; if (selected > optionsArray.Count - 1) { selected = 0; } if (cycleType == AC_CycleType.Language) { if (selected == 0 && KickStarter.speechManager.ignoreOriginalText && KickStarter.runtimeLanguages.Languages.Count > 1) { // Ignore original text by skipping to first language selected = 1; } Options.SetLanguage(selected); } else if (cycleType == AC_CycleType.Variable) { if (varID >= 0) { GVar var = GlobalVariables.GetVariable(varID); if (var.type == VariableType.Integer) { var.val = selected; var.Upload(); } } } if (cycleType == AC_CycleType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } if (actionListOnClick) { AdvGame.RunActionListAsset(actionListOnClick); } }
/** * <summary>Runs an inventory item's interaction, when multiple "use" interactions are defined.</summary> * <param name = "iconID">The ID number of the interaction's icon, defined in CursorManager</param> */ public void Use(int iconID) { if (!IsValid(this)) { return; } if (KickStarter.stateHandler.gameState == GameState.DialogOptions && !KickStarter.settingsManager.allowInventoryInteractionsDuringConversations && !KickStarter.settingsManager.allowGameplayDuringConversations) { return; } foreach (InvInteraction interaction in InvItem.interactions) { if (interaction.icon.id == iconID) { if (interaction.actionList) { KickStarter.eventManager.Call_OnUseInventory(this, iconID); AdvGame.RunActionListAsset(interaction.actionList); return; } break; } } // Unhandled if (KickStarter.settingsManager.InventoryInteractions == InventoryInteractions.Multiple && KickStarter.settingsManager.CanSelectItems(false)) { // Auto-select if (KickStarter.settingsManager.selectInvWithUnhandled && iconID == KickStarter.settingsManager.selectInvWithIconID) { KickStarter.runtimeInventory.SelectItem(this, SelectItemMode.Use); return; } if (KickStarter.settingsManager.giveInvWithUnhandled && iconID == KickStarter.settingsManager.giveInvWithIconID) { KickStarter.runtimeInventory.SelectItem(this, SelectItemMode.Give); return; } } KickStarter.eventManager.Call_OnUseInventory(this, iconID); AdvGame.RunActionListAsset(KickStarter.cursorManager.GetUnhandledInteraction(iconID)); }
/** * <summary>Resumes a previously-paused ActionListAsset. If the ActionListAsset is already running, nothing will happen.</summary> * <param name = "actionListAsset">The ActionListAsset to pause</param> * <param name = "rerunPausedActions">If True, then any Actions that were midway-through running when the ActionList was paused will be restarted. Otherwise, the Actions that follow them will be reun instead.</param> */ public void Resume(ActionListAsset actionListAsset, bool rerunPausedActions) { if (IsListRunning(actionListAsset) && !actionListAsset.canRunMultipleInstances) { return; } bool foundInstance = false; for (int i = 0; i < activeLists.Count; i++) { if (activeLists[i].IsFor(actionListAsset)) { int numInstances = 0; foreach (ActiveList activeList in activeLists) { if (activeList.IsFor(actionListAsset) && activeList.IsRunning()) { numInstances++; } } GameObject runtimeActionListObject = (GameObject)Instantiate(Resources.Load(Resource.runtimeActionList)); runtimeActionListObject.name = actionListAsset.name; if (numInstances > 0) { runtimeActionListObject.name += " " + numInstances.ToString(); } RuntimeActionList runtimeActionList = runtimeActionListObject.GetComponent <RuntimeActionList>(); runtimeActionList.DownloadActions(actionListAsset, activeLists[i].GetConversationOnEnd(), activeLists[i].startIndex, false, activeLists[i].inSkipQueue, true); activeLists[i].Resume(runtimeActionList, rerunPausedActions); foundInstance = true; if (!actionListAsset.canRunMultipleInstances) { return; } } } if (!foundInstance) { ACDebug.LogWarning("No resume data found for '" + actionListAsset + "' - running from start.", actionListAsset); AdvGame.RunActionListAsset(actionListAsset); } }
public void Use(InvItem item) { if (item == null || item.recipeSlot > -1) { return; } if (item.useActionList) { selectedItem = null; AdvGame.RunActionListAsset(item.useActionList); } else if (KickStarter.settingsManager.CanSelectItems(true)) { SelectItem(item, SelectItemMode.Use); } }
/** * <summary>Attempts to resume a Conversation, if the associated ActionList overrides it's handling.</summary> * <returns>True if the ActionList was overriding a Conversation</returns> */ public bool ResumeConversationOverride() { if (isConversationOverride) { isConversationOverride = false; if (actionListAsset != null) { actionList = AdvGame.RunActionListAsset(actionListAsset, startIndex, true); } else if (actionList != null) { actionList.Interact(startIndex, true); } return(true); } return(false); }
/** * <summary>Resumes a previously-paused ActionListAsset. If the ActionListAsset is already running, nothing will happen.</summary> * <param name = "actionListAsset">The ActionListAsset to pause</param> */ public void Resume(ActionListAsset actionListAsset) { if (IsListRunning(actionListAsset)) { return; } for (int i = 0; i < activeLists.Count; i++) { if (activeLists[i].IsFor(actionListAsset)) { GameObject runtimeActionListObject = (GameObject)Instantiate(Resources.Load(Resource.runtimeActionList)); RuntimeActionList runtimeActionList = runtimeActionListObject.GetComponent <RuntimeActionList>(); runtimeActionList.DownloadActions(actionListAsset, activeLists[i].GetConversationOnEnd(), activeLists[i].startIndex, false, activeLists[i].inSkipQueue, true); activeLists[i].Resume(runtimeActionList); return; } } AdvGame.RunActionListAsset(actionListAsset); }
/** * <summary>Creates and displays the correct InvItem, based on the current Recipe, provided craftingType = CraftingElementType.Output.</summary> * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param> */ public void SetOutput(MenuSource source) { if (craftingType != CraftingElementType.Output) { return; } items = new List <InvItem>(); activeRecipe = KickStarter.runtimeInventory.CalculateRecipe(); if (activeRecipe != null) { AdvGame.RunActionListAsset(activeRecipe.actionListOnCreate); foreach (InvItem assetItem in AdvGame.GetReferences().inventoryManager.items) { if (assetItem.id == activeRecipe.resultID) { InvItem newItem = new InvItem(assetItem); newItem.count = 1; items.Add(newItem); } } KickStarter.eventManager.Call_OnCraftingSucceed(activeRecipe); } else { if (!autoCreate && actionListOnWrongIngredients != null) { actionListOnWrongIngredients.Interact(); } } /*if (!autoCreate) * { * base.RecalculateSize (source); * }*/ }