/// <summary> /// Change the current animation to the specified animation. /// </summary> /// <param name="name">The unique identifier of the animation.</param> private void ChangeAnimation(string name) { if (String.IsNullOrEmpty(name)) { name = "idle"; } if (!_animationData.TryGetValue(name, out ComplexAnimData animData)) { return; throw new Exception("Animation not found."); } if (name == _currentName) { return; } // Reset animation and change current animation being used. _currentFrame = 0; _frameTimer.Reset(); _currentAnimationData = animData; _currentName = name; // Switch to the new texture and size. _texture = _currentAnimationData.Texture; _sourceRectangle.Width = _currentAnimationData.Width; _sourceRectangle.Height = _currentAnimationData.Height; _sourceRectangle.Y = _currentAnimationData.StartingY; AnimationStateChanged?.Invoke(); }
private void OnOpen() { collection.Set(MessageCodes.EnteredScene, SceneEntered.ToMessageHandler()); collection.Set(MessageCodes.ChangeScene, SceneChanged.ToMessageHandler()); collection.Set(MessageCodes.GameObjectAdded, GameObjectsAdded.ToMessageHandler()); collection.Set(MessageCodes.GameObjectRemoved, GameObjectsRemoved.ToMessageHandler()); collection.Set(MessageCodes.PositionChanged, PositionChanged.ToMessageHandler()); collection.Set(MessageCodes.AnimationStateChanged, AnimationStateChanged.ToMessageHandler()); collection.Set(MessageCodes.Attacked, Attacked.ToMessageHandler()); collection.Set(MessageCodes.BubbleNotification, BubbleMessageReceived.ToMessageHandler()); Connected?.Invoke(); }
private void ForwardAnimationStateChanged(object sender, AnimatedSurface.AnimationStateChangedEventArgs e) { AnimationStateChanged?.Invoke(sender, e); }
public void SetAnimationState(byte animationState) { this.animationState = animationState; AnimationStateChanged?.Invoke(); }