public bool CheckCondition(MapEventCondition data, MapEvent pEventData, TriggerConditionType except, params object[] args) { switch (data.Type) { case TriggerConditionType.EnterRegion: case TriggerConditionType.InitRegion: case TriggerConditionType.LeaveRegion: { return(data.Type == except); } case TriggerConditionType.WaveIndex: case TriggerConditionType.WavesetEnd: { if (except == data.Type) { return((int)args[0] == data.Args.ToInt32()); } else { return(false); } } default: return(false); } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="conditionType"></param> /// <param name="actionType"></param> /// <param name="editor"></param> public Trigger(string name, TriggerConditionType conditionType, TriggerActionType actionType, string editor) { Name = name; ConditionType = conditionType; ActionType = actionType; Editor = editor; }
public int RegisterInlineTrigger(TriggerConditionType type, Action<State> response) { if (type == TriggerConditionType.Changed) return RegisterInlineTrigger(response, s_Changed); throw new ArgumentOutOfRangeException("Unsupported trigger condition type"); }
private void RunTriggersOfConditionType(TriggerConditionType conditionType) { DateTime dtNow = DateTime.Now; foreach (Trigger trigger in formTrigger.TriggerCollection) { if (!trigger.Active) { continue; } // Don't show the interface on startup if AutoStartFromCommandLine is enabled. if (ScreenCapture.AutoStartFromCommandLine && trigger.ConditionType == TriggerConditionType.ApplicationStartup && trigger.ActionType == TriggerActionType.ShowInterface) { continue; } if (trigger.ConditionType == conditionType) { DoTriggerAction(trigger); } } }
public static ITriggerCondition Create(TriggerConditionType type, Transform ownTransform, int param) { switch (type) { case TriggerConditionType.Always: return(new AlwaysTrueCondition()); case TriggerConditionType.Distance: return(new DistanceCondition(ownTransform, param)); default: return(null); } }
public void OnLoad(ConfigNode node, VesselTriggers triggerConfig) { bool dataFound = false; ConfigNode childNode = null; int nbItem = 0; TriggerConditionType conditionType = (TriggerConditionType)(-1); dataFound = node.TryGetValue(KEY_NB_CONDITIONS, ref nbItem); if (dataFound) { for (int i = 0; i < nbItem; i++) { TriggerCondition condition = null; dataFound = node.TryGetNode(KEY_PREF_CONDITION + i, ref childNode); if (dataFound) { dataFound = childNode.TryGetEnum <TriggerConditionType>("type", ref conditionType, (TriggerConditionType)(-1)); if (dataFound) { switch (conditionType) { case TriggerConditionType.Part: condition = new TriggerConditionPart(triggerConfig); break; case TriggerConditionType.Flight: condition = new TriggerConditionFlight(triggerConfig); break; case TriggerConditionType.Timer: condition = new TriggerConditionTimer(triggerConfig); break; default: break; } if (condition != null) { dataFound = ConfigNode.LoadObjectFromConfig(condition, childNode); if (dataFound) { _conditions.Add(condition); } } } } } } }
public override void Read(XmlNode os) { foreach (XmlNode current in XmlObject.GetChilds(os)) { switch (current.Name) { case "Type": this.Type = (TriggerConditionType)ReadInt(current); break; case "Args": this.Args = ReadString(current); break; } } }
public void ActiveEventsByCondition(TriggerConditionType type, params object[] args) { for (int i = 0; i < m_Data.Events.Count; i++) { MapEvent data = m_Data.Events[i]; if (m_HasActiveEvents.Contains(data) && data.Conditions2 == null) { continue; } int num = 0; for (int k = 0; k < data.Conditions1.Count; k++) { MapEventCondition pChild = data.Conditions1[k]; bool isTrigger = CheckCondition(pChild, data, type, args); if (isTrigger) { num++; } } bool active = false; switch (data.Relation1) { case ConditionRelationType.And: active = num >= data.Conditions1.Count; break; case ConditionRelationType.Or: active = num > 0; break; } if (active) { GameEntry.Level.StartMapEvent(data, this); if (!m_HasActiveEvents.Contains(data)) { m_HasActiveEvents.Add(data); } } } }
/// <summary> /// The constructor for the trigger condition. /// </summary> /// <param name="type">The type of the trigger condition.</param> /// <param name="description">The description of the trigger condition. This is a user-friendly version of the trigger condition type and can't be changed by the user.</param> public TriggerCondition(TriggerConditionType type, string description) { Type = type; Description = description; }
// Draw the property inside the given rect public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { AddSeparator(); // Using BeginProperty / EndProperty on the parent property means that // prefab override logic works on the entire property. EditorGUI.BeginProperty(position, label, property); float defaultWidth = EditorGUIUtility.labelWidth; SerializedProperty triggerCondition = property.FindPropertyRelative("triggerCondition"); SerializedProperty triggerThreshold = property.FindPropertyRelative("triggerThreshold"); SerializedProperty useLocalCoordinates = property.FindPropertyRelative("useLocalCoordinates"); SerializedProperty allowTriggeringWhileInsideObject = property.FindPropertyRelative("allowTriggeringWhileInsideObject"); SerializedProperty targetDirection = property.FindPropertyRelative("targetDirection"); SerializedProperty targetObject = property.FindPropertyRelative("targetObject"); SerializedProperty targetRenderer = property.FindPropertyRelative("targetRenderer"); SerializedProperty targetPosition = property.FindPropertyRelative("targetPosition"); SerializedProperty targetLevels = property.FindPropertyRelative("targetLevels"); EditorGUILayout.PropertyField(triggerCondition); EditorGUILayout.Space(); TriggerConditionType currentTriggerCondition = (TriggerConditionType)Enum.GetValues(typeof(TriggerConditionType)).GetValue(triggerCondition.enumValueIndex); GUIContent directionLabel = new GUIContent("Target Direction:"); GUIContent objectLabel = new GUIContent("Target Object:"); GUIContent rendererLabel = new GUIContent("Target Object:"); GUIContent positionLabel = new GUIContent("Target Position:"); GUIContent thresholdLabel = new GUIContent("Trigger Threshold:"); GUIContent targetLevelsLabel = new GUIContent("Target level(s):"); GUIContent allowTriggeringInsideObjectLabel = new GUIContent("Allow triggering while inside of target object?"); GUIContent useLocalCoordinatesLabel = new GUIContent("Use local coordinates?"); switch (currentTriggerCondition) { case TriggerConditionType.PlayerFacingDirection: EditorGUILayout.PropertyField(triggerThreshold, thresholdLabel); EditorGUILayout.PropertyField(useLocalCoordinates, useLocalCoordinatesLabel); EditorGUILayout.PropertyField(targetDirection, directionLabel); break; case TriggerConditionType.PlayerFacingObject: case TriggerConditionType.PlayerFacingAwayFromObject: EditorGUILayout.PropertyField(triggerThreshold, thresholdLabel); EditorGUILayout.PropertyField(targetObject, objectLabel); EditorGUILayout.Space(); EditorGUIUtility.labelWidth = 300; EditorGUILayout.PropertyField(allowTriggeringWhileInsideObject, allowTriggeringInsideObjectLabel); EditorGUIUtility.labelWidth = defaultWidth; break; case TriggerConditionType.PlayerFacingPosition: case TriggerConditionType.PlayerFacingAwayFromPosition: EditorGUILayout.PropertyField(triggerThreshold, thresholdLabel); EditorGUILayout.PropertyField(targetPosition, positionLabel); break; case TriggerConditionType.PlayerMovingDirection: EditorGUILayout.PropertyField(triggerThreshold, thresholdLabel); EditorGUILayout.PropertyField(useLocalCoordinates, useLocalCoordinatesLabel); EditorGUILayout.PropertyField(targetDirection, directionLabel); break; case TriggerConditionType.RendererVisible: EditorGUILayout.PropertyField(targetRenderer, rendererLabel); break; case TriggerConditionType.RendererNotVisible: EditorGUILayout.PropertyField(targetRenderer, rendererLabel); break; case TriggerConditionType.PlayerInDirectionFromPoint: EditorGUILayout.PropertyField(triggerThreshold, thresholdLabel); EditorGUILayout.PropertyField(useLocalCoordinates, useLocalCoordinatesLabel); EditorGUILayout.PropertyField(targetPosition, positionLabel); EditorGUILayout.PropertyField(targetDirection, directionLabel); break; case TriggerConditionType.LevelsAreActive: EditorGUILayout.PropertyField(targetLevels, targetLevelsLabel); break; } EditorGUI.EndProperty(); EditorGUILayout.Space(); }
public TriggerCondition(TriggerCondition other) { _vesselTriggers = other._vesselTriggers; _type = (TriggerConditionType)(-1); _modified = false; }
public TriggerCondition(VesselTriggers vesselTriggers) { _vesselTriggers = vesselTriggers; _type = (TriggerConditionType)(-1); _modified = true; }
public override void OnInspectorGUI() { LevelEvent pElem = target as LevelEvent; MapTriggerType pType = (MapTriggerType)EditorGUILayout.EnumPopup("触发事件类型", pElem.Type); if (pType != pElem.Type) { pElem.Type = pType; pElem.SetName(); } int pTypeId = EditorGUILayout.IntField("触发事件类型ID", pElem.TypeId); if (pTypeId != pElem.TypeId) { pElem.TypeId = pTypeId; pElem.SetName(); } bool pActive = EditorGUILayout.Toggle("激活或者销毁", pElem.Active); if (pActive != pElem.Active) { pElem.Active = pActive; } ConditionRelationType pR1 = (ConditionRelationType)EditorGUILayout.EnumPopup("首次触发条件之间关系", pElem.Relation1); if (pR1 != pElem.Relation1) { pElem.Relation1 = pR1; } float pTriggerDelay = EditorGUILayout.FloatField("触发延迟", pElem.TriggerDelay); if (pElem.TriggerDelay != pTriggerDelay) { pElem.TriggerDelay = pTriggerDelay; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("首次触发条件"); if (UnityEngine.GUILayout.Button("添加")) { pElem.Conditions1.Add(new MapEventCondition()); } EditorGUILayout.EndHorizontal(); int pDeleteIndex1 = -1; for (int i = 0; i < pElem.Conditions1.Count; i++) { EditorGUILayout.Space(); EditorGUIUtility.labelWidth = 100; MapEventCondition data = pElem.Conditions1[i]; EditorGUILayout.LabelField("条件" + (i + 1)); EditorGUIUtility.labelWidth = 100; TriggerConditionType p = (TriggerConditionType)EditorGUILayout.EnumPopup("类型", data.Type); if (p != data.Type) { data.Type = p; } EditorGUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 100; string s = EditorGUILayout.TextField("参数", data.Args); if (s != data.Args) { data.Args = s; } if (UnityEngine.GUILayout.Button("删除")) { pDeleteIndex1 = i; } EditorGUILayout.EndHorizontal(); } if (pDeleteIndex1 >= 0) { pElem.Conditions1.RemoveAt(pDeleteIndex1); } EditorGUILayout.Space(); EditorGUILayout.Space(); bool pUseTriggerInterval = EditorGUILayout.Toggle("是否间隔触发", pElem.UseIntervalTrigger); if (pElem.UseIntervalTrigger != pUseTriggerInterval) { pElem.UseIntervalTrigger = pUseTriggerInterval; } if (pElem.UseIntervalTrigger == false) { return; } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("间隔触发条件"); if (UnityEngine.GUILayout.Button("添加")) { pElem.Conditions2.Add(new MapEventCondition()); } EditorGUILayout.EndHorizontal(); int pTriggerNum = EditorGUILayout.IntField("间隔触发次数(<=0代表无限)", pElem.TriggerNum); if (pElem.TriggerNum != pTriggerNum) { pElem.TriggerNum = pTriggerNum; } float pTriggerInterval = EditorGUILayout.FloatField("触发间隔时间", pElem.TriggerInterval); if (pElem.TriggerInterval != pTriggerInterval) { pElem.TriggerInterval = pTriggerInterval; } int pDeleteIndex2 = -1; for (int i = 0; i < pElem.Conditions2.Count; i++) { EditorGUILayout.Space(); MapEventCondition data = pElem.Conditions2[i]; TriggerConditionType p = (TriggerConditionType)EditorGUILayout.EnumPopup(GlobalTools.Format("条件{0}: 类型", i + 1), data.Type); if (p != data.Type) { data.Type = p; } string s = EditorGUILayout.TextField("参数", data.Args); if (s != data.Args) { data.Args = s; } if (UnityEngine.GUILayout.Button("删除")) { pDeleteIndex2 = i; } } if (pDeleteIndex2 >= 0) { pElem.Conditions2.RemoveAt(pDeleteIndex2); } }