public bool UnPickCard() { if (this.CardEntityPicked != null) { CardEntity cardEntity = this.CardEntityPicked; if (cardEntity.ParentStar != null) { IAnimation positionAnimation = new PositionAnimation(cardEntity.Position, cardEntity.ParentStar.Position, Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.SQUARE_DEC); cardEntity.PlayAnimation(positionAnimation); this.CardEntityPicked = null; return(false); } else { this.RemoveEntityFromLayer(cardEntity); this.CardEntityPicked = null; return(true); } } return(false); }
public ScoreDomainPlayerLabel2D(ALayer2D parentLayer, int indexPlayer, Player player) : base(parentLayer) { this.score = -1; this.SpriteColor = new Color(0, 0, 0, 255); this.Canevas = new IntRect(0, 0, 200, 200); if (indexPlayer == 0) { this.offsetX = -200; } else { this.offsetX = 200; } this.offsetY = 40; this.CreateTextParagraph2D(new Vector2f(0, 10), new Vector2f(0, 0), Text2D.TextParagraph2D.Alignment.CENTER, 20); this.CreateTextParagraph2D(new Vector2f(0, 80), new Vector2f(0, 0), Text2D.TextParagraph2D.Alignment.CENTER, 20); this.CreateTextParagraph2D(new Vector2f(0, 30), new Vector2f(0, 0), Text2D.TextParagraph2D.Alignment.CENTER, 40); this.CreateTextParagraph2D(new Vector2f(0, 40), new Vector2f(0, 0), Text2D.TextParagraph2D.Alignment.CENTER, 25); this.UpdateTextOfParagraph(2, "field_title"); if (indexPlayer == 0) { this.UpdateTextOfParagraph(0, "score_domain_player_label", player.PlayerName); } else { this.UpdateTextOfParagraph(0, "score_domain_opponent_label", player.PlayerName); } this.textParagraph2Ds[0].UpdateParameterColor(0, player.PlayerColor); if (indexPlayer == 0) { this.UpdateTextOfParagraph(1, "score_domain_player_content"); } else { this.UpdateTextOfParagraph(1, "score_domain_opponent_content"); } this.UpdateTextOfParagraph(3, "score_domain_temporary_content"); this.IsActive = false; IAnimation anim = new PositionAnimation(this.Position, new Vector2f(-this.offsetX, 0), Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.LINEAR); this.animationsList.Add(anim); SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(1), AnimationType.ONETIME); anim = new ColorAnimation(new Color(0, 0, 0, 255), new Color(0, 0, 0, 0), Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.LINEAR); sequence.AddAnimation(0, anim); anim = new PositionAnimation(this.Position, this.Position + new Vector2f(0, 200), Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.LINEAR); sequence.AddAnimation(0.001f, anim); this.animationsList.Add(sequence); }
public BannerEntity2D(ALayer2D parentLayer) : base(parentLayer, null, false) { this.bannerShape = new RectangleShape(new Vector2f(3000, 200)); this.bannerShape.Origin = new Vector2f(this.bannerShape.Size.X / 2, this.bannerShape.Size.Y / 2); this.bannerShape.FillColor = new Color(0, 0, 0, 128); this.Position = new Vector2f(-this.bannerShape.Size.X, 0); SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(6), AnimationType.ONETIME); IAnimation anim = new PositionAnimation(new Vector2f(-this.bannerShape.Size.X, 0), new Vector2f(0, 0), Time.FromSeconds(2), AnimationType.ONETIME, InterpolationMethod.SQUARE_DEC); sequence.AddAnimation(0, anim); anim = new ColorAnimation(new Color(0, 0, 0, 128), new Color(0, 0, 0, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(5, anim); this.animationsList.Add(sequence); sequence = new SequenceAnimation(Time.FromSeconds(4), AnimationType.ONETIME); anim = new ColorAnimation(new Color(0, 0, 0, 0), new Color(0, 0, 0, 128), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(0, anim); anim = new ColorAnimation(new Color(0, 0, 0, 128), new Color(0, 0, 0, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(3, anim); this.animationsList.Add(sequence); anim = new ColorAnimation(new Color(0, 0, 0, 0), new Color(0, 0, 0, 128), Time.FromSeconds(0.5f), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); this.animationsList.Add(anim); anim = new ColorAnimation(new Color(0, 0, 0, 128), new Color(0, 0, 0, 0), Time.FromSeconds(0.5f), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); this.animationsList.Add(anim); }
public void ExecuteAction(BoardGameLayer layerToPerform) { Vector2f previousPosition = this.CardToSocket.Position; this.OwnerStar.CardSocketed = this.CardToSocket; if (this.MustTravel) { this.CardToSocket.Position = previousPosition; IAnimation positionAnimation = new PositionAnimation(previousPosition, this.OwnerStar.Position, Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.SQUARE_DEC); this.CardToSocket.PlayAnimation(positionAnimation); } if (layerToPerform.NameToOnBoardCardEntities.TryGetValue(this.CardToSocket.Card.Name, out HashSet <CardEntity> cardEntities)) { cardEntities.Add(this.CardToSocket); } else { layerToPerform.NameToOnBoardCardEntities.Add(this.CardToSocket.Card.Name, new HashSet <CardEntity>() { this.CardToSocket }); } //layerToPerform.CardEntityPicked = null; }
/// <summary> /// Centers the camera on the given position. /// </summary> private void SetCameraFocus(Vector2 position) { _cameraAnimation = new PositionAnimation( _camera, GetFocusPosition(position), 1f, Interpolate); }
private static IAnimation <Transform> CreateMoveToAnimation(Transform transform, float x, float y, float duration, IEasing easing = null) { var animation = new PositionAnimation(transform, new Point(x, y), duration); animation.Easing = easing; return(animation); }
public void PlayRemoveAnimation() { SequenceAnimation sequenceAnimation = new SequenceAnimation(Time.FromSeconds(1f), AnimationType.ONETIME); IAnimation animation = new PositionAnimation(this.Position, this.Position + new Vector2f(0, 50), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.LINEAR); sequenceAnimation.AddAnimation(0, animation); animation = new ColorAnimation(new Color(255, 255, 255, 255), new Color(255, 255, 255, 0), Time.FromSeconds(0.9f), AnimationType.ONETIME, InterpolationMethod.LINEAR); sequenceAnimation.AddAnimation(0.1f, animation); this.PlayAnimation(sequenceAnimation); }
public void Update_Time_UpdateValue() { var sinceSceneStart = 0f; var ctx = Substitute.For <IWorldContext>(); ctx.LogSystem.Returns(Substitute.For <ILogSystem>()); var time = Substitute.For <ITime>(); time.SinceSceneStart.Returns(c => { var r = sinceSceneStart; sinceSceneStart += 2.5f; return(r); }); ctx.Time.Returns(time); var owner = new Transform(1, 2, ctx); var target = new PositionAnimation(owner, new Point(3, 4), 5); target.Play(); Assert.AreEqual(new Point(1, 2), owner.Position); target.Pause(); target.Update(); Assert.AreEqual(new Point(1, 2), owner.Position); target.Resume(); sinceSceneStart -= 2.5f; target.Update(); Assert.AreEqual(new Point(2, 3), owner.Position); target.Update(); Assert.AreEqual(new Point(3, 4), owner.Position); Assert.AreEqual(AnimationState.Playing, target.State); target.Reset(); target.Play(); Assert.AreEqual(new Point(1, 2), owner.Position); Assert.AreEqual(AnimationState.Playing, target.State); target.Update(); target.Update(); target.Update(); Assert.AreEqual(new Point(3, 4), owner.Position); Assert.AreEqual(AnimationState.Stopped, target.State); }
private void UpdateCardsHandPosition() { float startWidth = this.HandPosition.X + HAND_CARD_SPACE * this.CardsHand.Count / 2f; int i = 0; bool cardFocusedEncountered = false; foreach (CardEntity cardEntity in this.CardsHand) { Vector2f newPosition; cardFocusedEncountered |= this.cardFocused == cardEntity; if (this.cardFocused != null) { if (this.cardFocused == cardEntity) { newPosition = new Vector2f(startWidth - i * HAND_CARD_SPACE, this.HandPosition.Y); } else if (cardFocusedEncountered) { newPosition = new Vector2f(startWidth - (i + 1) * HAND_CARD_SPACE, this.HandPosition.Y); } else { newPosition = new Vector2f(startWidth - (i - 1) * HAND_CARD_SPACE, this.HandPosition.Y); } } else { newPosition = new Vector2f(startWidth - i * HAND_CARD_SPACE, this.HandPosition.Y); } IAnimation positionAnimation; if (this.cardFocused != null) { positionAnimation = new PositionAnimation(cardEntity.Position, newPosition, Time.FromSeconds(1f), AnimationType.ONETIME, InterpolationMethod.SQUARE_DEC); } else { positionAnimation = new PositionAnimation(cardEntity.Position, newPosition, Time.FromSeconds(2f), AnimationType.ONETIME, InterpolationMethod.SIGMOID); } cardEntity.PlayAnimation(positionAnimation); i++; } }
private void AddPositionAnimation(PositionAnimation animation) { for (int i = 0; i < animation.PointCount; i++) { PositionXTimeline.KeyFrames.Add( new LinearDoubleKeyFrame( animation.Points[i].X, i == 0 ? KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animation.StartTime)) : i == animation.PointCount - 1 ? KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animation.EndTime)) : KeyTime.Uniform)); PositionYTimeline.KeyFrames.Add( new LinearDoubleKeyFrame( animation.Points[i].Y, i == 0 ? KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animation.StartTime)) : i == animation.PointCount - 1 ? KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animation.EndTime)) : KeyTime.Uniform)); } }
private void InitializeStartState() { this.DecoratorState = CardDecoratorState.START; if (this.parentLayer.TryGetTarget(out ALayer2D layer2D)) { Vector2f fromPosition = (layer2D as BoardNotifLayer2D).GetPositionFrom((layer2D.GetEntityFromEntity2D(this) as CardEntityAwakenedDecorator).CardEntityDecorated.ParentLayer, this.initialPosition); SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(1), AnimationType.ONETIME); IAnimation animation = new ColorAnimation(new Color(255, 255, 255, 0), new Color(255, 255, 255, 255), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.LINEAR); sequence.AddAnimation(0.01f, animation); animation = new PositionAnimation(fromPosition, new Vector2f(0, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); sequence.AddAnimation(0, animation); this.PlayAnimation(sequence); } }
public EffectBehaviorLabel2D(ALayer2D parentLayer) : base(parentLayer) { this.startingPosition = new Vector2f(0, 0); this.offset = new Vector2f(0, 0); this.bannerShape = new RectangleShape(new Vector2f(500, 200)); this.SpriteColor = new Color(0, 0, 0, 255); this.Position = new Vector2f(0, 0); this.idLabelToIndex = new Dictionary <Type, string>(); this.CreateTextParagraph2D(new Vector2f(0, 15), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 30); this.UpdateTextOfParagraph(0, "field_title"); this.textParagraph2Ds[0].UpdateParameterColor(0, new Color(200, 200, 200, 255)); this.CreateTextParagraph2D(new Vector2f(0, 60), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 20); this.UpdateTextOfParagraph(1, "behavior_header_label"); this.CreateTextParagraph2D(new Vector2f(0, 110), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 20); this.CreateTextParagraph2D(new Vector2f(25, 150), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 20); this.UpdateTextOfParagraph(3, "behavior_using_label"); this.CreateTextParagraph2D(new Vector2f(-355, 145), new Vector2f(0, 0), TextParagraph2D.Alignment.CENTER, 30); this.UpdateTextOfParagraph(4, "field_title"); this.textParagraph2Ds[4].UpdateParameterColor(0, Color.Green); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.MoveCardNotifBehavior), "move_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.SwapCardNotifBehavior), "swap_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.DeleteCardNotifBehavior), "delete_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.ResurrectCardNotifBehavior), "resurrect_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.SocketCardNotifBehavior), "play_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.SocketNewCardNotifBehavior), "play_new_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.ConvertCardNotifBehavior), "convert_behavior_label"); this.idLabelToIndex.Add(typeof(Model.Layer.BoardNotifLayer.Behavior.AddPointsNotifBehavior), "addPoints_behavior_label"); IAnimation showAnimation = new PositionAnimation(new Vector2f(0, 0), new Vector2f(this.Canevas.Width, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); this.animationsList.Add(showAnimation); //IAnimation showAnimation = new ColorAnimation(new Color(0, 0, 0, 0), new Color(0, 0, 0, 255), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); //this.animationsList.Add(showAnimation); //SequenceAnimation sequence = new SequenceAnimation(Time.FromSeconds(2), AnimationType.LOOP); //IAnimation focusedAnimation = new ColorAnimation(new Color(0, 0, 0, 255), new Color(125, 125, 125, 255), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.LINEAR); //sequence.AddAnimation(0, focusedAnimation); //focusedAnimation = new ColorAnimation(new Color(125, 125, 125, 255), new Color(0, 0, 0, 255), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.LINEAR); //sequence.AddAnimation(1, focusedAnimation); //this.animationsList.Add(sequence); //IAnimation hideAnimation = new ColorAnimation(new Color(0, 0, 0, 255), new Color(0, 0, 0, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); //this.animationsList.Add(hideAnimation); IAnimation hideAnimation = new PositionAnimation(new Vector2f(this.Canevas.Width, 0), new Vector2f(0, 0), Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); this.animationsList.Add(hideAnimation); IAnimation labelChangedAnimation = new ZoomAnimation(2, 1, Time.FromSeconds(1), AnimationType.ONETIME, InterpolationMethod.SQUARE_ACC); this.animationsList.Add(labelChangedAnimation); this.IsActive = false; }