public void AddAnimation(StandardAnimation animationName, SpriteAnimation animation) { if (animation != null) { this.AddAnimation(animationName.ToString(), animation); } }
public void StandardAnimate(object animationObject, StandardAnimation animation, int animationSpeed) { Control control = animationObject as Control; if (animationSpeed < 1) { animationSpeed = 1; } if (animationSpeed > 10) { animationSpeed = 10; } if (animation == StandardAnimation.SlideRight) { int x = control.Location.X; control.Location = new Point(0 - control.Width, control.Location.Y); control.Refresh(); while (control.Location.X < x / 2) { control.Location = new Point(control.Location.X + 10 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X < x / 4) { control.Location = new Point(control.Location.X + 7 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X < x / 8) { control.Location = new Point(control.Location.X + 5 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X < x) { control.Location = new Point(control.Location.X + 2 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } control.Location = new Point(x, control.Location.Y); } if (animation == StandardAnimation.SlideLeft) { int x2 = control.Location.X; control.Location = new Point(control.Parent.Width + control.Width, control.Location.Y); control.Refresh(); while (control.Location.X > x2 + control.Width / 2) { control.Location = new Point(control.Location.X - 10 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X > x2 + control.Width / 4) { control.Location = new Point(control.Location.X - 7 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X > x2 + control.Width / 8) { control.Location = new Point(control.Location.X - 5 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } while (control.Location.X > x2) { control.Location = new Point(control.Location.X - 2 * animationSpeed, control.Location.Y); control.Refresh(); WaitAnimation(40); } control.Location = new Point(x2, control.Location.Y); } if (animation == StandardAnimation.SlideDown) { int y = control.Location.Y; control.Location = new Point(control.Location.X, 0 - control.Height); control.Refresh(); while (control.Location.Y < y / 2) { control.Location = new Point(control.Location.X, control.Location.Y + 10 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y < y / 4) { control.Location = new Point(control.Location.X, control.Location.Y + 7 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y < y / 8) { control.Location = new Point(control.Location.X, control.Location.Y + 5 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y < y) { control.Location = new Point(control.Location.X, control.Location.Y + 2 * animationSpeed); control.Refresh(); WaitAnimation(40); } control.Location = new Point(control.Location.X, y); } if (animation == StandardAnimation.SlideUp) { int y2 = control.Location.Y; control.Location = new Point(control.Location.X, control.Parent.Height + control.Height); control.Refresh(); while (control.Location.Y > y2 + control.Height / 2) { control.Location = new Point(control.Location.X, control.Location.Y - 10 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y > y2 + control.Height / 4) { control.Location = new Point(control.Location.X, control.Location.Y - 7 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y > y2 + control.Height / 8) { control.Location = new Point(control.Location.X, control.Location.Y - 5 * animationSpeed); control.Refresh(); WaitAnimation(40); } while (control.Location.Y > y2) { control.Location = new Point(control.Location.X, control.Location.Y - 2 * animationSpeed); control.Refresh(); WaitAnimation(40); } control.Location = new Point(control.Location.X, y2); } if (animation == StandardAnimation.SlugRight) { int x3 = control.Location.X; int width = control.Width; control.Location = new Point(0 - control.Width, control.Location.Y); control.Refresh(); while (control.Location.X < x3) { control.Location = new Point(control.Location.X + 8 * animationSpeed, control.Location.Y); control.Refresh(); control.Refresh(); WaitAnimation(100 / animationSpeed); while (control.Width > width / 2) { control.Width -= 3 * animationSpeed; control.Refresh(); WaitAnimation(50 / animationSpeed); } while (control.Width < width) { control.Width += 3 * animationSpeed; control.Refresh(); WaitAnimation(50 / animationSpeed); } } control.Location = new Point(x3, control.Location.Y); control.Width = width; control.Refresh(); } if (animation == StandardAnimation.SlugLeft) { int x4 = control.Location.X; int width2 = control.Width; control.Location = new Point(control.Parent.Width + control.Width, control.Location.Y); control.Refresh(); while (control.Location.X > x4) { control.Location = new Point(control.Location.X - 8 * animationSpeed, control.Location.Y); control.Refresh(); control.Refresh(); WaitAnimation(100 / animationSpeed); while (control.Width > width2 / 2) { control.Width -= 3 * animationSpeed; control.Refresh(); WaitAnimation(50 / animationSpeed); } while (control.Width < width2) { control.Width += 3 * animationSpeed; control.Refresh(); WaitAnimation(50 / animationSpeed); } } control.Location = new Point(x4, control.Location.Y); control.Width = width2; control.Refresh(); } if (animation == StandardAnimation.Hop) { int y3 = control.Location.Y; while (control.Location.Y > y3 - 20) { while (control.Location.Y > y3 - 10) { control.Location = new Point(control.Location.X, control.Location.Y - 5); control.Refresh(); WaitAnimation(100 / animationSpeed); } while (control.Location.Y > y3 - 18) { control.Location = new Point(control.Location.X, control.Location.Y - 4); control.Refresh(); WaitAnimation(100 / animationSpeed); } while (control.Location.Y > y3 - 20) { control.Location = new Point(control.Location.X, control.Location.Y - 2); control.Refresh(); WaitAnimation(100 / animationSpeed); } } while (control.Location.Y < y3) { while (control.Location.Y < y3 - 18) { control.Location = new Point(control.Location.X, control.Location.Y + 2); control.Refresh(); WaitAnimation(100 / animationSpeed); } while (control.Location.Y < y3 - 20) { control.Location = new Point(control.Location.X, control.Location.Y + 6); control.Refresh(); WaitAnimation(100 / animationSpeed); } control.Location = new Point(control.Location.X, y3); } } if (animation == StandardAnimation.ShootRight) { int x5 = control.Location.X; int y4 = control.Location.Y; Size size = control.Size; control.Size = new Size(control.Width, 6); control.Refresh(); control.Location = new Point(0 - control.Width, control.Location.Y + size.Height / 2 - 3); control.Refresh(); while (control.Width - size.Width < x5 + size.Width) { control.Size = new Size(control.Width + 50, control.Height); control.Refresh(); WaitAnimation(50 / animationSpeed); } control.Size = new Size(x5 + size.Width * 2, control.Height); control.Refresh(); while (control.Location.X < x5) { control.Location = new Point(control.Location.X + 25, control.Location.Y); control.Size = new Size(control.Width - 25, control.Height); control.Refresh(); WaitAnimation(50 / animationSpeed); } control.Size = size; control.Location = new Point(x5, y4); control.Refresh(); } if (animation == StandardAnimation.ShootLeft) { int x6 = control.Location.X; int y5 = control.Location.Y; Size size2 = control.Size; control.Size = new Size(control.Width, 6); control.Refresh(); control.Location = new Point(control.Parent.Width + control.Width, control.Location.Y + size2.Height / 2 - 3); control.Refresh(); while (control.Location.X > x6) { control.Size = new Size(control.Width + 50, control.Height); control.Location = new Point(control.Location.X - 50, control.Location.Y); control.Refresh(); WaitAnimation(50 / animationSpeed); } control.Size = new Size(x6 + size2.Width * 2, control.Height); control.Refresh(); while (control.Location.X + control.Width > size2.Width) { control.Size = new Size(control.Width - 25, control.Height); control.Refresh(); WaitAnimation(50 / animationSpeed); } control.Size = size2; control.Location = new Point(x6, y5); control.Refresh(); } }