private static void InitOpenDoorAction() { ActionRequirement openActionRequirement = (GameObject owner) => { var doorway = owner.GetComponent <LockedDoorway>(); if (PlayerInventory.Instance.GetItems().Any(item => item.ItemID == doorway.ItemToUnlock)) { return(true); } return(false); }; InteractiveAction action = (GameObject obj) => { var doorway = obj.GetComponent <LockedDoorway>(); PlayerInventory.Instance.RemoveItemFromInventory(doorway.ItemToUnlock); ProcessBarController.StartProcessWithCompletion(3f, doorway.Action.ActionImage, () => doorway.gameObject.SetActive(false), Color.yellow); }; var openDoorAction = new ActionBase(LockedDoorway.kOpenDoorActionId, openActionRequirement, action); _actions.Add(LockedDoorway.kOpenDoorActionId, openDoorAction); }
public Quest(string questId, string description, ActionRequirement requirement, InteractiveAction completion) { _questId = questId; _description = description; _requirement = requirement; _completion = completion; }
public ActionBase(string actionID, ActionRequirement requirement, InteractiveAction action) { _id = actionID; _requirement = requirement; _action = action; _actionImage = Resources.Load <Sprite> (kActionSpritesPath + actionID); }
public InteractiveObject[] GetFilteredInteractives(InteractiveAction interactiveCategory, InteractiveState?state = InteractiveState.None, bool?activeSkills = null, short[] skills = null) { return(m_interactives.Where( interactive => interactive.Action == interactiveCategory && (state == null || interactive.State == state) && (skills == null || (activeSkills != true && interactive.DisabledSkills.Select(skill => (short)skill.JobSkill.id).Intersect(skills).Any()) || (activeSkills != false && interactive.EnabledSkills.Select(skill => (short)skill.JobSkill.id).Intersect(skills).Any()))).ToArray()); }
private static void InitDialogueAction() { InteractiveAction action = (GameObject obj) => { var trigger = obj.GetComponent <DialogTrigger>(); var dialogue = DialogueStorage.GetDialogueByID(trigger.DialogueID); DialogueDisplayer.ShowDialogue(dialogue); }; var dialogueAction = new ActionBase("action.id.dialogue", (GameObject owner) => { return(true); }, action); _actions.Add("action.id.dialogue", dialogueAction); }
private static void InitVendorAction() { InteractiveAction action = (GameObject obj) => { var trigger = obj.GetComponent <VendorTrigger>(); var vendor = VendorsStorage.GetVendor(trigger.VendorID); TradeController.ShowTradeForVendor(vendor.Vendorid); }; var tradeAction = new ActionBase("action.id.trade", (GameObject owner) => { return(true); }, action); _actions.Add("action.id.trade", tradeAction); }
private static void InitContainerAction() { InteractiveAction action = (GameObject obj) => { ProcessBarController.StartProcessWithCompletion(3f * PlayerQuirks.GetSkill(EPlayerSkills.Scavanging), Resources.Load <Sprite>("Sprites/Actions/action.id.container"), () => { var container = obj.GetComponent <Container>(); ContainerUI.ShowForContainer(container); }, Color.green); }; var containerAction = new ActionBase("action.id.container", (GameObject owner) => { return(true); }, action); _actions.Add("action.id.container", containerAction); }
public void ProcessInteractiveActionCustomEvent(InteractiveAction i, bool stateEvent) { if (stateEvent) { if (i.trueEvent != null) { i.trueEvent.Invoke(); // Debug.Log("trueEvent"); } } else { if (i.falseEvent != null) { i.falseEvent.Invoke(); // Debug.Log("falseEvent"); } } }
private static void InitQuests() { ActionRequirement req = (GameObject owner) => { var containsitem = PlayerInventory.Instance.GetItems().Count(i => i.ItemID == "genericitem.id.toybear") > 0; return(containsitem); }; InteractiveAction action = (GameObject obj) => { var dialogue = DialogueStorage.GetDialogueByID("dialogue.id.thanks"); PlayerInventory.Instance.RemoveItemFromInventory("genericitem.id.toybear"); DialogueDisplayer.ShowDialogue(dialogue); }; var newQuest = new Quest("quest.id.gettovault", "Find your way to vault", req, action); _quests.Add(newQuest.ID, newQuest); }
public void ProcessInteractiveAction(InteractiveAction i) { if (lastNeedDisplayRoot != null) { lastNeedDisplayRoot.gameObject.SetActive(false); } if (i.cameraUniversal != null) { cameraUniversalCenter.ChangeCamera(i.cameraUniversal, 1); } if (i.cameraStates != "") { cameraUniversalCenter.currentCamera.SetCameraPositionAndXYZCount(i.cameraStates); } if (i.needDisplayRoot != null) { i.needDisplayRoot.gameObject.SetActive(true); lastNeedDisplayRoot = i.needDisplayRoot; } }
private int TryInteractiveAction(InteractiveAction interactiveAction, out bool continueInteraction) { int result = 1; // assume failure continueInteraction = false; try { result = interactiveAction(out continueInteraction); } catch (PythonSystemExit se) { return(se.GetExitCode(engineContext)); } catch (ThreadAbortException tae) { PythonKeyboardInterrupt pki = tae.ExceptionState as PythonKeyboardInterrupt; if (pki != null) { Thread.ResetAbort(); bool endOfMscorlib = false; DumpException(tae, ExceptionConverter.ToPython(pki), delegate(StackFrame sf) { // filter out mscorlib methods that show up on the stack initially, // for example ReadLine / ReadBuffer etc... if (!endOfMscorlib && sf.GetMethod().DeclaringType != null && sf.GetMethod().DeclaringType.Assembly == typeof(string).Assembly) { return(false); } endOfMscorlib = true; return(true); }); continueInteraction = true; } } catch (Exception e) { // There should be no unhandled exceptions in the interactive session // We catch all exceptions here, and just display it, // and keep on going DumpException(e); continueInteraction = true; } return(result); }
private static void InitHideAction() { ActionRequirement openActionRequirement = (GameObject owner) => { return(!PlayerQuirks.Attacked); }; InteractiveAction action = (GameObject obj) => { var doorway = obj.GetComponent <Hideout>(); ProcessBarController.StartProcessWithCompletion(1f, doorway.Action.ActionImage, () => { PlayerBehaviour.CurrentPlayer.Renderer.enabled = false; PlayerQuirks.Hidden = true; }, Color.grey); }; var openDoorAction = new ActionBase(Hideout.kHideAction, openActionRequirement, action); _actions.Add(Hideout.kHideAction, openDoorAction); }
private static void InitDragAction() { var undrag = new ActionBase("action.id.undrag", (GameObject obj) => { return(true); }, (GameObject obj) => { RopeDragController.Unbind(obj); PlayerQuirks.Drags = false; }); ActionRequirement openActionRequirement = (GameObject owner) => { return(PlayerInventory.Instance.GetItems().Any(i => i.ItemID == "genericitem.id.rope") && !PlayerQuirks.Drags); }; InteractiveAction action = (GameObject obj) => { ProcessBarController.StartProcessWithCompletion(3f * PlayerQuirks.GetSkill(EPlayerSkills.Hiding), Resources.Load <Sprite>("Sprites/Actions/action.id.drag"), () => { RopeDragController.Bind(obj); }, Color.yellow); }; var drag = new ActionBase("action.id.drag", openActionRequirement, action); _actions.Add(drag.ActionID, drag); _actions.Add(undrag.ActionID, undrag); }
public InteractiveActionControl(ActionContainerControl containerControl, InteractiveAction action) : this(containerControl) { this.action = action; }
string RecordInteractiveActionInfo(InteractiveAction inAct) { if (inAct.needDisplayRoot != null && inAct.needDisplayRoot.GetComponent <DontExport>() != null) { string log = inAct.needDisplayRoot.name + "被用在needDisplayRoot,且又含有DontExport"; GlobalDebug.Addline(log); Debug.Log(log); Debug.LogWarning(log); Debug.LogError(log); return(""); } string jsonString = "{"; //取得自定义的objectid jsonString += "\"gameObjectName\":\"" + (inAct.needDisplayRoot != null ? GetUTF16_2(inAct.needDisplayRoot.name) : "") + "\""; jsonString += ",\"needDisplayRoot\":" + (inAct.needDisplayRoot != null ? inAct.needDisplayRoot.GetComponent <Object3DInfo>().objectId:-1); jsonString += ",\"needSetCameraName\":\"" + (inAct.cameraUniversal != null?inAct.cameraUniversal.name + "\"":"\""); if (inAct.cameraUniversal != null) { string[] splitString = inAct.cameraStates.Split(','); if (splitString.Length != 6) { string log = inAct.ToString() + "CameraStates格式设置有错误!"; GlobalDebug.Addline(log); Debug.Log(log); Debug.LogWarning(log); Debug.LogError(log); return(""); } if (splitString[2] != "") { float zFloatTemp = float.Parse(splitString[2]); zFloatTemp = -zFloatTemp; splitString[2] = zFloatTemp.ToString(); } // if (splitString[5] != "") // splitString[5] = "-" + splitString[5]; jsonString += ",\"cameraStates\":["; jsonString += "\"" + splitString[0] + "\","; jsonString += "\"" + splitString[1] + "\","; jsonString += "\"" + splitString[2] + "\","; jsonString += "\"" + splitString[3] + "\","; jsonString += "\"" + splitString[4] + "\","; jsonString += "\"" + splitString[5] + "\"]"; } else { jsonString += ",\"cameraStates\":[]"; } if (inAct.pzMesh != null) { jsonString += ",\"pzMesh\":" + GetCollisonMeshJson(inAct.pzMesh); } jsonString += "}"; return(jsonString); }
private static async Task Version14Upgrade(int version, string filePath) { if (version < 14) { string data = File.ReadAllText(filePath); JObject dataJObj = JObject.Parse(data); if (dataJObj.ContainsKey("interactiveCommandsInternal")) { JArray interactiveCommands = (JArray)dataJObj["interactiveCommandsInternal"]; foreach (JToken interactiveCommand in interactiveCommands) { interactiveCommand["$type"] = "MixItUp.Base.Commands.InteractiveButtonCommand, MixItUp.Base"; } } data = SerializerHelper.SerializeToString(dataJObj); DesktopChannelSettings settings = SerializerHelper.DeserializeFromString <DesktopChannelSettings>(data); await ChannelSession.Services.Settings.Initialize(settings); List <PermissionsCommandBase> permissionCommands = new List <PermissionsCommandBase>(); permissionCommands.AddRange(settings.ChatCommands); permissionCommands.AddRange(settings.GameCommands); permissionCommands.AddRange(settings.InteractiveCommands); foreach (PermissionsCommandBase command in permissionCommands) { command.Requirements.Role.MixerRole = ConvertLegacyRoles(command.Requirements.Role.MixerRole); } List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.TimerCommands); commands.AddRange(settings.ActionGroupCommands); commands.AddRange(settings.GameCommands); commands.AddRange(settings.RemoteCommands); foreach (CommandBase command in commands) { foreach (ActionBase action in command.Actions) { if (action is InteractiveAction) { InteractiveAction iAction = (InteractiveAction)action; iAction.RoleRequirement = ConvertLegacyRoles(iAction.RoleRequirement); } } } foreach (PreMadeChatCommandSettings preMadeCommandSettings in settings.PreMadeChatCommandSettings) { preMadeCommandSettings.Permissions = ConvertLegacyRoles(preMadeCommandSettings.Permissions); } foreach (InteractiveUserGroupViewModel userGroup in settings.InteractiveUserGroups.Values.SelectMany(ug => ug)) { userGroup.AssociatedUserRole = ConvertLegacyRoles(userGroup.AssociatedUserRole); } foreach (GameCommandBase command in settings.GameCommands) { if (command is OutcomeGameCommandBase) { OutcomeGameCommandBase outcomeGame = (OutcomeGameCommandBase)command; foreach (GameOutcomeGroup group in outcomeGame.Groups) { group.Role = ConvertLegacyRoles(group.Role); } } } settings.ModerationFilteredWordsExcempt = ConvertLegacyRoles(settings.ModerationFilteredWordsExcempt); settings.ModerationChatTextExcempt = ConvertLegacyRoles(settings.ModerationChatTextExcempt); settings.ModerationBlockLinksExcempt = ConvertLegacyRoles(settings.ModerationBlockLinksExcempt); IEnumerable <InteractiveCommand> oldInteractiveCommand = settings.InteractiveCommands.ToList(); settings.InteractiveCommands.Clear(); foreach (InteractiveCommand command in oldInteractiveCommand) { settings.InteractiveCommands.Add(new InteractiveButtonCommand() { ID = command.ID, Name = command.Name, Type = command.Type, Commands = command.Commands, Actions = command.Actions, IsEnabled = command.IsEnabled, IsBasic = command.IsBasic, Unlocked = command.Unlocked, Requirements = command.Requirements, GameID = command.GameID, SceneID = command.SceneID, Control = command.Control, Trigger = EnumHelper.GetEnumValueFromString <InteractiveButtonCommandTriggerType>(command.CommandsString), }); } await ChannelSession.Services.Settings.Save(settings); } }
private static async Task Version5Upgrade(int version, string filePath) { if (version < 5) { LegacyDesktopChannelSettings legacySettings = await SerializerHelper.DeserializeFromFile <LegacyDesktopChannelSettings>(filePath); DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); foreach (string quote in legacySettings.quotesInternal) { settings.UserQuotes.Add(new UserQuoteViewModel(quote)); } List <CommandBase> commands = new List <CommandBase>(); commands.AddRange(settings.ChatCommands); commands.AddRange(settings.InteractiveCommands); commands.AddRange(settings.EventCommands); commands.AddRange(settings.TimerCommands); UserCurrencyViewModel currency = settings.Currencies.Values.FirstOrDefault(c => !c.IsRank); if (currency == null) { currency = settings.Currencies.Values.FirstOrDefault(); } foreach (CommandBase command in commands) { foreach (ActionBase action in command.Actions) { if (action is InteractiveAction) { InteractiveAction nAction = (InteractiveAction)action; #pragma warning disable CS0612 // Type or member is obsolete if (nAction.AddUserToGroup) { nAction.InteractiveType = InteractiveActionTypeEnum.MoveUserToGroup; } else { nAction.InteractiveType = InteractiveActionTypeEnum.MoveGroupToScene; } nAction.SceneID = nAction.MoveGroupToScene; #pragma warning restore CS0612 // Type or member is obsolete } if (currency != null) { if (action is ChatAction) { ChatAction nAction = (ChatAction)action; nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name); } else if (action is CurrencyAction) { CurrencyAction nAction = (CurrencyAction)action; nAction.ChatText = nAction.ChatText.Replace("$usercurrencyname", currency.Name); } else if (action is OBSStudioAction) { OBSStudioAction nAction = (OBSStudioAction)action; if (!string.IsNullOrEmpty(nAction.SourceText)) { nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name); } } else if (action is OverlayAction) { OverlayAction nAction = (OverlayAction)action; if (!string.IsNullOrEmpty(nAction.Text)) { nAction.Text = nAction.Text.Replace("$usercurrencyname", currency.Name); } } else if (action is TextToSpeechAction) { TextToSpeechAction nAction = (TextToSpeechAction)action; nAction.SpeechText = nAction.SpeechText.Replace("$usercurrencyname", currency.Name); } else if (action is XSplitAction) { XSplitAction nAction = (XSplitAction)action; if (!string.IsNullOrEmpty(nAction.SourceText)) { nAction.SourceText = nAction.SourceText.Replace("$usercurrencyname", currency.Name); } } } } } foreach (GameCommandBase game in settings.GameCommands) { if (game is IndividualProbabilityGameCommand) { IndividualProbabilityGameCommand individualGame = (IndividualProbabilityGameCommand)game; DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.UserJoinedCommand); DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(individualGame.LoseLeftoverCommand); foreach (GameOutcome outcome in individualGame.Outcomes) { DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(outcome.ResultCommand); } } else if (game is OnlyOneWinnerGameCommand) { OnlyOneWinnerGameCommand oneWinnerGame = (OnlyOneWinnerGameCommand)game; DesktopSettingsUpgrader.SetAllGameChatActionsToWhispers(oneWinnerGame.UserJoinedCommand); } } await ChannelSession.Services.Settings.Save(settings); } }
public override ActionBase GetAction() { if (this.TypeComboBox.SelectedIndex >= 0) { InteractiveActionTypeEnum interactiveType = EnumHelper.GetEnumValueFromString <InteractiveActionTypeEnum>((string)this.TypeComboBox.SelectedItem); if (interactiveType == InteractiveActionTypeEnum.MoveUserToGroup && !string.IsNullOrEmpty(this.MoveUserToGroupGroupNameTextBox.Text) && this.MoveUserToGroupPermissionsAllowedComboBox.SelectedIndex >= 0) { return(InteractiveAction.CreateMoveUserToGroupAction(this.MoveUserToGroupGroupNameTextBox.Text, EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.MoveUserToGroupPermissionsAllowedComboBox.SelectedItem), this.MoveUserToGroupUserNameTextBox.Text)); } else if (interactiveType == InteractiveActionTypeEnum.MoveUserToScene && this.MoveUserToScenePermissionsAllowedComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.MoveUserToSceneSceneIDTextBox.Text)) { return(InteractiveAction.CreateMoveUserToSceneAction(this.MoveUserToSceneSceneIDTextBox.Text, EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.MoveUserToScenePermissionsAllowedComboBox.SelectedItem), this.MoveUserToSceneUserNameTextBox.Text)); } else if (interactiveType == InteractiveActionTypeEnum.MoveGroupToScene && !string.IsNullOrEmpty(this.MoveGroupToSceneGroupNameTextBox.Text) && !string.IsNullOrEmpty(this.MoveGroupToSceneSceneIDTextBox.Text)) { return(InteractiveAction.CreateMoveGroupToSceneAction(this.MoveGroupToSceneGroupNameTextBox.Text, this.MoveGroupToSceneSceneIDTextBox.Text)); } else if (interactiveType == InteractiveActionTypeEnum.MoveAllUsersToGroup && !string.IsNullOrEmpty(this.MoveAllUsersToGroupGroupNameTextBox.Text)) { return(InteractiveAction.CreateMoveAllUsersToGroupAction(this.MoveAllUsersToGroupGroupNameTextBox.Text, EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.MoveAllUsersToGroupPermissionsAllowedComboBox.SelectedItem))); } else if (interactiveType == InteractiveActionTypeEnum.MoveAllUsersToScene && !string.IsNullOrEmpty(this.MoveAllUsersToSceneSceneNameTextBox.Text)) { return(InteractiveAction.CreateMoveAllUsersToSceneAction(this.MoveAllUsersToSceneSceneNameTextBox.Text, EnumHelper.GetEnumValueFromString <MixerRoleEnum>((string)this.MoveAllUsersToScenePermissionsAllowedComboBox.SelectedItem))); } else if (interactiveType == InteractiveActionTypeEnum.CooldownButton || interactiveType == InteractiveActionTypeEnum.CooldownGroup || interactiveType == InteractiveActionTypeEnum.CooldownScene) { if (!string.IsNullOrEmpty(this.CooldownNameTextBox.Text) && int.TryParse(this.CooldownAmountTextBox.Text, out int cooldownAmount) && cooldownAmount > 0) { return(InteractiveAction.CreateCooldownAction(interactiveType, this.CooldownNameTextBox.Text, cooldownAmount)); } } else if (interactiveType == InteractiveActionTypeEnum.Connect) { if (this.GameComboBox.SelectedIndex >= 0) { InteractiveGameModel game = (InteractiveGameModel)this.GameComboBox.SelectedItem; return(InteractiveAction.CreateConnectAction(game)); } } else if (interactiveType == InteractiveActionTypeEnum.Disconnect) { return(new InteractiveAction(interactiveType)); } else if (interactiveType == InteractiveActionTypeEnum.UpdateControl) { if (!string.IsNullOrEmpty(this.UpdateControlNameTextBox.Text) && this.UpdateControlTypeComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.UpdateControlValueTextBox.Text)) { return(InteractiveAction.CreateUpdateControlAction( EnumHelper.GetEnumValueFromString <InteractiveActionUpdateControlTypeEnum>((string)this.UpdateControlTypeComboBox.SelectedItem), this.UpdateControlNameTextBox.Text, this.UpdateControlValueTextBox.Text)); } } else if (interactiveType == InteractiveActionTypeEnum.SetCustomMetadata) { if (!string.IsNullOrEmpty(this.CustomMetadataControlIDTextBox.Text) && this.customMetadataPairs.Count > 0) { foreach (CustomMetadataPair pair in this.customMetadataPairs) { if (string.IsNullOrEmpty(pair.Name) || string.IsNullOrEmpty(pair.Value)) { return(null); } } return(InteractiveAction.CreateSetCustomMetadataAction(this.CustomMetadataControlIDTextBox.Text, this.customMetadataPairs.ToDictionary(p => p.Name, p => p.Value))); } } else if (interactiveType == InteractiveActionTypeEnum.EnableDisableControl) { if (!string.IsNullOrEmpty(this.EnableDisableControlNameTextBox.Text)) { return(InteractiveAction.CreateEnableDisableControlAction(this.EnableDisableControlNameTextBox.Text, this.EnableDisableControlToggleButton.IsChecked.GetValueOrDefault())); } } } return(null); }