public AnimatedMovement(Animation animation, Movement movement) { this.animation = animation; movement.Redefine(); if (animation.HasChild) { switch (animation.MovementBehavior) { case MovementBehavior.ActAndDelegate: child = new AnimatedMovement(animation.Child.Clone(), movement.Clone()); this.movement = movement; break; case MovementBehavior.Act: child = new AnimatedMovement(animation.Child.Clone(), MovementProvider.GetStaticMovement(movement.Origin)); this.movement = movement; break; case MovementBehavior.Delegate: child = new AnimatedMovement(animation.Child.Clone(), movement.Clone()); this.movement = MovementProvider.GetStaticMovement(movement.Origin); break; } } else { this.movement = movement; } Origin = movement.Origin; }
public virtual void Dispose() { while (currentActions.Count > 0) { AnimatedMovement action = currentActions.Dequeue(); action.Dispose(); } }
public virtual void Update(float passedTime) { AnimatedMovement action = currentActions.Peek(); if (action.IsFinalized()) { RemoveActualAnimatedMovement(); } action.Update(passedTime); }
public void Dispose() { animation.Dispose(); animation = null; movement = null; if (child != null) { child.Dispose(); child = null; } }
public void AddAnimatedMovement(AnimationType key, Point startCell, Point endCell, float speed) { Animation nextAnimation = definedAnimations[key].Clone(); nextAnimation.LayerDepth = LayerDepth; nextAnimation.ColorModifier = ColorModifier; AnimatedMovement nextAction = new AnimatedMovement(nextAnimation, MovementProvider.GetMapMovement(startCell, endCell, speed)); AddNextAction(nextAction); }
public void AddAnimatedMovement(AnimationType key, Point cell) { Animation nextAnimation = definedAnimations[key].Clone(); nextAnimation.LayerDepth = LayerDepth; nextAnimation.ColorModifier = ColorModifier; AnimatedMovement nextAction = new AnimatedMovement(nextAnimation, MovementProvider.GetStaticMovement(cell)); AddNextAction(nextAction); }
public void AddAnimatedMovement(AnimationType key, Vector2 origin, Vector2 destiny, float speed) { Animation nextAnimation = definedAnimations[key].Clone(); nextAnimation.LayerDepth = LayerDepth; nextAnimation.ColorModifier = ColorModifier; AnimatedMovement nextAction = new AnimatedMovement(nextAnimation, MovementProvider.GetDirectMovement(origin, destiny, speed)); AddNextAction(nextAction); }
private void AddNextAction(AnimatedMovement nextAction) { if (currentActions.Count == 0) { nextAction.Start(); } if (IsIdle()) { nextAction.Origin = currentActions.Dequeue().Movement.Position; nextAction.Start(); } currentActions.Enqueue(nextAction); }
override public void Update(float passedTime) { AnimatedMovement action = currentMovements.Peek(); if (action.IsFinalized()) { currentMovements.Dequeue(); if (currentMovements.Count == 0) { AddAnimatedMovement(AnimationType.Static); } currentMovements.Peek().Movement.Origin = action.Movement.Position; action = currentMovements.Peek(); action.Animation.Start(); } action.Movement.Update(passedTime); action.Animation.Position = action.Movement.Position; action.Animation.Update(passedTime); }
public void RemoveActualAnimatedMovement() { if (currentActions.Count > 0) { AnimatedMovement action = currentActions.Dequeue(); if (currentActions.Count == 0) { if (DefaultDirection == DefaultDirection.Right) { AddAnimatedMovement(AnimationType.StaticRight, action.Animation.Position); } else { AddAnimatedMovement(AnimationType.StaticLeft, action.Animation.Position); } } AnimatedMovement nextAction = currentActions.Peek(); nextAction.Origin = action.Movement.Position; action.Finish(); nextAction.Start(); } }
override public void Update(float passedTime) { AnimatedMovement action = currentActions.Peek(); if (IsIdle() && !Ocupied && !drawingAffects && RandomMath.Percentage(0.001f)) { if (DefaultDirection == DefaultDirection.Right) { AddAnimatedMovement(AnimationType.NoneRight); } else { AddAnimatedMovement(AnimationType.NoneLeft); } currentActions.Peek().Origin = action.Movement.Position; } base.Update(passedTime); bool affectsFinished = true; foreach (Animation affectAnimation in affects.Values) { if (affectAnimation != null) { if (affectAnimation.IsFinalized()) { affectAnimation.IsVisible = false; } else { affectsFinished = false; } affectAnimation.Update(passedTime); affectAnimation.Position = this.Position; affectAnimation.LayerDepth = this.LayerDepth - 0.03f; } } drawingAffects = !affectsFinished; if (target != null && (IsReady() || IsIdle()) && !HealthVariation.IsVisible()) { target.Health.ReceiveDamage(targetDamage); if (target.Health.IsDead) { if (targetAnimation == AnimationType.HitRight) { target.AddAnimatedMovement(AnimationType.DieRight, target.MapLocation); target.AddAnimatedMovement(AnimationType.DeadRight, target.MapLocation); } else if (targetAnimation == AnimationType.HitLeft) { target.AddAnimatedMovement(AnimationType.DieLeft, target.MapLocation); target.AddAnimatedMovement(AnimationType.DeadLeft, target.MapLocation); } target.Ocupied = true; } else { target.AddAnimatedMovement(targetAnimation, target.MapLocation); target.Ocupied = false; } target.ShowHealthVariation(targetDamage * -1.0f); if (targetCounterAttack) { target.AttackCharacter(this, targetCounterDamage, false, 0); } target = null; } healthVariation.Update(passedTime); }