private void DoMove(MovementPatternComponent movementPatternComponent, MoveableComponent moveableComponent) { switch (movementPatternComponent.MovementPattern) { case MovementPatterns.None: { break; } case MovementPatterns.Straight: { moveableComponent.MoveY = movementPatternComponent.DistanceY; break; } case MovementPatterns.ZigZag: { moveableComponent.MoveY = movementPatternComponent.DistanceY; moveableComponent.MoveX = movementPatternComponent.DistanceX; movementPatternComponent.DistanceX *= -1; break; } default: { throw new NotImplementedException("This movement pattern isnt implemented yet"); } } }
private bool CanMove(GameTime gameTime, MovementPatternComponent movementPatternComponent) { var result = false; movementPatternComponent.DelayTimer -= gameTime.ElapsedMiliseconds; if (movementPatternComponent.DelayTimer <= 0) { result = true; movementPatternComponent.DelayTimer = movementPatternComponent.Delay; } return(result); }