/// <summary> /// Ejecuta una animación sobre una ruta /// </summary> private void ExecutePathAnimation(FrameworkElement control, PathActionModel action) { if (CheckMustAnimate(action)) { PathGeometry pathGeometry = new PathGeometry(); // Añade la ruta a la geometría pathGeometry.AddGeometry(Geometry.Combine(Geometry.Empty, Geometry.Parse(action.Path), GeometryCombineMode.Union, null)); // Asigna las animaciones CreateDoubleAnimationUsingPath(control, action, pathGeometry, PathAnimationSource.X, new PropertyPath(ComicPageView.PageTopProperty)); CreateDoubleAnimationUsingPath(control, action, pathGeometry, PathAnimationSource.Y, new PropertyPath(ComicPageView.PageLeftProperty)); } }
public async Task <PathModel> GetPathByKey(pathKey key) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); TrajetDB trajet = _paths.FirstOrDefault(o => o.Key == key.Key); PathModel pathToSend = new PathModel() { Name = trajet.Name, Type = trajet.Type, GroupLevelMax = trajet.GroupLevelMax, GroupLevelMin = trajet.GroupLevelMin, CaptureItem = trajet.CaptureItem, MaxPod = trajet.MaxPod, MonsterQuantityMin = trajet.MonsterQuantityMin, MonsterQuantityMax = trajet.MonsterQuantityMax, ListRessource = trajet.ListRessource, LeaderBank = trajet.LeaderBank, IsCapture = trajet.IsCapture, Key = trajet.Key.ToString() }; pathToSend.PathAction = new List <PathActionModel>(); foreach (var item in trajet.PathAction) { PathActionModel pathactionmodelToAdd = new PathActionModel(); pathactionmodelToAdd.MapPos = Database.Maps.Find(o => o.Key == item.MapId).First().Coordinate.Replace(',', ';').Replace("[", "").Replace("]", ""); pathactionmodelToAdd.Actions = new List <MapActionModel>(); foreach (var action in item.Actions) { MapActionModel mapaction = new MapActionModel() { Order = action.Order }; if (action is FightAction) { FightActionModel fight = new FightActionModel() { IsAlone = ((FightAction)action).IsAlone }; mapaction.FightAction = fight; } else if (action is BankAction) { BankActionModel bank = new BankActionModel() { MapId = item.MapId }; mapaction.BankAction = bank; } else if (action is GatherAction) { GatherActionModel gather = new GatherActionModel() { }; mapaction.GatherAction = gather; } else if (action is InteractionAction) { InteractionActionModel interaction = new InteractionActionModel() { InteractiveidObject = ((InteractionAction)action).InteractiveIdObject, InteractiveIdResponse = ((InteractionAction)action).InteractiveIdResponse, ToBackBank = ((InteractionAction)action).ToBackBank, ToGoBank = ((InteractionAction)action).ToGoBank }; mapaction.InteractionAction = interaction; } else if (action is MoveAction) { MoveActionModel move = null; if (((MoveAction)action).Direction != null) { move = new MoveActionModel() { Cellid = ((MoveAction)action).CellId, ToGoBank = ((MoveAction)action).ToGoBank, ToBackBank = ((MoveAction)action).ToBackBank, Direction = ((MoveAction)action).Direction.ConvertAll(o => o.ToString()), MapId = ((MoveAction)action).MapId }; } else { move = new MoveActionModel() { Cellid = ((MoveAction)action).CellId, ToGoBank = ((MoveAction)action).ToGoBank, ToBackBank = ((MoveAction)action).ToBackBank, Direction = null, MapId = ((MoveAction)action).MapId }; } mapaction.moveAction = move; } else if (action is UseItemAction) { UseItemActionModel useitem = new UseItemActionModel() { ToBackBank = ((UseItemAction)action).ToBackBank, ItemId = ((UseItemAction)action).ItemId, ToGoBank = ((UseItemAction)action).ToGoBank }; mapaction.UseItemAction = useitem; } else if (action is ZaapAction) { ZaapActionModel zaap = new ZaapActionModel() { ToGoBank = ((ZaapAction)action).ToGoBank, ToBackBank = ((ZaapAction)action).ToBackBank, Destination = Database.Maps.Find(o => o.Key == ((ZaapAction)action).Destination).First().Coordinate.Replace(',', ';').Replace("[", "").Replace("]", ""), ZaapId = ((ZaapAction)action).ZaapId }; mapaction.ZaapAction = zaap; } else if (action is ZaapiAction) { ZaapiActionModel zaapi = new ZaapiActionModel() { ToGoBank = ((ZaapAction)action).ToGoBank, ToBackBank = ((ZaapAction)action).ToBackBank, Destination = Database.Maps.Find(o => o.Key == ((ZaapAction)action).Destination).First().Coordinate.Replace(',', ';').Replace("[", "").Replace("]", ""), ZaapiId = ((ZaapAction)action).ZaapId }; mapaction.ZaapiAction = zaapi; } pathactionmodelToAdd.Actions.Add(mapaction); } ; pathToSend.PathAction.Add(pathactionmodelToAdd); } ; return(pathToSend); }
/// <summary> /// Carga los datos de un timeline /// </summary> internal TimeLineModel LoadTimeLine(PageModel page, MLNode nodeML) { TimeLineModel timeLine = new TimeLineModel(page, nodeML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); // Asigna los atributos AssignAttributesAction(nodeML, timeLine.Parameters, 0, 3); // Carga el contenido del timeLine foreach (MLNode childML in nodeML.Nodes) { ActionBaseModel action = null; // Obtiene la acción switch (childML.Name) { case ComicRepositoryConstants.TagActionShowImage: action = new SetVisibilityActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagVisible].Value.GetBool(true), childML.Attributes[ComicRepositoryConstants.TagOpacity].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagActionResize: action = new ResizeActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagWidth].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagHeight].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagActionRotate: action = new RotateActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5), childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5), childML.Attributes[ComicRepositoryConstants.TagAngle].Value.GetDouble(0), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagActionZoom: action = new ZoomActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagOriginX].Value.GetDouble(0.5), childML.Attributes[ComicRepositoryConstants.TagOriginY].Value.GetDouble(0.5), childML.Attributes[ComicRepositoryConstants.TagScaleX].Value.GetDouble(1), childML.Attributes[ComicRepositoryConstants.TagScaleY].Value.GetDouble(1), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagActionTranslate: action = new TranslateActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagTop].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagLeft].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagActionSetZIndex: action = new SetZIndexModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true), childML.Attributes[ComicRepositoryConstants.TagZIndex].Value.GetInt(1)); break; case ComicRepositoryConstants.TagActionPath: action = new PathActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, Mediator.CommonRepository.Normalize(childML.Value), childML.Attributes[ComicRepositoryConstants.TagRotateWithTangent].Value.GetBool(true), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagSetActionViewBox: action = new BrushViewBoxActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewBox].Value), Mediator.CommonRepository.GetRectangle(childML.Attributes[ComicRepositoryConstants.TagViewPort].Value), Mediator.CommonRepository.ConvertTile(childML.Attributes[ComicRepositoryConstants.TagTileMode].Value), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagSetActionRadialBrush: action = new BrushRadialActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagCenter].Value), Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagOrigin].Value), childML.Attributes[ComicRepositoryConstants.TagRadiusX].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagRadiusY].Value.GetDouble(), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; case ComicRepositoryConstants.TagSetActionLinearBrush: action = new BrushLinearActionModel(timeLine, childML.Attributes[ComicRepositoryConstants.TagKey].Value, Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagStart].Value), Mediator.CommonRepository.GetPoint(childML.Attributes[ComicRepositoryConstants.TagEnd].Value), Mediator.CommonRepository.GetSpreadMethod(childML.Attributes[ComicRepositoryConstants.TagSpread].Value), childML.Attributes[ComicRepositoryConstants.TagMustAnimate].Value.GetBool(true)); break; } // Si realmente se ha leído alguna acción if (action != null) { // Asigna los atributos AssignAttributesAction(childML, action.Parameters, timeLine.Parameters.Start, timeLine.Parameters.Duration); // Asigna las funciones LoadEases(action, childML); // Añade la acción al timeline timeLine.Actions.Add(action); } } // Devuelve el timeline return(timeLine); }