public CreatureAnimation Add(CreatureAnimation other) { var newCommands = new List <CreatureCommand>(commands); newCommands.AddRange(other.commands); return(new CreatureAnimation(newCommands)); }
public override CreatureAnimation MakeCurrentAnim() { CreatureAnimation result; if (isGoingUp) { var distToUpperBorder = Location.Y - originalCoords.Y + webSize.Height; if (distToUpperBorder > 8) { result = new CreatureAnimation().Add(new CreatureCommand { dy = -1 }).Repeat(8); } else { result = new CreatureAnimation().Add(new CreatureCommand { dy = -1 }).Repeat(distToUpperBorder) .Add(new CreatureAnimation().Add(new CreatureCommand { dy = 1 }).Repeat(8 - distToUpperBorder)); isGoingUp = false; } } else { var distToLowerBorder = (originalCoords.Y + webSize.Height + 64) - Location.Y; //remove magic constants (sprite size) if (distToLowerBorder > 8) { result = new CreatureAnimation().Add(new CreatureCommand { dy = 1 }).Repeat(8); } else { result = new CreatureAnimation() .Add(new CreatureCommand { dy = 1 }).Repeat(distToLowerBorder) .Add(new CreatureAnimation().Add(new CreatureCommand { dy = -1 }).Repeat(8 - distToLowerBorder)); isGoingUp = true; } } return(result); }
public void MakeRealAnim(List <Terrain> mapObjs, string pressedKey) { bool isOnGround = false; foreach (var o in mapObjs) { if (o.Hitbox.Contains(new Point(Location.X - o.Location.X, Location.Y - o.Location.Y + 64 + 1))) { isOnGround = true; break; } } if (isOnGround) { if (pressedKey == "A") { currentAnim = new CreatureAnimation().Add(new CreatureCommand { dx = -1 }).Repeat(8); } else if (pressedKey == "D") { currentAnim = new CreatureAnimation().Add(new CreatureCommand { dx = 1 }).Repeat(8); } else { currentAnim = new CreatureAnimation().Add(new CreatureCommand()).Repeat(8); } } else { currentAnim = new CreatureAnimation().Add(new CreatureCommand { dy = 1 }).Repeat(8); } }
public override CreatureAnimation MakeCurrentAnim() { CreatureAnimation result; if (!isGoingUp) { if (Location.Y > bottomY) { isGoingUp = true; } result = new CreatureAnimation() .Add(new CreatureCommand { dy = 1 }) .Add(new CreatureCommand { dx = 1, dy = 1 }) .Repeat(4); } else { if (Location.Y < originalY) { //disappear and remove from game.creatures } result = new CreatureAnimation() .Add(new CreatureCommand { dy = -1 }) .Add(new CreatureCommand { dx = 1, dy = -1 }) .Repeat(4); } return(result); }