// public static List <TransitionInfo> GetTransitionPath(List <TransitionInfo> fromPath, List <TransitionInfo> toPath) { List <TransitionInfo> newPath = new List <TransitionInfo>(); int len = toPath.Count; // 同じScneControllerを探し、新しくPathを作成 for (int i = len - 1; i >= 0; i--) { TransitionInfo toScAndId = toPath[i]; SceneController toSceneController = toScAndId.controller; // for (int j = fromPath.Count - 1; j >= 0; j--) { TransitionInfo fromScAndId = fromPath[j]; SceneController fromSceneController = fromScAndId.controller; if (toSceneController == fromSceneController) { int from_index = j; int to_index = i; fromPath.RemoveRange(0, from_index + 1); fromPath.Reverse(); newPath.AddRange(fromPath); toPath.RemoveRange(0, to_index); newPath.AddRange(toPath); return(newPath); } } } return(null); }
public static void TransitionContent(List <TransitionInfo> toRootScenes, int index) { TransitionInfo setScene = toRootScenes [index]; SceneController controller = setScene.controller; int sceneId = setScene.sceneId; SceneController.TransitionHandler handler = null; handler = delegate(SceneBase s, SceneController.TransitionType transitionType) { if (transitionType == SceneController.TransitionType.OPEN_COMP) { controller.eventTransition -= handler; controller.isAutoTransition = false; index++; if (index < toRootScenes.Count) { TransitionContent(toRootScenes, index); } else { return; } } }; controller.eventTransition += handler; Debug.Log("Trans: " + controller + " / " + sceneId); controller.isAutoTransition = true; controller.TransitionScene(sceneId); }
private void Setup3DScene(TransitionInfo transitionInfo) { // Create the viewport that will host the 3D animation Viewport3D = new Viewport3D { IsHitTestVisible = false, ClipToBounds = false }; // Set up the camera Camera = CreateCamera(transitionInfo); Viewport3D.Camera = Camera; // Set up the light Light = CreateLight(transitionInfo); Viewport3D.Children.Add(Light); // Set up the 3D objects var objects = Create3DObjects(transitionInfo); objects.ForEach(m => Viewport3D.Children.Add(m)); transitionInfo.Scene.Children.Add(Viewport3D); // Hides views if (transitionInfo.BackView != null) { transitionInfo.BackView.Visibility = Visibility.Hidden; } if (transitionInfo.FrontView != null) { transitionInfo.FrontView.Visibility = Visibility.Hidden; } }
private Storyboard HideFrontViewAnimation(TransitionInfo transitionInfo) { var storyboard = new Storyboard(); var translateTransform = new TranslateTransform(); transitionInfo.SceneNameScope.RegisterName(AnimatedObjectName, translateTransform); transitionInfo.FrontView.RenderTransform = translateTransform; var slideAnimation = new DoubleAnimation { From = 0, To = -1 * transitionInfo.FrontView.ActualWidth, Duration = Duration, EasingFunction = new CubicEase() }; Storyboard.SetTargetName(slideAnimation, AnimatedObjectName); Storyboard.SetTargetProperty(slideAnimation, new PropertyPath(TranslateTransform.XProperty)); storyboard.Children.Add(slideAnimation); return(storyboard); }
/// <summary> /// Adds transition information to the object. /// Only used internally in <see cref="ITransitiontInfo.AddTo(GameObject)"/>. /// </summary> /// <param name="info">Transition informaion to add</param> /// <returns><see cref="TransitionResult"/> that contains the state of the transition</returns> public TransitionResult AddInfo(ITransitiontInfo info) { TransitionInfo information = new TransitionInfo(); information.info = info; TransitionResult result = new TransitionResult(); information.result = result; if (information.info.IsPhysics) { physicsInfos.Add(information); } else { nonphysicsInfos.Add(information); } if (!enabled) { enabled = true; } return(result); }
private void Start() { canvas.GetComponent <Canvas>().worldCamera = mainCamera; overlayCanvas.GetComponent <Canvas>().worldCamera = mainCamera; universalCanvas = GameObject.FindGameObjectWithTag("Canvas"); networkDiscovery = FindObjectOfType <NetworkDiscovery>(); gameManager = FindObjectOfType <GameManager>(); sceneChangeManager = FindObjectOfType <SceneChangeManager>(); transitionInfo = FindObjectOfType <TransitionInfo>(); audioManager = FindObjectOfType <AudioManager>(); infoPanel = FindObjectOfType <InfoPanel>(); x = gameManager.x; o = gameManager.o; ScaleUpFinished += ScaleDone; DotsScaleDownFinished += DisbaleDotsAndReset; ModifiedNetworkManager.OnServerDisconnected += ServerDisconnected; ModifiedNetworkManager.OnClientDisconnected += ClientDisconnected; }
/// <summary> /// </summary> /// <param name="inputData"></param> public void Enable(ICollection <Dictionary <string, object> > inputData) { RequireActivation(true); //TODO: validate the data if (inputData.Count == 0) { throw new TaskDataInvalidException(TaskId, InstanceId, "No input data for multi-instance task"); } this.Status = TaskStatus.Enabling; foreach (Dictionary <string, object> dob in inputData) { TransitionInfo ti = new TransitionInfo(); ti.Status = TransitionStatus.Enabling; ti.InstanceId = AllocateNewTaskInstanceId(TaskId); ChildTransitions.Add(ti); Context.EnableChildTask(new EnableChildTask { CorrelationId = ti.InstanceId, FromProcessInstanceId = this.ProcessInstanceId, FromTaskInstanceId = this.InstanceId, ToTaskInstanceId = ti.InstanceId, InputData = dob, ProcessDefinitionId = this.ProcessDefinitionId, TaskId = this.TaskId }); } }
private static void ParseEventHandler(CompositeActivity eventHandler, List <TransitionInfo> transitions) { Queue <Activity> processingQueue = new Queue <Activity>(); processingQueue.Enqueue(eventHandler); while (processingQueue.Count > 0) { Activity activity = processingQueue.Dequeue(); SetStateActivity setState = activity as SetStateActivity; if (setState != null) { TransitionInfo transitionInfo = new TransitionInfo(setState, eventHandler); transitions.Add(transitionInfo); } else { CompositeActivity compositeActivity = activity as CompositeActivity; if (compositeActivity != null) { foreach (Activity childActivity in compositeActivity.Activities) { processingQueue.Enqueue(childActivity); } } } } }
private void Handle(TaskEnabled message) { RequireActivation(true); TransitionInfo ti = GetTransition(message.FromTaskInstanceId); if (ti == null) { ti = GetTransition(message.CorrelationId); } if (ti == null) { throw new TaskRuntimeException("Child transition not found: " + message.CorrelationId).SetInstanceId(InstanceId); } if (ti.Status == TransitionStatus.Enabling) { log.Info("MT Child transition {0} has been enabled", ti.InstanceId); ti.Status = TransitionStatus.Enabled; if (ti.InstanceId != message.FromTaskInstanceId) { log.Info("Child task instance id changed {0}->{1}", ti.InstanceId, message.FromTaskInstanceId); ti.InstanceId = message.FromTaskInstanceId; } OnTransitionStatusChanged(ti.InstanceId); } else { log.Debug("Ignoring message: {0}", message); } }
public IEntityWorkflowTransition Transition(string commandName) { IEntityWorkflowTransition result = new TransitionInfo(commandName); _transitions.Add(result); return(result); }
public LayoutDrawElement(Location location, BitmapEx bitmap, TransitionInfo transitionInfo = default(TransitionInfo)) { Location = location; TransitionInfo = transitionInfo; BitmapRepresentation = new BitmapRepresentation(bitmap); bitmap.Dispose(); }
public static void ProcessAllTransitions(Animator animator, ProcessAnimatorTransition callback) { AnimatorController controller = GetInternalAnimatorController(animator); int layerCount = controller.layerCount; for (int layer = 0; layer < layerCount; layer++) { string layerName = controller.GetLayer(layer).name; UnityEditorInternal.StateMachine sm = controller.GetLayer(layer).stateMachine; //Handle anyState cases. see UnityEditorInternal.StateMachine.transitions { Transition[] anyTransitions = sm.GetTransitionsFromState(null); foreach (var t in anyTransitions) { TransitionInfo info = new TransitionInfo(t.uniqueNameHash, t.uniqueName, layer, layerName, 0, t.dstState.uniqueNameHash, t.atomic, t.duration, t.mute, t.offset, t.solo); callback(info); } } for (int i = 0; i < sm.stateCount; i++) { UnityEditorInternal.State state = sm.GetState(i); Transition[] transitions = sm.GetTransitionsFromState(state); foreach (var t in transitions) { // Debug.Log (state.uniqueName + ", transition: " + t.uniqueName + " ---" + " dest = " + t.dstState + " (" + (Animator.StringToHash (state.uniqueName) == Animator.StringToHash (layerName + "." + t.dstState)) + ") " + " src = " + t.srcState); TransitionInfo info = new TransitionInfo(t.uniqueNameHash, t.uniqueName, layer, layerName, t.srcState.uniqueNameHash, t.dstState.uniqueNameHash, t.atomic, t.duration, t.mute, t.offset, t.solo); callback(info); } } } }
protected override Camera CreateCamera(TransitionInfo transitionInfo) { var axisAngle = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0); transitionInfo.SceneNameScope.RegisterName(AnimatedObjectName, axisAngle); var camera = new PerspectiveCamera { LookDirection = new Vector3D(0, 0, -1), Transform = new RotateTransform3D(axisAngle) }; // Compute camera position const double fieldOfView = 30d; const double fieldOfViewRadian = (fieldOfView / 2d) * (Math.PI / 180f); var oppositeSideLength = transitionInfo.SceneWidth / 2d; var computedOppositeSideLength = oppositeSideLength * Math.Tan(fieldOfViewRadian) + oppositeSideLength; var cameraDistance = computedOppositeSideLength / Math.Tan(fieldOfViewRadian); camera.FieldOfView = fieldOfView; camera.Position = new Point3D(0, 0, cameraDistance); return(camera); }
protected override List <ModelVisual3D> Create3DObjects(TransitionInfo transitionInfo) { var initiallyVisibleView = transitionInfo.AnimationType == AnimationType.ShowFrontView ? transitionInfo.BackView : transitionInfo.FrontView; var initiallyInvisibleView = transitionInfo.AnimationType == AnimationType.ShowFrontView ? transitionInfo.FrontView : transitionInfo.BackView; return(new List <ModelVisual3D> { new ModelVisual3D { Content = new GeometryModel3D { Material = CreateInitiallyVisibleFaceMaterial(initiallyVisibleView), Geometry = CreateInitiallyVisibleFaceMesh(initiallyVisibleView) } }, new ModelVisual3D { Content = new GeometryModel3D { Material = CreateInitiallyInvisibleFaceMaterial(initiallyInvisibleView), Geometry = CreateInitiallyInvisibleFaceMesh(initiallyInvisibleView) } } }); }
// Start is called before the first frame update void Start() { transitionInfo = FindObjectOfType <TransitionInfo>(); if (transitionInfo == null) { Debug.LogWarning("TransitionInfo was not found!"); } if (transitionInfo.overrideParamaters) { return; } #region Startup in Some Scenes if ((transitionInfo.canceledHost || transitionInfo.returningFromWin) && SceneManager.GetActiveScene().name == "Main") { fadePanel.GetComponent <Image>().color = new Color(0f, 0f, 0f, 1f); fadePanel.SetActive(true); transitionInfo.Reset(); StartCoroutine(FadePanel(1)); } if (SceneManager.GetActiveScene().name.Equals("Win")) { fadePanel.GetComponent <Image>().color = new Color(0f, 0f, 0f, 1f); fadePanel.SetActive(true); StartCoroutine(FadePanel(2)); } #endregion }
private void OnPreviewAvatarChanged() { this.m_RefTransitionInfo = new TransitionInfo(); this.ClearController(); this.CreateController(); this.CreateParameterInfoList(); }
/// <summary> /// Starts the fade screen transition animation /// </summary> private void StartFadeAnimation(TransitionInfo transitionInfo, bool show, float duration) { float fromAlpha = show ? 0f : 1f; float toAlpha = show ? 1f : 0f; UIAnimation anim = UIAnimation.Alpha(gameObject, fromAlpha, toAlpha, duration); anim.style = transitionInfo.animationStyle; anim.animationCurve = transitionInfo.animationCurve; anim.startOnFirstFrame = true; if (!show) { anim.OnAnimationFinished = (GameObject obj) => { SetVisibility(false); }; } else { anim.OnAnimationFinished = null; } anim.Play(); }
private void AddEdge(XElement graph, TransitionInfo<TState, TEvent> transition) { string actions = CreateActionsDescription(transition); string guard = CreateGuardDescription(transition); string arrow; string lineStyle; string targetId; if (transition.Target != null) { arrow = "standard"; lineStyle = "line"; targetId = transition.Target.Id.ToString(); } else { arrow = "plain"; lineStyle = "dashed"; targetId = transition.Source.Id.ToString(); } var edge = new XElement( N + "edge", new XAttribute("id", transition.EventId + (this.edgeId++).ToString(CultureInfo.InvariantCulture)), new XAttribute("source", transition.Source.Id), new XAttribute("target", targetId)); edge.Add(new XElement( N + "data", new XAttribute("key", "d10"), new XElement(Y + "PolyLineEdge", new XElement(Y + "LineStyle", new XAttribute("type", lineStyle)), new XElement(Y + "Arrows", new XAttribute("source", "none"), new XAttribute("target", arrow)), new XElement(Y + "EdgeLabel", guard + transition.EventId + actions)))); graph.Add(edge); }
private void Handle(TaskCancelled message) { RequireActivation(true); if (message.ParentTaskInstanceId != this.InstanceId) { throw new Exception(); } TransitionInfo ti = GetTransition(message.FromTaskInstanceId); if (ti == null) { throw new Exception(); } lock (this) { log.Info("Child task {0} has been cancelled", ti.InstanceId); if (ti.Status == TransitionStatus.Cancelled) { return; } if (!ti.IsTransitionActive) { log.Warn("Transition {0} ({1}) is not active: {2}", ti.InstanceId, ti.TaskId, ti.Status); return; } ti.Status = TransitionStatus.Cancelled; OnTransitionStatusChanged(ti.InstanceId); return; } }
public bool IsEqual(TransitionInfo info) { return(m_SrcState == info.m_SrcState && m_DstState == info.m_DstState && Mathf.Approximately(m_TransitionDuration, info.m_TransitionDuration) && Mathf.Approximately(m_TransitionOffset, info.m_TransitionOffset) && Mathf.Approximately(m_ExitTime, info.m_ExitTime)); }
// Start is called before the first frame update void Start() { transitionInfo = FindObjectOfType <TransitionInfo>(); sceneChangeManager = FindObjectOfType <SceneChangeManager>(); aumanager = FindObjectOfType <AudioManager>(); networkDiscovery = FindObjectOfType <NetworkDiscovery>(); SceneChangeManager.OnStopHostingCancel += CancelAndStopHosting; }
public ITransitionInfo Create(IDictionary <string, object> transitionInfo) { var t = new TransitionInfo { Source = (string)transitionInfo["source"], Target = (string)transitionInfo["target"], Transition = (string)transitionInfo["transition"] }; return(t); }
private void start <TScene>(Color clearColor) where TScene : Scene, new() { var transition = new FadeTransition(() => Scene.createWithDefaultRenderer <TScene>(clearColor)) { delayBeforeFadeInDuration = 0, fadeOutDuration = duration, fadeInDuration = duration, fadeToColor = clearColor }; var next = new TransitionInfo(transition, typeof(TScene)); this.enqueue(next); }
private void ProcessEvents(Event current) { switch (current.type) { case EventType.MouseDown: bool transitionSelected = false; foreach (var item in _transitionRectList) { if (item.Rect.Contains(current.mousePosition - new Vector2(0, _menuAreaRect.height) + _scrollPositon)) { transitionSelected = true; _selectedTransition = item; if (_selectedNode != null) { _selectedNode.IsSelected = false; _selectedNode = null; } GUI.changed = true; break; } } switch (current.button) { case 1: if (_selectedNode == null) { if (transitionSelected) { _selectedTransitionContextMenu.ShowAsContext(); } else { _addStateContextMenu.ShowAsContext(); } } else { _selectedNodeContextMenu.ShowAsContext(); } break; } _currentMousePossition = current.mousePosition; break; case EventType.MouseDrag: if (current.button == 2) { _scrollPositon -= current.delta; Repaint(); } break; } }
public void SetTransition(AnimatorStateTransition transition, AnimatorState sourceState, AnimatorState destinationState, AnimatorControllerLayer srcLayer, Animator previewObject) { this.m_RefSrcState = sourceState; this.m_RefDstState = destinationState; TransitionInfo info = new TransitionInfo(); info.Set(transition, sourceState, destinationState); if (this.MustResample(info)) { this.ResampleTransition(transition, srcLayer.avatarMask, info, previewObject); } }
public void AddTransitionFrom(TransitionInfo transitionInfo) { var source = StateNodeOf(transitionInfo.StateFrom); var target = StateNodeOf(transitionInfo.StateTo); var newTransition = new TransitionConnection(source, target, _builder.TriggerType, transitionInfo.Trigger, transitionInfo.GuardConditions); newTransition.OnTriggerChanged += (connection, previousTrigger, currentTrigger) => RecordAndRebuild(); newTransition.OnGuardConditionsChanged += (connection, currentGuardConditions) => RecordAndRebuild(); _transitions.Add(newTransition); }
void Start() { networkManager = FindObjectOfType <ModifiedNetworkManager>(); networkDiscovery = FindObjectOfType <NetworkDiscovery>(); transitionInfo = FindObjectOfType <TransitionInfo>(); sceneChangeManager = FindObjectOfType <SceneChangeManager>(); aumanager = FindObjectOfType <AudioManager>(); SceneChangeManager.OnStopHostingCancel += CancelAndStopHosting; LeanTween.scale(glass, new Vector3(1.1f, 1.1f, 1.1f), 2f).setEaseInOutSine().setLoopPingPong(); }
protected override Storyboard CreateAnimation(TransitionInfo transitionInfo) { var storyboard = new Storyboard(); Point3DAnimationUsingKeyFrames cameraPositionAnimation; DoubleAnimationUsingKeyFrames cameraRotationAnimation; // Camera distance animation cameraPositionAnimation = new Point3DAnimationUsingKeyFrames { Duration = Duration }; cameraPositionAnimation.KeyFrames.Add(new EasingPoint3DKeyFrame(_cameraInitialPosition, KeyTime.FromPercent(0))); cameraPositionAnimation.KeyFrames.Add(new EasingPoint3DKeyFrame(_cameraIntermediatePosition, KeyTime.FromPercent(0.25))); cameraPositionAnimation.KeyFrames.Add(new EasingPoint3DKeyFrame(_cameraIntermediatePosition, KeyTime.FromPercent(0.75))); cameraPositionAnimation.KeyFrames.Add(new EasingPoint3DKeyFrame(_cameraInitialPosition, KeyTime.FromPercent(1))); Storyboard.SetTargetName(cameraPositionAnimation, CameraObjectName); Storyboard.SetTargetProperty(cameraPositionAnimation, new PropertyPath(ProjectionCamera.PositionProperty)); // Flip animation switch (Direction) { case FlipDirection.LeftToRight: case FlipDirection.BottomToTop: cameraRotationAnimation = new DoubleAnimationUsingKeyFrames { Duration = Duration }; cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromPercent(0.25))); cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(-180, KeyTime.FromPercent(0.75))); cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(-180, KeyTime.FromPercent(1))); break; default: cameraRotationAnimation = new DoubleAnimationUsingKeyFrames { Duration = Duration }; cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromPercent(0.25))); cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(180, KeyTime.FromPercent(0.75))); cameraRotationAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(180, KeyTime.FromPercent(1))); break; } Storyboard.SetTargetName(cameraRotationAnimation, CameraRotationObjectName); Storyboard.SetTargetProperty(cameraRotationAnimation, new PropertyPath(AxisAngleRotation3D.AngleProperty)); storyboard.Children.Add(cameraPositionAnimation); storyboard.Children.Add(cameraRotationAnimation); return(storyboard); }
/// <summary> /// Adds a property to the schema. /// </summary> /// <param name="name"> The name of the property to add. </param> /// <param name="attributes"> The property attributes. </param> /// <returns> A new schema with the extra property. </returns> public HiddenClassSchema AddProperty(string name, PropertyAttributes attributes) { // Package the name and attributes into a struct. var transitionInfo = new TransitionInfo { Name = name, Attributes = attributes }; // Check if there is a transition to the schema already. HiddenClassSchema newSchema = null; if (this.m_addTransitions != null) { this.m_addTransitions.TryGetValue(transitionInfo, out newSchema); } if (newSchema == null) { if (this.m_parent == null) { // Create a new schema based on this one. A complete copy must be made of the properties hashtable. var properties = new Dictionary <string, SchemaProperty>(this.m_properties) { { name, new SchemaProperty(this.NextValueIndex, attributes) } }; newSchema = new HiddenClassSchema(properties, this.NextValueIndex + 1, this, transitionInfo); } else { // Create a new schema based on this one. The properties hashtable is "given // away" so a copy does not have to be made. if (this.m_properties == null) { this.m_properties = CreatePropertiesDictionary(); } this.m_properties.Add(name, new SchemaProperty(this.NextValueIndex, attributes)); newSchema = new HiddenClassSchema(this.m_properties, this.NextValueIndex + 1, this, transitionInfo); this.m_properties = null; } // Add a transition to the new schema. if (this.m_addTransitions == null) { this.m_addTransitions = new Dictionary <TransitionInfo, HiddenClassSchema>(1); } this.m_addTransitions.Add(transitionInfo, newSchema); } return(newSchema); }
/// <summary> /// 将 link 信息转化成 info 信息 /// </summary> /// <param name="link"></param> /// <returns></returns> public static TransitionInfo ExtractTransitionInfo(ActivityLink link) { TransitionInfo tranInfo = new TransitionInfo() { Key = link.Key, Name = link.Text, Enabled = link.WfEnabled, FromActivityKey = link.From, ToActivityKey = link.To, IsReturn = link.WfReturnLine }; return(tranInfo); }
private static void InvestigateDetails(FileInfo fileInfo, TextWriter trace, TimeSpan totalDuration) { using (var reader = fileInfo.OpenText()) { DateTime previousPointInTime = DateTime.Now; string previousLine = string.Empty; bool first = true; while (!reader.EndOfStream) { string line = reader.ReadLine().Trim(); if (line.Length > 22) { string pointInTime = line.Substring(2, 23); DateTime when = Convert.ToDateTime(pointInTime); TimeSpan duration = when - previousPointInTime; if (duration > maxOperationDuration) { trace.WriteLine(first ? fileInfo.FullName + " total: " + totalDuration.ToString() : "..."); trace.WriteLine(previousLine); trace.WriteLine(line); first = false; string sourceTransition = GetOperation(previousLine); string targetTransition = GetOperation(line); string transition = sourceTransition + " to " + targetTransition; if (transitionsCount.ContainsKey(transition)) { TransitionInfo prev = transitionsCount[transition]; transitionsCount[transition] = new TransitionInfo(prev.Count + 1, prev.Duration + duration); } else { transitionsCount.Add(transition, new TransitionInfo(1, duration)); } } previousLine = line; previousPointInTime = when; } } if (!first) { trace.WriteLine("-----------------------------------------------------------------------------------------------------------"); } } }
protected void GetTransitionList(ArrayList transitionList, IStateGlyph state) { // now find transitions foreach (IGlyph child in state.Children) { ITransitionContactPointGlyph transContactPoint = child as ITransitionContactPointGlyph; if (transContactPoint != null) { ITransitionGlyph trans = transContactPoint.Owner as ITransitionGlyph; if (transContactPoint.WhichEnd == TransitionContactEnd.From) { // this is a from transition ITransitionContactPointGlyph transTo = null; foreach (ITransitionContactPointGlyph contactPoint in trans.ContactPoints) { if (contactPoint.WhichEnd == TransitionContactEnd.To) { transTo = contactPoint; break; } } System.Diagnostics.Debug.Assert (transTo != null, "Transition To Contact Point not found"); IStateGlyph toStateGlyph = transTo.Parent as IStateGlyph; string toStateName = "TRANSITION_TOSTATE_NOT_SET"; if (toStateGlyph != null) { if (IsNotEmptyString (toStateGlyph.Name)) { toStateName = StateNameFrom (toStateGlyph); } else { toStateName = "TRANSITION_TOSTATE_SET_BUT_STATE_NOT_NAMED"; } } TransitionInfo info = new TransitionInfo (trans, StateNameFrom (state), toStateName, toStateGlyph); transitionList.Add (info); } } } }
protected void WriteLog(StateLogType logType, IStateGlyph state, TransitionInfo transitionInfo) { WriteLog(logType, state, transitionInfo, "s"); }
/// <summary> /// Запуск анимации ячейки. Пройдёт время и анимация закончится, не стоит об этом беспокоиться. /// Всё работу берёт на себя AnimationManager. /// </summary> /// <param name="cell">Шашечка, которая поедет в дальний край. Шашка официально должна находится на финальной позиции.</param> /// <param name="startPosition">Позиция, с которой начинается движение.</param> public void StartTransition( CellPlate cell, Rectangle startPosition) { TransitionInfo transition = transitionByCell[cell] as TransitionInfo; if (transition != null) { transition.InvalidateTransitionArea(); transitionByCell.Remove(cell); } transition = new TransitionInfo( cell, startPosition); transitionByCell[cell] = transition; UpdateTimer(); }
/// <summary> /// Modifies the attributes for a property in the schema. /// </summary> /// <param name="name"> The name of the property to modify. </param> /// <param name="attributes"> The new attributes. </param> /// <returns> A new schema with the modified property. </returns> public HiddenClassSchema SetPropertyAttributes(string name, PropertyAttributes attributes) { // Package the name and attributes into a struct. var transitionInfo = new TransitionInfo() { Name = name, Attributes = attributes }; // Check if there is a transition to the schema already. HiddenClassSchema newSchema = null; if (this.modifyTransitions != null) this.modifyTransitions.TryGetValue(transitionInfo, out newSchema); if (newSchema == null) { // Create the properties dictionary if it hasn't already been created. if (this.properties == null) this.properties = CreatePropertiesDictionary(); // Check the attributes differ from the existing attributes. SchemaProperty propertyInfo; if (this.properties.TryGetValue(name, out propertyInfo) == false) throw new InvalidOperationException(string.Format("The property '{0}' does not exist.", name)); if (attributes == propertyInfo.Attributes) return this; // Create a new schema based on this one. var properties = new Dictionary<string, SchemaProperty>(this.properties); properties[name] = new SchemaProperty(propertyInfo.Index, attributes); newSchema = new HiddenClassSchema(properties, this.NextValueIndex); // Add a transition to the new schema. if (this.modifyTransitions == null) this.modifyTransitions = new Dictionary<TransitionInfo, HiddenClassSchema>(1); this.modifyTransitions.Add(transitionInfo, newSchema); } return newSchema; }
/// <summary> /// Creates a new HiddenClassSchema instance from an add operation. /// </summary> private HiddenClassSchema(Dictionary<string, SchemaProperty> properties, int nextValueIndex, HiddenClassSchema parent, TransitionInfo addPropertyTransitionInfo) : this(properties, nextValueIndex) { this.parent = parent; this.addPropertyTransitionInfo = addPropertyTransitionInfo; }
protected void WriteLog(StateLogType logType, IStateGlyph state, TransitionInfo transitionInfo, string transitionFieldNamePrefix) { if (CanInstrument (state)) { string text = NormalisedTransitionDisplayText (transitionInfo); WriteLine ("LogStateEvent (StateLogType.{0}, s_{1}, {5}_{2}, \"{3}\", \"{4}\");", logType, StateNameFrom (state), transitionInfo.ToStateName, transitionInfo.Transition.QualifiedEvent, text, transitionFieldNamePrefix); } }
/// <summary> /// Adds a property to the schema. /// </summary> /// <param name="name"> The name of the property to add. </param> /// <param name="attributes"> The property attributes. </param> /// <returns> A new schema with the extra property. </returns> public HiddenClassSchema AddProperty(string name, PropertyAttributes attributes = PropertyAttributes.FullAccess) { // Package the name and attributes into a struct. var transitionInfo = new TransitionInfo() { Name = name, Attributes = attributes }; // Check if there is a transition to the schema already. HiddenClassSchema newSchema = null; if (this.addTransitions != null) this.addTransitions.TryGetValue(transitionInfo, out newSchema); if (newSchema == null) { if (this.parent == null) { // Create a new schema based on this one. A complete copy must be made of the properties hashtable. var properties = new Dictionary<string, SchemaProperty>(this.properties); properties.Add(name, new SchemaProperty(this.NextValueIndex, attributes)); newSchema = new HiddenClassSchema(properties, this.NextValueIndex + 1, this, transitionInfo); } else { // Create a new schema based on this one. The properties hashtable is "given // away" so a copy does not have to be made. if (this.properties == null) this.properties = CreatePropertiesDictionary(); this.properties.Add(name, new SchemaProperty(this.NextValueIndex, attributes)); newSchema = new HiddenClassSchema(this.properties, this.NextValueIndex + 1, this, transitionInfo); this.properties = null; } // Add a transition to the new schema. if (this.addTransitions == null) this.addTransitions = new Dictionary<TransitionInfo, HiddenClassSchema>(1); this.addTransitions.Add(transitionInfo, newSchema); } return newSchema; }
private bool MustResample(TransitionInfo info) { return (this.mustResample || !info.IsEqual(this.m_RefTransitionInfo)); }
protected string NormalisedTransitionDisplayText(TransitionInfo transitionInfo) { return NormalisedTransitionDisplayText (transitionInfo.Transition); }
private void ResampleTransition(AnimatorStateTransition transition, AvatarMask layerMask, TransitionInfo info, Animator previewObject) { this.m_IsResampling = true; this.m_MustResample = false; bool flag = this.m_RefTransition != transition; this.m_RefTransition = transition; this.m_RefTransitionInfo = info; this.m_LayerMask = layerMask; if (this.m_AvatarPreview != null) { this.m_AvatarPreview.OnDestroy(); this.m_AvatarPreview = null; } this.ClearController(); Motion motion = this.m_RefSrcState.motion; this.Init(previewObject, (motion == null) ? this.m_RefDstState.motion : motion); if (this.m_Controller != null) { this.m_AvatarPreview.Animator.allowConstantClipSamplingOptimization = false; this.m_StateMachine.defaultState = this.m_DstState; this.m_Transition.mute = true; AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_AvatarPreview.Animator.Update(1E-05f); this.WriteParametersInController(); this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f); float length = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length; this.m_StateMachine.defaultState = this.m_SrcState; this.m_Transition.mute = false; AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_AvatarPreview.Animator.Update(1E-05f); this.WriteParametersInController(); this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f); float num2 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length; if (this.m_LayerIndex > 0) { this.m_AvatarPreview.Animator.stabilizeFeet = false; } float num3 = ((num2 * this.m_RefTransition.exitTime) + (this.m_Transition.duration * (!this.m_RefTransition.hasFixedDuration ? num2 : 1f))) + length; if (num3 > 2000f) { Debug.LogWarning("Transition duration is longer than 2000 second, Disabling previewer."); this.m_ValidTransition = false; } else { float num4 = (this.m_RefTransition.exitTime <= 0f) ? num2 : (num2 * this.m_RefTransition.exitTime); float a = (num4 <= 0f) ? 0.03333334f : Mathf.Min(Mathf.Max((float) (num4 / 300f), (float) 0.03333334f), num4 / 5f); float num6 = (length <= 0f) ? 0.03333334f : Mathf.Min(Mathf.Max((float) (length / 300f), (float) 0.03333334f), length / 5f); a = Mathf.Max(a, num3 / 300f); num6 = Mathf.Max(num6, num3 / 300f); float deltaTime = a; float num8 = 0f; bool flag2 = false; bool flag3 = false; bool flag4 = false; this.m_AvatarPreview.Animator.StartRecording(-1); this.m_LeftStateWeightA = 0f; this.m_LeftStateTimeA = 0f; this.m_AvatarPreview.Animator.Update(0f); int num9 = 0; while (!flag4) { num9++; this.m_AvatarPreview.Animator.Update(deltaTime); AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex); num8 += deltaTime; if (!flag2) { this.m_LeftStateWeightA = currentAnimatorStateInfo.normalizedTime; this.m_LeftStateTimeA = num8; flag2 = true; } if (flag3 && (num8 >= num3)) { flag4 = true; } if (!flag3 && currentAnimatorStateInfo.IsName(this.m_DstState.name)) { this.m_RightStateWeightA = currentAnimatorStateInfo.normalizedTime; this.m_RightStateTimeA = num8; flag3 = true; } if (!flag3) { this.m_LeftStateWeightB = currentAnimatorStateInfo.normalizedTime; this.m_LeftStateTimeB = num8; } if (flag3) { this.m_RightStateWeightB = currentAnimatorStateInfo.normalizedTime; this.m_RightStateTimeB = num8; } if (this.m_AvatarPreview.Animator.IsInTransition(this.m_LayerIndex)) { deltaTime = num6; } } float num10 = num8; this.m_AvatarPreview.Animator.StopRecording(); if (Mathf.Approximately(this.m_LeftStateWeightB, this.m_LeftStateWeightA) || Mathf.Approximately(this.m_RightStateWeightB, this.m_RightStateWeightA)) { Debug.LogWarning("Speed difference between states is too big. Transition preview will be disabled."); this.m_ValidTransition = false; } else { float num11 = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA); float num12 = (this.m_RightStateTimeB - this.m_RightStateTimeA) / (this.m_RightStateWeightB - this.m_RightStateWeightA); if (this.m_MustSampleMotions) { this.m_MustSampleMotions = false; this.m_SrcPivotList.Clear(); this.m_DstPivotList.Clear(); deltaTime = num6; this.m_StateMachine.defaultState = this.m_DstState; this.m_Transition.mute = true; AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_AvatarPreview.Animator.Update(0f); this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f); this.m_AvatarPreview.Animator.Update(1E-07f); this.WriteParametersInController(); for (num8 = 0f; num8 <= num12; num8 += deltaTime * 2f) { Timeline.PivotSample item = new Timeline.PivotSample { m_Time = num8, m_Weight = this.m_AvatarPreview.Animator.pivotWeight }; this.m_DstPivotList.Add(item); this.m_AvatarPreview.Animator.Update(deltaTime * 2f); } deltaTime = a; this.m_StateMachine.defaultState = this.m_SrcState; this.m_Transition.mute = true; AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_AvatarPreview.Animator.Update(1E-07f); this.WriteParametersInController(); this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f); for (num8 = 0f; num8 <= num11; num8 += deltaTime * 2f) { Timeline.PivotSample sample2 = new Timeline.PivotSample { m_Time = num8, m_Weight = this.m_AvatarPreview.Animator.pivotWeight }; this.m_SrcPivotList.Add(sample2); this.m_AvatarPreview.Animator.Update(deltaTime * 2f); } this.m_Transition.mute = false; AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller); this.m_AvatarPreview.Animator.Update(1E-07f); this.WriteParametersInController(); } this.m_Timeline.StopTime = this.m_AvatarPreview.timeControl.stopTime = num10; this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time; if (flag) { float num13; this.m_AvatarPreview.timeControl.currentTime = num13 = this.m_AvatarPreview.timeControl.startTime = 0f; this.m_Timeline.StartTime = num13; this.m_Timeline.Time = num13; this.m_Timeline.ResetRange(); } this.m_AvatarPreview.Animator.StartPlayback(); this.m_IsResampling = false; } } } }
protected void _addStateTransition(AnimationState fromState, AnimationState targetState, float transitionTime, bool triggerOnAnimationEnd) { var newTransition = new TransitionInfo (); newTransition.sorce = fromState; newTransition.target = targetState; newTransition.transitionTime = transitionTime; newTransition.triggerOnAnimationEnd = triggerOnAnimationEnd; foreach (var transition in _transitions) { if (transition.Equals (newTransition)) { var errMsg = "Idential animation transition already defined."; System.Console.WriteLine (errMsg); throw new Exception (errMsg); } } _transitions.Add (newTransition); }
private static void ParseEventHandler(CompositeActivity eventHandler, List<TransitionInfo> transitions) { Queue<Activity> processingQueue = new Queue<Activity>(); processingQueue.Enqueue(eventHandler); while (processingQueue.Count > 0) { Activity activity = processingQueue.Dequeue(); SetStateActivity setState = activity as SetStateActivity; if (setState != null) { TransitionInfo transitionInfo = new TransitionInfo(setState, eventHandler); transitions.Add(transitionInfo); } else { CompositeActivity compositeActivity = activity as CompositeActivity; if (compositeActivity != null) { foreach (Activity childActivity in compositeActivity.Activities) { processingQueue.Enqueue(childActivity); } } } } }
Transition transitionCreate(TransitionInfo data) { var transition = new Transition(); transition.from = data.from; transition.to = data.to; transition.from.transitions.Add(transition); return transition; }
internal StateDesignerConnector FindConnector(TransitionInfo transitionInfo) { foreach (Connector connector in this.Connectors) { StateDesignerConnector stateDesignerConnector = connector as StateDesignerConnector; if (stateDesignerConnector != null) { if (transitionInfo.Matches(stateDesignerConnector)) return stateDesignerConnector; } } return null; }