public object Clone() { FrameAnimationClass f = new FrameAnimationClass(); f.frameLength = frameLength; f.frames = frames; return f; }
private void InitializeNPCs() { FrameAnimationClass up = new FrameAnimationClass(2, Engine.TileHeight, Engine.TileHeight, 0, 0); player_char.Animations.Add("Up", up); FrameAnimationClass down = new FrameAnimationClass(2, Engine.TileHeight, Engine.TileHeight, 64, 0); player_char.Animations.Add("Down", down); FrameAnimationClass left = new FrameAnimationClass(2, Engine.TileHeight, Engine.TileHeight, 128, 0); player_char.Animations.Add("Left", left); FrameAnimationClass right = new FrameAnimationClass(2, Engine.TileHeight, Engine.TileHeight, 64 + 128, 0); player_char.Animations.Add("Right", right); player_char.CurrentAnimationName = "Down"; player_char.Position = GetValidPositionForNPCs(); foreach (AnimatedSprite npc in npcs) { npc.Animations.Add("Up", (FrameAnimationClass)up.Clone()); npc.Animations.Add("Down", (FrameAnimationClass)down.Clone()); npc.Animations.Add("Left", (FrameAnimationClass)left.Clone()); npc.Animations.Add("Right", (FrameAnimationClass)right.Clone()); int animation = r.Next(3); switch (animation) { case 0: npc.CurrentAnimationName = "Up"; break; case 1: npc.CurrentAnimationName = "Down"; break; case 2: npc.CurrentAnimationName = "Left"; break; case 3: npc.CurrentAnimationName = "Right"; break; } npc.Position = GetValidPositionForNPCs(); } }